Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
Select input component#1736
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.
Select input component #1736
Changes from all commits
520a056917423cffa21833bcebcb0f77d9d16b5f6abc06aba73799509b81e508fe1d2073292865303d0d95c3be8ccc3d8cfde3e7688a65c95ccc2f25cc98676e4df1a6a041069ff8321a90a58dc6eb7108b659c796909d7e7c5d91ee76cb34b84d8d003e35386ab77877832b4fa45ce6File 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 a component for a native select input |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| componentId: select | ||
| title: Select | ||
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'm thinking maybe "SelectInput" is a better name. I'd love to hear what other reviewers think. 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. Yep! I think so too. It kinda cements it as a Form component and not any fancy menu/overlay interface 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. We only recently decided to avoid using | ||
| description: Use a select input when a user needs to select one option from a long list | ||
| status: Alpha | ||
| source: https://github.com/primer/react/blob/main/src/Select.tsx | ||
| storybook: '/react/storybook?path=/story/forms-select--default' | ||
| --- | ||
| import {Select, Text} from '@primer/react' | ||
| ## Examples | ||
| ### Basic | ||
| ```jsx live | ||
| <> | ||
| <Text fontWeight="bold" fontSize={1} as="label" display="block" htmlFor="basic"> | ||
| Preferred Primer component interface | ||
| </Text> | ||
| <Select id="basic"> | ||
| <Select.Option value="figma">Figma</Select.Option> | ||
| <Select.Option value="css">Primer CSS</Select.Option> | ||
| <Select.Option value="prc">Primer React components</Select.Option> | ||
| <Select.Option value="pvc">Primer ViewComponents</Select.Option> | ||
| </Select> | ||
| </> | ||
| ``` | ||
| ### With grouped options | ||
| ```jsx live | ||
| <> | ||
| <Text fontWeight="bold" fontSize={1} as="label" display="block" htmlFor="grouped"> | ||
| Preferred Primer component interface | ||
| </Text> | ||
| <Select id="grouped"> | ||
| <Select.OptGroup label="GUI"> | ||
| <Select.Option value="figma">Figma</Select.Option> | ||
| </Select.OptGroup> | ||
| <Select.OptGroup label="Code"> | ||
| <Select.Option value="css">Primer CSS</Select.Option> | ||
| <Select.Option value="prc">Primer React components</Select.Option> | ||
| <Select.Option value="pvc">Primer ViewComponents</Select.Option> | ||
| </Select.OptGroup> | ||
| </Select> | ||
| </> | ||
| ``` | ||
| ### With a placeholder | ||
| ```jsx live | ||
| <> | ||
| <Text fontWeight="bold" fontSize={1} as="label" display="block" htmlFor="withPlaceholder"> | ||
| Preferred Primer component interface | ||
| </Text> | ||
| <Select id="withPlaceholder" placeholder="Pick an interface"> | ||
| <Select.Option value="figma">Figma</Select.Option> | ||
| <Select.Option value="css">Primer CSS</Select.Option> | ||
| <Select.Option value="prc">Primer React components</Select.Option> | ||
| <Select.Option value="pvc">Primer ViewComponents</Select.Option> | ||
| </Select> | ||
| </> | ||
| ``` | ||
| ## Props | ||
| ### Select | ||
| <PropsTable> | ||
| <PropsTableRow | ||
| name="block" | ||
| type="boolean" | ||
| defaultValue="false" | ||
| description={<>Creates a full width input element</>} | ||
| /> | ||
| <PropsTableRow | ||
| name="contrast" | ||
| type="boolean" | ||
| defaultValue="false" | ||
| description="Changes background color to a higher contrast color" | ||
| /> | ||
| <PropsTableRow | ||
| name="size" | ||
| type="'small' | 'medium' | 'large'" | ||
| description="Creates a smaller or larger input than the default." | ||
| /> | ||
| <PropsTableRow name="validationStatus" type="'warning' | 'error'" description="Style the input to match the status" /> | ||
| <PropsTablePassthroughPropsRow | ||
| elementName="select" | ||
| passthroughPropsLink={ | ||
| <Link href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attributes">MDN</Link> | ||
| } | ||
| /> | ||
| </PropsTable> | ||
| ### Select.OptGroup | ||
| The `Select.OptGroup` component accepts the same props as a native HTML [`<optgroup>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup). | ||
| ### Select.Option | ||
| The `Select.Option` component accepts the same props as a native HTML [`<option>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option). | ||
| ## Status | ||
| <ComponentChecklist | ||
| items={{ | ||
| propsDocumented: true, | ||
| noUnnecessaryDeps: true, | ||
| adaptsToThemes: true, | ||
| adaptsToScreenSizes: true, | ||
| fullTestCoverage: true, | ||
| usedInProduction: false, | ||
| usageExamplesDocumented: true, | ||
| hasStorybookStories: true, | ||
| designReviewed: false, | ||
| a11yReviewed: false, | ||
| stableApi: false, | ||
| addressedApiFeedback: false, | ||
| hasDesignGuidelines: false, | ||
| hasFigmaComponent: false | ||
| }} | ||
| /> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selectwasn't added tonav.ymland is therefore not present in the sidebar menu. Was this intentional @mperrotti? You can only find this doc page via the search atm.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not intentional. Adding now...