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-md heading-lg heading-md heading-sm body-lg-medium body-md body-md-bold body-sm body-sm-bold body-xs inherit ``` ### 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';
{OVERFLOW_WRAP.NORMAL}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d {OVERFLOW_WRAP.BREAK_WORD}: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d
; ``` ### 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';
Ellipsis: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d No Ellipsis: 0x39013f961c378f02c2b82a6e1d31e9812786fd9d
; ``` ### As Use the `as` prop to change the root html element of the `Text` component ```jsx import { Text } from '../../ui/components/component-library'; dd div dt em h1 h2 h3 h4 h5 h6 li p span strong ``` Renders the html: ```html
dd
div
dt
em

h1

h2

h3

h4

h5
h6
  • li
  • p

    span strong ``` ### 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