Text
<gcds-text>
-
GitHub -
Figma
Text component preview
On this page
Coding and accessibility for text
Ensure accessible character limits
- Maintain the default line length maximum of 65 characters for each line of text to ensure a comfortable, accessible reading length.
- Opt to shorten the line length by setting the
character-limitattribute tofalse.
Set the text size
- Set the text
sizeattribute tobodyorsmall. - Use the default
bodysizevalue to render apelement with the recommended font size and colour contrast. - Opt to display smaller text by setting the
sizeattribute tosmallto render asmallelement inside apelement.
Use text styling sparingly
- Only use underline for links.
- Use bold text sparingly.
- Avoid using bold text as a heading. Headings are the accessible component for identifying content sections.
- For bold text, use the
strongtag within thegcds-textcomponent to highlight terms and emphasize key points. - Only use italics for:
- Legal reference, like the Accessible Canada Act.
- Words in other languages, including Latin.
- Titles of publications, works of art, and mathematical and scientific material.
- Use the
emtag within thegcds-textcomponent to emphasize specific words or phrases. - Use the HTML
codeelement within thegcds-textcomponent to wrap content that represents code. Thecodeelement is styled with the monospace typography token.
Examples
In this section
Optional attributes
character-limit
character-limit attribute sets the line length to a maximum amount of characters per line to ensure a comfortable, accessible reading length. <gcds-text character-limit="false">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> display
display attribute sets the display behaviour of the text. The available options are: block(default)flexinlineinline-blockinline-flexnone
<gcds-text display="flex">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> margin-bottom
margin-bottom attribute sets a margin below the text. The default margin-bottom is 300. <gcds-text margin-bottom="600">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> margin-top
margin-top attribute sets a margin above the text. The default margin-top is 0. <gcds-text margin-top="600">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> size
size attribute sets the text size. The available options are: body(default)small
<gcds-text size="small">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> text-role
text-role attribute sets the main style of the text. The available options are: primary(default)secondarylight
<gcds-text text-role="secondary">
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> Slots
default
default slot is for placing the content of the text element. <gcds-text>
This is text that's related to the heading and describes in further detail the heading's subject or action. Text is typically one or several lines or paragraphs that form a section's content or introduce a bulleted list, table, or other content, like an image or video.
</gcds-text> - Explore by choosing different code values to generate the instance you want.
- Get the code and pull it into your environment.
- Add any copy you need to the component (like text for a label).
This is text that’s related to the heading and describes in further detail the heading’s subject or action. Text is typically one or several lines or paragraphs that form a section’s content or introduce a bulleted list, table, or other content, like an image or video.