Import
import { Caption } from '@contentful/f36-components';// orimport { Caption } from '@contentful/f36-typography';
Examples
Basic
function CaptionExample() {return (<Flex flexDirection="column"><Caption fontWeight="fontWeightMedium">Status</Caption><Caption>Published</Caption></Flex>);}
as property
We provide you with as property, to allow you to set the tag of the Caption component to another tag than span.
function CaptionExample() {return (<Flex flexDirection="column"><Caption as="p">Status</Caption></Flex>);}
Props (API reference)
Open in StorybookName | Type | Default |
|---|---|---|
| as | "a" "abbr" "address" "animate" "animateMotion" "animateTransform" "area" "article" "aside" "audio" "b" "base" "bdi" "bdo" "big" "blockquote" "body" "br" "button" "canvas" "caption" "center" "circle" "cite" "clipPath" "code" "col" "colgroup" "data" "datalist" "dd" "defs" "del" "desc" "details" "dfn" "dialog" "div" "dl" "dt" "ellipse" "em" "embed" "feBlend" "feColorMatrix" "feComponentTransfer" "feComposite" "feConvolveMatrix" "feDiffuseLighting" "feDisplacementMap" "feDistantLight" "feDropShadow" "feFlood" "feFuncA" "feFuncB" "feFuncG" "feFuncR" "feGaussianBlur" "feImage" "feMerge" "feMergeNode" "feMorphology" "feOffset" "fePointLight" "feSpecularLighting" "feSpotLight" "feTile" "feTurbulence" "fieldset" "figcaption" "figure" "filter" "footer" "foreignObject" "form" "g" "h1" "h2" "h3" "h4" "h5" "h6" "head" "header" "hgroup" "hr" "html" "i" "iframe" "image" "img" "input" "ins" "kbd" "keygen" "label" "legend" "li" "line" "linearGradient" "link" "main" "map" "mark" "marker" "mask" "menu" "menuitem" "meta" "metadata" "meter" "mpath" "nav" "noindex" "noscript" "object" "ol" "optgroup" "option" "output" "p" "param" "path" "pattern" "picture" "polygon" "polyline" "pre" "progress" "q" "radialGradient" "rect" "rp" "rt" "ruby" "s" "samp" "script" "search" "section" "select" "set" "slot" "small" "source" "span" "stop" "strong" "style" "sub" "summary" "sup" "svg" "switch" "symbol" "table" "tbody" "td" "template" "text" "textarea" "textPath" "tfoot" "th" "thead" "time" "title" "tr" "track" "tspan" "u" "ul" "use" "var" "video" "view" "wbr" "webview" ComponentClass<any, any> FunctionComponent<any> | |
| children | ReactNode | |
| className | string CSS class to be appended to the root element | |
| fontColor | "blue100" "blue200" "blue300" "blue400" "blue500" "blue600" "blue700" "blue800" "blue900" "gray100" "gray200" "gray300" "gray400" "gray500" "gray600" "gray700" "gray800" "gray900" "green100" "green200" "green300" "green400" "green500" "green600" "green700" "green800" "green900" "orange100" "orange200" "orange300" "orange400" "orange500" "orange600" "orange700" "orange800" "orange900" "purple100" "purple200" "purple300" "purple400" "purple500" "purple600" "purple700" "purple800" "purple900" "red100" "red200" "red300" "red400" "red500" "red600" "red700" "red800" "red900" "colorPrimary" "colorPositive" "colorNegative" "colorWarning" "colorWhite" "yellow100" "yellow200" "yellow300" "yellow400" "yellow500" "yellow600" "yellow700" "yellow800" "yellow900" | |
| fontSize | "fontSize4Xl" "fontSize3Xl" "fontSize2Xl" "fontSizeXl" "fontSizeXlHigh" "fontSizeL" "fontSizeLHigh" "fontSizeM" "fontSizeMHigh" "fontSizeS" "fontSizeSHigh" | |
| fontStack | "fontStackPrimary" "fontStackMonospace" | |
| fontWeight | "fontWeightNormal" "fontWeightMedium" | |
| isTruncated | false true | |
| isWordBreak | false true | |
| letterSpacing | "letterSpacingDefault" "letterSpacingWide" | |
| lineHeight | "lineHeightDefault" "lineHeightCondensed" "lineHeight4Xl" "lineHeight3Xl" "lineHeight2Xl" "lineHeightXl" "lineHeightXlHigh" "lineHeightL" "lineHeightLHigh" "lineHeightM" "lineHeightMHigh" "lineHeightS" "lineHeightSHigh" | |
| margin | "spacing2Xs" "spacingXs" "spacingS" "spacingM" "spacingL" "spacingXl" "spacing2Xl" "spacing3Xl" "spacing4Xl" "none" sets margin to one of the corresponding spacing tokens | |
| marginBottom | "spacing2Xs" "spacingXs" "spacingS" "spacingM" "spacingL" "spacingXl" "spacing2Xl" "spacing3Xl" "spacing4Xl" "none" sets margin-bottom to one of the corresponding spacing tokens | |
| marginLeft | "spacing2Xs" "spacingXs" "spacingS" "spacingM" "spacingL" "spacingXl" "spacing2Xl" "spacing3Xl" "spacing4Xl" "none" sets margin-left to one of the corresponding spacing tokens | |
| marginRight | "spacing2Xs" "spacingXs" "spacingS" "spacingM" "spacingL" "spacingXl" "spacing2Xl" "spacing3Xl" "spacing4Xl" "none" sets margin-right to one of the corresponding spacing tokens | |
| marginTop | "spacing2Xs" "spacingXs" "spacingS" "spacingM" "spacingL" "spacingXl" "spacing2Xl" "spacing3Xl" "spacing4Xl" "none" sets margin-top to one of the corresponding spacing tokens | |
| testId | string A [data-test-id] attribute used for testing purposes |
Density support
This component supports multiple densities thanks to the useDensity hook and automatically adjusts its styling for each density (when wrapped with the DensityProvider).