Detail Text
Detail text is typography used for short pieces of secondary text content.
const DetailTextExample = () => {return (<Box maxWidth='size30'><Box as='img' alt='' src='/images/detail-text/detail-text-image.png' maxWidth='100%' /><DetailText>Your sender identity is the “from” email address your recipients will see in their inbox.</DetailText></Box>);};render(<DetailTextExample />)
The Detail Text component is used for small pieces of text that are secondary to body text in the hierarchy of a page. Common examples include an image caption, chart element legend, or a paragraph footnote.
Detail Text should not be used for body text, and should be reserved for small pieces of content only. It should not be used solely for its stylistic properties within other typographic elements.
The Detail Text component is a div
element by default. You can modify the element in situations where a div
isn’t semantically correct. For example, set as=”figcaption”
if working with Detail Text inside a figure
element.
If your Detail Text is used to describe another element, use an id
for the Detail Text component and aria-describedby
for the other element to make the connection clear.
Detail Text is not the same as alt text on images. The context and content of your usage might mean including alt text for further detail, or making alt text an empty string to prevent redundancy. Learn more about alt text and when to use it.
Use Detail Text to add a caption below an image.
const DetailTextExample = () => {return (<Box maxWidth='size30'><Box as='img' alt='' src='/images/detail-text/detail-text-image.png' maxWidth='100%' /><DetailText>Your sender identity is the “from” email address your recipients will see in their inbox.</DetailText></Box>);};render(<DetailTextExample />)
Use Detail Text to add a description below primary content for extra context.
const DetailTextExample = () => {return (<Table><THead><Tr><Th>User</Th><Th>Skills</Th><Th textAlign="right">Tasks</Th></Tr></THead><TBody><Tr><Th scope="row"><Text as="span">Adam Brown</Text><DetailText marginTop='space0'>adam@brown.com</DetailText></Th><Td>English, French, Sales, Spanish</Td><Td textAlign="right">35</Td></Tr><Tr><Th scope="row"><Text as="span">Adriana Lovelock</Text><DetailText marginTop='space0'>adriana@lovelock.com</DetailText></Th><Td>English, French, Sales, Spanish</Td><Td textAlign="right">28</Td></Tr><Tr><Th scope="row"><Text as="span">Amanda Cutlack</Text><DetailText marginTop='space0'>amanda@cutlack.com</DetailText></Th><Td>English, French, Sales, Spanish</Td><Td textAlign="right">7</Td></Tr></TBody></Table>);};render(<DetailTextExample />)
Detail Text includes a marginTop prop to remove its default top margin of space30
.
const DetailTextExample = () => {return (<Box maxWidth='size30'><Card><Headingas='h3'variant='heading50'marginBottom='space0'>Average handle time</Heading><Box display='grid' gridTemplateColumns='1fr auto' marginTop='space70' marginBottom='space90'><TextfontWeight='fontWeightSemibold'fontSize='fontSize90'lineHeight='lineHeight70'>3m</Text><Box display='flex' flexDirection='row' alignItems='center' color='colorTextPrimary'><ArrowUpIcon decorative={true} size='sizeIcon80' /><TextfontWeight='fontWeightSemibold'fontSize='fontSize90'lineHeight='lineHeight70'color='inherit'>8%</Text></Box></Box><Text fontSize='fontSize30' lineHeight='lineHeight60'>Handle time by hour</Text><Boxas='img'src='/images/detail-text/graph.png'maxWidth='100%'marginBottom='space90'alt='Sample graph showing how the handle time increased after 10:00 AM today compared to yesterday.'/><Box display='grid' gridTemplateColumns='1fr auto' columnGap='space50'><Boxdisplay='flex'flexDirection='row'justifyContent='flex-end'columnGap='space40'alignItems='center'><BoxborderTopStyle='solid'borderTopColor='colorBorderPrimary'borderTopWidth='borderWidth20'width='sizeSquare50'/><DetailText marginTop='space0'>Today</DetailText></Box><Boxdisplay='flex'flexDirection='row'justifyContent='flex-end'columnGap='space40'alignItems='center'><BoxborderTopStyle='dashed'borderTopColor='colorBorderWeak'borderTopWidth='borderWidth20'width='sizeSquare50'/><DetailText marginTop='space0'>Yesterday</DetailText></Box></Box></Card></Box>);};render(<DetailTextExample />)
Use Detail Text to add a footnote below a paragraph.
const DetailTextExample = () => {return (<><Heading as='h2' variant='heading20'>Auth tokens</Heading><Paragraph>Auth tokens can be used to authenticate while making API requests. You will need to use HTTP Basic Authentication with user = Account SID and password = AuthToken. Auth tokens are specific to your account and can be used to access all API’s for the account.</Paragraph><DetailText>*Please keep the auth tokens in a secure place and rotate them periodically.</DetailText></>);};render(<DetailTextExample />)
Do
Use Detail Text for small pieces of text that are not the main content of the UI, like graph legends and image captions
Don't
Don’t use Detail Text for body content. Consider using Paragraph instead.
Do
Use Detail Text semantically
Don't
Don’t use Detail Text for stylistic purposes within other typography. Consider using the Text primitive instead.
yarn add @twilio-paste/detail-text - or - yarn add @twilio-paste/core
import {DetailText} from '@twilio-paste/core/detail-text';
const Component = () => <DetailText>This is my detail text.</DetailText>;
Prop | Type | Description | Default |
---|---|---|---|
as? | string | The HTML tag to render the Detail Text as | 'div' |
marginTop? | 'space0' \| 'space30' | The marginTop of the DetailText. Currently we only allow space0 to remove top margin. | 'space30' |
children? | React.ReactNode | The content of the DetailText | |
element? | string | Overrides the default element name to apply unique styles with the Customization Provider | 'DETAIL_TEXT' |
Detail Text is available in the Paste Components Figma library.
Property | Variants | Description | Default |
---|---|---|---|
Margin | "Yes", "No" | If there is a margin on top of the Detail Text. | "Yes" |
Changelog
733709127
#3395 Thanks @SiTaggart! - Modified the compile target of our JavaScript bundles fromnode
tobrowser
to minimize the risk of clashing with RequireJS. This is marked as a major out of an abundance of caution. You shouldn't need to do anything but we wanted you to be aware of the change on the off chance it has unintended consequences
- Updated dependencies [
733709127
]:- @twilio-paste/color-contrast-utils@5.0.0
- @twilio-paste/box@10.0.0
- @twilio-paste/customization@8.0.0
- @twilio-paste/design-tokens@10.0.0
- @twilio-paste/animation-library@2.0.0
- @twilio-paste/styling-library@3.0.0
- @twilio-paste/style-props@9.0.0
- @twilio-paste/theme@11.0.0
- @twilio-paste/types@6.0.0
3ab2bb6f4
#3114 Thanks @SiTaggart! - ### Breaking changeWe have moved
@types/react
and@types/react-dom
to peer dependencies of the library. This should allow for greater control and backwards compatibility with older versions of React as Paste is no longer bundling the type libraries.Your application likely has both of these as dependencies anyway, but it is now up to you to manage that version number.
Action needed
Ensure
@types/react
and@types/react-dom
are installed as dependencies of your application.
- Updated dependencies [
bce889344
,3ab2bb6f4
,3ab2bb6f4
]:- @twilio-paste/theme@10.0.0
- @twilio-paste/box@9.0.0
- @twilio-paste/customization@7.0.0
- @twilio-paste/style-props@8.0.0
- @twilio-paste/types@5.0.0
b1ae14e22
#3000 Thanks @shleewhite! - [Detail Text] create the new DetailText component, meant to be used for short pieces of secondary text content.
d97098846
#3020 Thanks @SiTaggart! - This major version included listing all the missing peer dependencies for each Paste package.If you are using a package from Paste in isolation from Core, when upgrading to this latest version, be sure to correctly install all the missing peer dependencies.
- Updated dependencies [
dbd9bf992
,3c89fd83d
,d97098846
,0acdf3486
,ef094db4a
,0acdf3486
]:- @twilio-paste/design-tokens@9.0.0
- @twilio-paste/box@8.0.0
- @twilio-paste/customization@6.0.0
- @twilio-paste/animation-library@1.0.0
- @twilio-paste/styling-library@2.0.0
- @twilio-paste/style-props@7.0.0
- @twilio-paste/theme@9.0.0
- @twilio-paste/types@4.0.0
- @twilio-paste/color-contrast-utils@4.0.0