Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Input field components - text, checkbox, radio#1611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a23e32d779e5fe0ad2715f8668cee0addd00d3ae10a67c80ffe9696add088286054f1c910ee6800ecaba115bb4efc84152f70f8ad793c00de50bde8e9bcee94533f20ad1c9e8024b5d3006e97679c2286581b4ca54b43a47b7c1f80a220ad6ea5201504a9d9d721895e5a964f15da266cbab1aeec1312ab0927296577aa8742444069334dc2691adc4b20f1ab137a073c183634e06ca7a179e9273285ba98a67e8b6781f4ff79a52f4ff5c858efa2bc6c2062e3f7a6ee283cbe05f96ddc1c4808ce49a846a7bb7512d8047fd269bf73ad10c5c56710b42dc3903156ef00f5ff250a7f81398e541d6d3f03c17ec66a450bb87e6da8a4d0406615bf95c709d5a9ad9e954File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@primer/react': minor | ||
| --- | ||
| Adds TextInputField, CheckboxInputField, and RadioInputField components. Also adds a few internal (private to primer/react) components to support form fields |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,161 @@ | ||
| --- | ||
| componentId: choiceInputField | ||
| title: ChoiceInputField | ||
| status: Alpha | ||
| 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' | ||
| --- | ||
| import {ChoiceInputField, Checkbox, Radio} from '@primer/react' | ||
| import {MarkGithubIcon} from '@primer/octicons-react' | ||
| import {PropsTable} from '../src/props-table' | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these imports may not be needed anymore ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll see what I can get rid of. When I excluded the | ||
| import {ComponentChecklist} from '../src/component-checklist' | ||
| ## Examples | ||
| ### Checkbox | ||
| ```jsx live | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option one</ChoiceInputField.Label> | ||
| <Checkbox /> | ||
| </ChoiceInputField> | ||
| ``` | ||
| ### Radio | ||
| ```jsx live | ||
| <fieldset style={{margin: 0, padding: 0, border: 0}}> | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option one</ChoiceInputField.Label> | ||
| <Radio name="radioExample" value="one" /> | ||
| </ChoiceInputField> | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option two</ChoiceInputField.Label> | ||
| <Radio name="radioExample" value="two" /> | ||
| </ChoiceInputField> | ||
| </fieldset> | ||
| ``` | ||
| ### Disabled field | ||
| ```jsx live | ||
| <ChoiceInputField disabled> | ||
| <ChoiceInputField.Label>Option one</ChoiceInputField.Label> | ||
| <Checkbox /> | ||
| </ChoiceInputField> | ||
| ``` | ||
| ### With a caption | ||
| ```jsx live | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option One</ChoiceInputField.Label> | ||
| <Checkbox /> | ||
| <ChoiceInputField.Caption>Hint: the first and only option</ChoiceInputField.Caption> | ||
| </ChoiceInputField> | ||
| ``` | ||
| ### With a LeadingVisual | ||
| ```jsx live | ||
| <> | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option one</ChoiceInputField.Label> | ||
| <ChoiceInputField.LeadingVisual> | ||
| <MarkGithubIcon /> | ||
| </ChoiceInputField.LeadingVisual> | ||
| <Checkbox /> | ||
| </ChoiceInputField> | ||
| <ChoiceInputField> | ||
| <ChoiceInputField.Label>Option two</ChoiceInputField.Label> | ||
| <ChoiceInputField.LeadingVisual> | ||
| <MarkGithubIcon /> | ||
| </ChoiceInputField.LeadingVisual> | ||
| <Checkbox /> | ||
| <ChoiceInputField.Caption>This one has a caption</ChoiceInputField.Caption> | ||
| </ChoiceInputField> | ||
| </> | ||
| ``` | ||
| ## Props | ||
| ### ChoiceInputField | ||
| The container that handles the layout and passes the relevant IDs and ARIA attributes it's children. | ||
| `ChoiceInputField.Label` and `ChoiceInputField.Input` are required children. | ||
| <PropsTable> | ||
| <PropsTable.Row | ||
| name="children" | ||
| type="ChoiceInputField.Label | ChoiceInputField.Caption | ChoiceInputField.LeadingVisual | Checkbox | Radio" | ||
| required | ||
| /> | ||
| <PropsTable.Row | ||
| name="disabled" | ||
| type="boolean" | ||
| defaultValue="false" | ||
| description="Whether the field is ready for user input" | ||
| /> | ||
| <PropsTable.Row | ||
| name="id" | ||
| type="string" | ||
| defaultValue="a generated string" | ||
| description="The unique identifier for this field. Used to associate the label, validation text, and caption text" | ||
| /> | ||
| </PropsTable> | ||
| ### ChoiceInputField.Label | ||
| A `ChoiceInputField.Label` must be passed, but it may be visually hidden. | ||
| <PropsTable> | ||
| <PropsTable.Row name="children" type="React.ReactNode" description="The title that describes the choice input" /> | ||
| </PropsTable> | ||
| ### ChoiceInputField.Caption | ||
| If this field needs additional context, a `ChoiceInputField.Caption` may be used to render hint text. | ||
| <PropsTable> | ||
| <PropsTable.Row | ||
| name="children" | ||
| type="React.ReactNode" | ||
| description="The content (usually just text) that is rendered to give contextual info about the field" | ||
| /> | ||
| </PropsTable> | ||
| ### ChoiceInputField.LeadingVisual | ||
| If the selectable option would be easier to understand with a visual, the `ChoiceInputField.LeadingVisual` component may be used. | ||
| <PropsTable> | ||
| <PropsTable.Row | ||
| name="children" | ||
| type="React.ReactNode" | ||
| description="The visual to render before the choice input's label" | ||
| /> | ||
| </PropsTable> | ||
| ## Status | ||
| <ComponentChecklist | ||
| items={{ | ||
| propsDocumented: true, | ||
| noUnnecessaryDeps: true, | ||
| adaptsToThemes: true, | ||
| adaptsToScreenSizes: true, | ||
| fullTestCoverage: true, | ||
| usedInProduction: false, | ||
| usageExamplesDocumented: true, | ||
| designReviewed: false, | ||
| a11yReviewed: true, | ||
| stableApi: false, | ||
| addressedApiFeedback: false, | ||
| hasDesignGuidelines: false, | ||
| hasFigmaComponent: false | ||
| }} | ||
| /> | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.