import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import ActionableMessage from '../../ui/actionable-message';
import { Text } from './text';
# Text
> This Text (fka Typography) component has breaking changes in variant options and the line heights associated to each variant.
Good typography improves readability, legibility and hierarchy of information.
## Props
The `Text` accepts all props below as well as all [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props
### Variant
Use the `variant` prop and the `TEXT` object from `./ui/helpers/constants/design-system.js` to change the font size of the component.
Optional: `TEXT_VARIANTS` from ./text object can also be used.
```jsx
import { Text } from '../../ui/components/component-library';
import { TEXT } from '../../../helpers/constants/design-system';
display-mdheading-lgheading-mdheading-smbody-lg-mediumbody-mdbody-md-boldbody-smbody-sm-boldbody-xsinherit
```
### Color
Use the `color` prop and the `COLORS` object from `./ui/helpers/constants/design-system.js` to change the color of the `Text` component.
```jsx
import { Text } from '../../ui/components/component-library';
import { COLORS } from '../../../helpers/constants/design-system';
text-default
text-alternative
text-muted
overlay-inverse
primary-default
primary-inverse
error-default
error-inverse
success-default
success-inverse
warning-inverse
info-default
info-inverse
```
### Font Weight
Use the `fontWeight` prop and the `FONT_WEIGHT` object from `./ui/helpers/constants/design-system.js` to change the font weight of the `Text` component. There are 3 font weights:
- `FONT_WEIGHT.NORMAL` = `normal` || `400`
- `FONT_WEIGHT.MEDIUM` = `medium` || `500`
- `FONT_WEIGHT.BOLD` = `bold` || `700`
```jsx
import { Text } from '../../ui/components/component-library';
import { FONT_WEIGHT } from '../../../helpers/constants/design-system';
normal
medium
bold
```
### Font Style
Use the `fontStyle` prop and the `FONT_STYLE` object from `./ui/helpers/constants/design-system.js` to change the font style of the `Text` component. There are 2 font styles:
- `FONT_STYLE.NORMAL`
- `FONT_STYLE.ITALIC`
```jsx
import { Text } from '../../ui/components/component-library';
import { FONT_STYLE } from '../../../helpers/constants/design-system';
normal
bold
```
### Text Transform
Use the `textTransform` prop and the `TEXT_TRANSFORM` object from `./ui/helpers/constants/design-system.js` to change the text alignment of the `Text` component
```jsx
import { Text } from '../../ui/components/component-library';
import { TEXT_TRANSFORM } from '../../../helpers/constants/design-system';
uppercase
lowercase
capitalize
```
### Text Align
Use the `textAlign` prop and the `TEXT_ALIGN` object from `./ui/helpers/constants/design-system.js` to change the text alignment of the `Text` component
```jsx
import { Text } from '../../ui/components/component-library';
import { TEXT_ALIGN } from '../../../helpers/constants/design-system';
left
center
right
justify
end
```
### Overflow Wrap
Use the `overflowWrap` prop and the `OVERFLOW_WRAP` object from `./ui/helpers/constants/design-system.js` to change the overflow wrap of the `Text` component
```jsx
import { Text } from '../../ui/components/component-library';
import { OVERFLOW_WRAP } from '../../../helpers/constants/design-system';
;
```
### Ellipsis
Use the boolean `ellipsis` prop to change the if the `Text` component to have an ellipsis.
```jsx
import { Text } from '../../ui/components/component-library';
;
```
### As
Use the `as` prop to change the root html element of the `Text` component
```jsx
import { Text } from '../../ui/components/component-library';
dddivdtemh1h2h3h4h5h6lipspanstrong
```
Renders the html:
```html
dd
div
dt
em
h1
h2
h3
h4
h5
h6
li
p
spanstrong
```
### Text Direction
Use the `textDirection` prop and the `TEXT_DIRECTIONS` object from `./text.constants.js` to change the text direction of `Text`
```jsx
import { Text, TEXT_DIRECTIONS } from '../../ui/components/component-library';
This is left to right (ltr) for English and most languages
This is right to left (rtl) for use with other laguanges such as Arabic. This Enlgish example is incorrect usage.
Let the user agent decide with the auto option
```
### Box Props
Use any valid box props [Box](/?path=/story/ui-components-ui-box-box-stories-js--default-story) component props to the Text component.
### Class Name
Adds an additional class to the `Text` component
### Children
The text content of the `Text` component