Usage
Use Text component to display text and links with theme styles. Control Text styles with props:
Gradient variant
To use gradient as Text color:
- set
variant
togradient
- set
gradient
to{ from: 'color-from', to: 'color-to', deg: 135 }
, wherecolor-from
andcolor-to
are color fromtheme.colors
deg
is linear gradient deg
Truncate
Set truncate
prop to add text-overflow: ellipsis
styles:
Line clamp
Specify maximum number 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
Polymorphic component
Text is a polymorphic component, you can change root element:
span prop
Use span
prop as a shorthand for component="span"
:
Text component props
Name | Type | Description |
---|---|---|
align | "left" | "right" | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "center" | "end" | "start" | "justify" | "match-parent" | Sets text-align css property |
children | ReactNode | Text content |
color | DefaultMantineColor | "dimmed" | Key of theme.colors or any valid CSS color |
gradient | MantineGradient | Controls gradient settings in gradient variant only |
inherit | boolean | Inherit font properties from parent element |
inline | boolean | Sets line-height to 1 for centering |
italic | boolean | Adds font-style: italic style |
lineClamp | number | CSS -webkit-line-clamp property |
size | number | "xs" | "sm" | "md" | "lg" | "xl" | Key of theme.fontSizes or any valid CSS value to set font-size |
span | boolean | Shorthand for component="span" |
strikethrough | boolean | Add strikethrough styles |
transform | "-moz-initial" | "inherit" | "initial" | "revert" | "unset" | "none" | "capitalize" | "full-size-kana" | "full-width" | "lowercase" | "uppercase" | Sets text-transform css property |
truncate | true | "end" | "start" | CSS truncate overflowing text with an ellipsis |
underline | boolean | Underline the text |
variant | Variants<"text" | "gradient"> | Link or text variant |
weight | FontWeight | Sets font-weight css property |