1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/ui/form-field
George Marshall 739075662c
Migrating Icon to typescript and deprecating JS component (#18431)
* Migrating Icon to typescript and deprecating JS component

* gw suggestions (#18434)

---------

Co-authored-by: Garrett Bear <gwhisten@gmail.com>
2023-04-04 09:48:04 -07:00
..
form-field.js UX Icon: updated fas-question icon (#17828) 2023-02-22 16:45:07 -06:00
form-field.stories.js Migrating Icon to typescript and deprecating JS component (#18431) 2023-04-04 09:48:04 -07:00
index.js Add form-field component and new account view (#11450) 2021-07-06 17:19:11 -05:00
index.scss UX Icon: updated fas-question icon (#17828) 2023-02-22 16:45:07 -06:00
README.mdx Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30

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

import FormField from '.';

# Form Field

Various data fields available for forms and pages.

<Canvas>
  <Story id="components-ui-formfield--default-story" />
</Canvas>

## Props

<ArgsTable of={FormField} />

### Title detail

Show form fields with title detail on the left of the title

<Canvas>
  <Story id="components-ui-formfield--form-field-with-title-detail" />
</Canvas>

### Error

Show form fields with error state

<Canvas>
  <Story id="components-ui-formfield--form-field-with-error" />
</Canvas>

### Custom Components

Use the custom component props `TitleTextCustomComponent`, `TitleUnitCustomComponent` and `TooltipCustomComponent` to replace the default components.
If these props exists they will replace their respective text props. The FormField is wrapped in a Box component that renders as a `<label />` element.
To change the element type, use the `wrappingLabelProps` and polymorphic `as` prop. e.g `wrappingLabelProps={{ as: 'div' }}`. Make sure to provide your own `<label />` element combined with the `id` prop and `htmlFor` to ensure accessibility

<Canvas>
  <Story id="components-ui-formfield--custom-components" />
</Canvas>