mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
23b412c13f
* Adding global index.js file * Removing style prop from button base * Fixing comment on generate-icon-names.js file * Re-ordering sass imports to atomic structure * Updating component paths code examples of MDX docs
96 lines
2.7 KiB
Plaintext
96 lines
2.7 KiB
Plaintext
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
|
|
|
|
import { Label } from './label';
|
|
|
|
# Label
|
|
|
|
The `Label` is a component used to label form inputs.
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-label-label-stories-js--default-story" />
|
|
</Canvas>
|
|
|
|
## Props
|
|
|
|
The `Label` accepts all props below as well as all [Text](/docs/ui-components-component-library-text-text-stories-js--default-story#props) and [Box](/docs/ui-components-ui-box-box-stories-js--default-story#props) component props.
|
|
|
|
<ArgsTable of={Label} />
|
|
|
|
### Children
|
|
|
|
The `children` of the label can be text or a react node.
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-label-label-stories-js--children" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { DISPLAY, ALIGN_ITEMS, FLEX_DIRECTION, SIZES, COLORS } from '../../../helpers/constants/design-system';
|
|
import { Icon, ICON_NAMES } from '../../ui/components/component-library';
|
|
import { Label } from '../../ui/components/component-library';
|
|
import { TextFieldBase } from '../../ui/components/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_FILLED}
|
|
size={SIZES.AUTO}
|
|
/>
|
|
</Label>
|
|
<Label
|
|
display={DISPLAY.INLINE_FLEX}
|
|
flexDirection={FLEX_DIRECTION.COLUMN}
|
|
alignItems={ALIGN_ITEMS.FLEX_START}
|
|
>
|
|
Label that wraps an input
|
|
{/* TODO: replace with TextField component */}
|
|
<TextFieldBase 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="ui-components-component-library-label-label-stories-js--html-for" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { TextFieldBase } from '../../ui/components/component-library';
|
|
import { Label } from '../../ui/components/component-library';
|
|
|
|
<Label htmlFor="add-network">Add network</Label>
|
|
<TextFieldBase 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="ui-components-component-library-label-label-stories-js--required" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { Label } from '../../ui/components/component-library';
|
|
|
|
<Label required>Label</Label>;
|
|
```
|
|
|
|
### Disabled
|
|
|
|
Use the `disabled` prop to set the `Label` in disabled state
|
|
|
|
<Canvas>
|
|
<Story id="ui-components-component-library-label-label-stories-js--disabled" />
|
|
</Canvas>
|
|
|
|
```jsx
|
|
import { Label } from '../../ui/components/component-library';
|
|
|
|
<Label disabled>Label</Label>;
|
|
```
|