diff --git a/.changeset/sharp-cats-return.md b/.changeset/sharp-cats-return.md new file mode 100644 index 00000000000..e11de057fb3 --- /dev/null +++ b/.changeset/sharp-cats-return.md @@ -0,0 +1,5 @@ +--- +'@primer/react': minor +--- + +Introduces FormControl component. The FormControl component combines the functionality of InputField and ChoiceInputField, and will replace FormGroup, InputField, and ChoiceInputField. diff --git a/docs/content/ChoiceInputField.mdx b/docs/content/ChoiceInputField.mdx index 272fcef9b3c..fee25034321 100644 --- a/docs/content/ChoiceInputField.mdx +++ b/docs/content/ChoiceInputField.mdx @@ -1,7 +1,7 @@ --- componentId: choiceInputField title: ChoiceInputField -status: Alpha +status: Deprecated description: The ChoiceInputField component is used to render a labelled checkbox or radio inputs with optional hint text. source: https://github.com/primer/react/blob/main/src/ChoiceInputField.tsx storybook: '/react/storybook?path=/story/forms-choiceinputfield--checkbox-input-field' @@ -12,6 +12,10 @@ import {MarkGithubIcon} from '@primer/octicons-react' import {PropsTable} from '../src/props-table' import {ComponentChecklist} from '../src/component-checklist' +## Deprecation + +Use [FormControl](/FormControl) instead. + ## Examples ### Checkbox diff --git a/docs/content/FormControl.mdx b/docs/content/FormControl.mdx new file mode 100644 index 00000000000..3ca1e7ef097 --- /dev/null +++ b/docs/content/FormControl.mdx @@ -0,0 +1,356 @@ +--- +componentId: form_control +title: FormControl +status: Alpha +description: The FormControl component is used to render a labelled text input and, optionally, associated validation text and hint text. +source: https://github.com/primer/react/blob/main/src/FormControl/FormControl.tsx +storybook: '/react/storybook?path=/story/forms-inputfield--text-input-field' +--- + +import {FormControl, TextInputWithTokens, Autocomplete, Select, Textarea, Checkbox, Radio, Text} from '@primer/react' +import {MarkGithubIcon} from '@primer/octicons-react' + +## Examples + +### Basic + +```jsx live + + Name + + +``` + +### With complex inputs + +```javascript live noinline +const DifferentInputs = () => { + const [tokens, setTokens] = React.useState([ + {text: 'zero', id: 0}, + {text: 'one', id: 1}, + {text: 'two', id: 2} + ]) + const onTokenRemove = tokenId => { + setTokens(tokens.filter(token => token.id !== tokenId)) + } + + return ( + + + TextInputWithTokens + + + + Autocomplete + + + + + + + + + Select + + + + Textarea +