Text
Usage
Use Text component to display text and links with theme styles. Control Text styles with props:
- size – font-size from
theme.fontSizes– xs, sm, md, lg, xl - color – color from
theme.colors– red, green, blue, etc. - weight – font-weight property – 500, 700, bold, semibold, etc.
- underline - underline text
- transform – text-transform property – uppercase, lowercase, capitalize
- align – text-align property
- variant – text or link predefined styles
Dimmed
Text supports special dimmed value in color prop. It sets color to theme.colors.dark[2] in dark theme and to theme.colors.gray[6] in light:
Gradient variant
To use gradient as Text color:
- set
varianttogradient - set
gradientto{ from: 'color-from', to: 'color-to', deg: 135 }, wherecolor-fromandcolor-toare color fromtheme.colorsdegis linear gradient deg
Line clamp
Specify maximum amount of lines with lineClamp prop. This option uses -webkit-line-clamp
CSS property (caniuse). Note that padding-bottom cannot be set on text element:
Line clamp can also be used with any children (not only strings), for example with TypographyStylesProvider:
Line clamp with TypographyStylesProvider
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nesciunt nulla quam aut sed corporis voluptates praesentium inventore, sapiente ex tempore sit consequatur debitis non! Illo cum ipsa reiciendis quidem facere, deserunt eos totam impedit. Vel ab, ipsum veniam aperiam odit molestiae incidunt minus, sint eos iusto earum quaerat vitae perspiciatis.
Inherit styles
Text always applies font-size, font-family and line-height styles,
but in some cases this is not a desired behavior. To force Text to inherit parent
styles set inherit prop. For example, highlight part of Title:
Title in which you want to highlight something
Custom component
By default, text is rendered as div element, to change it by set component prop: