The psammead-figure
component is a styled <figure>
element. It has the same semantic meaning -- it should be used to surround images, tables or code snippets.
npm install @bbc/psammead-figure
Argument | Type | Required | Default | Example |
---|---|---|---|---|
No props. |
The following example shows psammead-figure
wrapping an
- psammead-image-placeholder, a
<div>
with background image - psammead-image, an
<img>
- psammead-caption, a
<figcaption>
- psammead-copyright, a
<p>
- psammead-visually-hidden-text, a hidden
<span>
available only to assistive technology
import Caption from '@bbc/psammead-caption';
import Copyright from '@bbc/psammead-copyright';
import Figure from '@bbc/psammead-figure';
import Image from '@bbc/psammead-image';
import ImagePlaceholder from '@bbc/psammead-image-placeholder';
import VisuallyHiddenText from '@bbc/psammead-visually-hidden-text';
const Wrapper = ({ alt, captionText, ratio, src, width }) => (
<Figure>
<ImagePlaceholder ratio={ratio}>
<Image alt={alt} src={src} width={width} />
<Copyright>
<VisuallyHiddenText>Image copyright, </VisuallyHiddenText>
{copyrightOwner}
</Copyright>
</ImagePlaceholder>
<Caption>
<VisuallyHiddenText>Image caption, </VisuallyHiddenText>
{captionText}
</Caption>
</Figure>
);
Use this component when a <figure>
element, which represents self-contained content that frequently has a caption, is required. Figures usually wrap an image.
The psammead-figure
is a <figure>
element with associated styles. When you use this component, it has the same semantic meaning as a regular figure element.
Psammead is completely open source. We are grateful for any contributions, whether they be new components, bug fixes or general improvements. Please see our primary contributing guide which can be found at the root of the Psammead respository.
We welcome feedback and help on this work. By participating in this project, you agree to abide by the code of conduct. Please take a moment to read it.
Psammead is Apache 2.0 licensed.