1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/component-library/label
Garrett Bear 0bf6aeb5f5
icon audit, remove xxs icon size (#17089)
* icon audit, remove xxs icon size

* update icon file names and snapshots

* remove unused icon- code and fix icons with slash issue

* close icon fix

* remove icons id

* update snapshot

* font awesome icon list

* remove font awesome

* fix linting issue
2023-01-24 09:39:46 -08:00
..
__snapshots__ Feat/16187/text housekeeping (#16589) 2022-12-01 09:26:19 -08:00
index.js Adding Label component (#16203) 2022-11-03 10:09:54 -07:00
label.js Label house keeping updates (#16680) 2022-11-29 13:01:05 -08:00
label.scss Adding Label component (#16203) 2022-11-03 10:09:54 -07:00
label.stories.js icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
label.test.js icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00
README.mdx icon audit, remove xxs icon size (#17089) 2023-01-24 09:39:46 -08:00

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

import { Text } from '..';

import { Label } from './label';

# Label

The `Label` is a component used to label form inputs

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

## Props

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

<ArgsTable of={Label} />

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

<ArgsTable of={Text} />

### Children

The `children` of the label can be text or a react node

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

```jsx
import { DISPLAY, ALIGN_ITEMS, FLEX_DIRECTION, SIZES, COLORS } from '../../../helpers/constants/design-system';
import { Label, TextField, Icon, ICON_NAMES } from '../../component-library';

<Label>Plain text</Label>
<Label display={DISPLAY.FLEX} alignItems={ALIGN_ITEMS.FLEX_START}>
  Text and icon
  <Icon
    color={COLORS.ICON_ALTERNATIVE}
    name={ICON_NAMES.INFO}
    size={SIZES.AUTO}
  />
</Label>
<Label
  display={DISPLAY.INLINE_FLEX}
  flexDirection={FLEX_DIRECTION.COLUMN}
  alignItems={ALIGN_ITEMS.FLEX_START}
>
  Label that wraps an input
  <TextField placeholder="Click label to focus" />
</Label>
```

### Html For

Use the `htmlFor` prop to allow the `Label` to focus on an input with the same id when clicked. The cursor will also change to a `pointer` when the `htmlFor` has a value.

<Canvas>
  <Story id="components-componentlibrary-label--html-for" />
</Canvas>

```jsx
import { Label, TextFieldBase } from '../../component-library';

<Label htmlFor="add-network">Add network</Label>
<TextField id="add-network" placeholder="Enter network name" />
```

### Required

Use the `required` prop to add a required red asterisk next to the `children` of the `Label`. Note the required asterisk will always render after the `children`.

<Canvas>
  <Story id="components-componentlibrary-label--required" />
</Canvas>

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

<Label required>Label</Label>;
```

### Disabled

Use the `disabled` prop to set the `Label` in disabled state

<Canvas>
  <Story id="components-componentlibrary-label--disabled" />
</Canvas>

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

<Label disabled>Label</Label>;
```