1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 02:10:12 +01:00
metamask-extension/ui/components/component-library/help-text
Garrett Bear 30520a3352
button link housekeeping (#16885)
* button link housekeeping

Co-authored-by: George Marshall <george.marshall@consensys.net>
Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
2023-01-26 10:32:11 -08:00
..
__snapshots__ Feat/16187/text housekeeping (#16589) 2022-12-01 09:26:19 -08:00
help-text.js HelpText house keeping updates (#16681) 2022-11-29 13:00:51 -08:00
help-text.stories.js button link housekeeping (#16885) 2023-01-26 10:32:11 -08:00
help-text.test.js icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
index.js Adding HelpText component (#16293) 2022-11-03 10:09:09 -07:00
README.mdx button link housekeeping (#16885) 2023-01-26 10:32:11 -08:00

import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';

import { Text } from '..';

import { HelpText } from './help-text';

# HelpText

The `HelpText` is intended to be used as the help or error text under a form element

<Canvas>
  <Story id="components-componentlibrary-helptext--default-story" />
</Canvas>

## Props

The `HelpText` accepts all props below as well as all [Box](/docs/components-ui-box--default-story#props) component props

<ArgsTable of={HelpText} />

`HelpText` accepts all [Text](/docs/components-componentlibrary-text--default-story#props) component props

<ArgsTable of={Text} />

### Children

The `children` of the `HelpText` can be plain text or react nodes

<Canvas>
  <Story id="components-componentlibrary-helptext--children" />
</Canvas>

```jsx
import { SIZES, COLORS } from '../../../helpers/constants/design-system';
import { HelpText, Icon, ICON_NAMES } from '../../component-library';

<HelpText>Plain text</HelpText>
<HelpText>
  Text and icon
  <Icon
    marginLeft={1}
    color={COLORS.INHERIT}
    name={ICON_NAMES.WARNING}
    size={SIZES.INHERIT}
  />
</HelpText>
```

### Error

Use the `error` prop to show the `HelpText` in error state

<Canvas>
  <Story id="components-componentlibrary-helptext--error-story" />
</Canvas>

```jsx
import { HelpText } from '../../component-library';

<HelpText error>This HelpText in error state</HelpText>;
```

### Color

It may be useful to change the color of the `HelpText`. Use the `color` prop and the `COLORS` object to change the color of the `HelpText`. Defaults to `COLORS.TEXT_DEFAULT`.

<Canvas>
  <Story id="components-componentlibrary-helptext--color" />
</Canvas>

```jsx
import { COLORS } from '../../../helpers/constants/design-system';
import { HelpText } from '../../component-library';

<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.COLUMN} gap={2}>
  <HelpText color={COLORS.TEXT_DEFAULT}>
    The HelpText default color is COLORS.TEXT_DEFAULT
  </HelpText>
  <HelpText color={COLORS.INFO_DEFAULT}>
    This HelpText color is COLORS.INFO_DEFAULT
  </HelpText>
  <HelpText color={COLORS.WARNING_DEFAULT}>
    This HelpText color is COLORS.WARNING_DEFAULT
  </HelpText>
  <HelpText color={COLORS.SUCCESS_DEFAULT}>
    This HelpText color is COLORS.SUCCESS_DEFAULT
  </HelpText>
</Box>;
```