Text
The Text component is a versatile typography tool designed to handle various textual styles and semantics within the UI. It supports multiple text tones and size variants, ensuring consistency and adaptability across your app.
Effective Practices
When using the Text component, consider the following best practices:
- Semantic Correctness: Always choose the appropriate HTML element (
asprop) to match the semantic importance of the text in your content structure. - Accessibility: Use the
visuallyHiddenprop for text that should be accessible to screen readers but not visible on the screen, such as labels for form elements. - Consistency: Utilize predefined
toneandvariantprops to maintain consistent styling across your application.
Usage Guidelines
The Text component can be adapted through a combination of tone and variant properties, each tailored for different use cases:
Tones
default
The standard text style, suitable for general use.
<Text tone="default">Default Tone Text</Text>headline
Intended for headings and titles that require emphasis.
<Text tone="headline">Headline Text</Text>dark
Ideal for text that requires contrast, typically on light backgrounds.
<Text tone="dark">Dark Tone Text</Text>light
Best used on dark backgrounds to ensure readability.
<Text tone="light">Light Tone Text</Text>disabled
Use this tone for text elements that are disabled or inactive.
<Text tone="disabled">Disabled Text</Text>info
Use for informational messages or content.
<Text tone="info">Informational Text</Text>success
Indicates success, confirmation, or positive messages.
<Text tone="success">Success Text</Text>warning
Signifies caution or warning.
<Text tone="warning">Warning Text</Text>critical
Used for critical warnings or errors.
<Text tone="critical">Critical Text</Text>Variants
heading-lg
Large headings for significant screen sections.
<Text variant="heading-lg">Large Heading Text</Text>heading-md
Medium headings for sub-sections.
<Text variant="heading-md">Medium Heading Text</Text>body-md-strong
Bold medium body text.
<Text variant="body-md-strong">Bold Medium Body Text</Text>body-md
Standard body text, medium size.
<Text variant="body-md">Medium Body Text</Text>body-sm
Small text for less prominent information.
<Text variant="body-sm">Small Body Text</Text>Props
Optional HTML element type to render as.
Optional class name to apply to the text.
The text to display.
The HTML id attribute
Optional tone of the text.
Optional custom color to apply to the text.
Optional variant of the text.
Optional slot for use in composite components.
Optional boolean to visually hide the text.