-
Notifications
You must be signed in to change notification settings - Fork 536
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
Select input component #1736
Select input component #1736
Changes from all commits
520a056
917423c
ffa2183
3bcebcb
0f77d9d
16b5f6a
bc06aba
7379950
9b81e50
8fe1d20
7329286
5303d0d
95c3be8
ccc3d8c
fde3e76
88a65c9
5ccc2f2
5cc9867
6e4df1a
6a04106
9ff8321
a90a58d
c6eb710
8b659c7
96909d7
e7c5d91
ee76cb3
4b84d8d
003e353
86ab778
77832b4
fa45ce6
File filter
Filter by extension
Conversations
Jump to
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 | ||
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. 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 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 | ||
}} | ||
/> |
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.
Select
wasn't added tonav.yml
and 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...