Choose a single option from a dropdown list.
import { Select } from '@fluxui-dev/react';<Select name="industry" placeholder="Choose industry..."> <Select.Option>Photography</Select.Option> <Select.Option>Design services</Select.Option> <Select.Option>Web development</Select.Option> <Select.Option>Accounting</Select.Option> <Select.Option>Legal services</Select.Option> <Select.Option>Consulting</Select.Option> <Select.Option>Other</Select.Option></Select>
A smaller select element for more compact layouts.
<Select size="sm" placeholder="Choose industry..."> <Select.Option>Photography</Select.Option> <Select.Option>Design services</Select.Option> <Select.Option>Web development</Select.Option> <Select.Option>Accounting</Select.Option> <Select.Option>Legal services</Select.Option> <Select.Option>Consulting</Select.Option> <Select.Option>Other</Select.Option></Select>
Organize related options into labeled groups to make longer lists easier to scan.
<Select name="industry" placeholder="Choose an industry..."> <Select.Group label="Creative"> <Select.Option value="photography">Photography</Select.Option> <Select.Option value="design">Design services</Select.Option> </Select.Group> <Select.Group label="Technology"> <Select.Option value="web-development">Web development</Select.Option> <Select.Option value="it-consulting">IT consulting</Select.Option> </Select.Group> <Select.Group label="Services"> <Select.Option value="accounting">Accounting</Select.Option> <Select.Option value="legal">Legal services</Select.Option> <Select.Option value="consulting">Consulting</Select.Option> </Select.Group></Select>
|
Prop
|
Description
|
|---|---|
| name |
Name submitted with the form, also used to look up the select's validation error.
|
| placeholder |
Text displayed when no option is selected.
|
| label |
Label text displayed above the select. When provided, wraps the select in a Field component with an adjacent Field.Label component. See the field component.
|
| description |
Help text displayed above the select. When provided alongside label, appears between the label and select within the Field wrapper. See the field component.
|
| descriptionTrailing |
The description provided will be displayed below the select instead of above it.
|
| badge |
Badge text displayed at the end of the Field.Label component when the label prop is provided.
|
| error |
Error message displayed below the select that marks it invalid, defaulting to the validation error for its name.
|
| value |
Controlled value of the selected option, paired with onValueChange.
|
| defaultValue |
Value of the option selected initially when uncontrolled.
|
| onValueChange |
Callback fired with the selected option's value when the selection changes.
|
| size |
Size of the select. Options: base (default), sm, xs. A number sets the native size attribute.
|
| disabled |
Prevents user interaction with the select.
|
| invalid |
Applies error styling to the select.
|
| className |
CSS classes applied directly to the select element rather than the wrapping field, even when label is set.
|
|
Slot
|
Description
|
|---|---|
| children |
The select options.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-select |
Applied to the select element for styling and identification.
|
|
Prop
|
Description
|
|---|---|
| value |
Value associated with the option. Defaults to the option's text.
|
| disabled |
Prevents selecting the option.
|
|
Slot
|
Description
|
|---|---|
| children |
The option's text.
|
|
Prop
|
Description
|
|---|---|
| label |
Label displayed above the grouped options. Required.
|
| disabled |
Prevents selecting any option in the group.
|
|
Slot
|
Description
|
|---|---|
| children |
The options contained in the group.
|