Select

Display a dropdown list of items.

The Select contain an additional Hooks, see subsection useModal for details.

General

Basic usage.

Choose one
Code Editor

Type

Differentiate states by color.

Default
Option 1
Option 2
Option 1
Code Editor

Disabled

Disable all options.

Choose one
Code Editor

Disabled Option

disable specified options.

Choose one
Code Editor

Without Icon

Hide icon on right.

Choose one
Code Editor

Labels

show data as a group.

Frameworks
Code Editor

Divider

Frameworks
Code Editor

Multiple

Select supports multiple values to be selected.

React
Vue
Rails
Express
Code Editor

Multiple without clear

Select supports multiple values to be selected without the clear icon.

React
Vue
Rails
Express
Code Editor

Compose

Use with other components.

TypeScript
Code Editor

Over width

Option to show more text with adaptive width.

Truncate an overly long string
Autoscale option width when text is too long
Code Editor

Set parent element

you can specify the container for drop-down box rendering.

Code Editor

APIs

Select.Props

AttributeDescriptionTypeAccepted valuesDefault
valueselected valuestring, string[]--
initialValueinitial valuestring, string[]--
placeholderplaceholder stringstring--
widthcss width value of selectstring-initial
typecurrent typeSelectTypesSelectTypesdefault
iconicon componentComponentType-SVG Component
pureremove icon componentboolean-false
multiplesupport multiple selectionboolean-false
clearableadd clear icon on multiple selection (ignored otherwise)boolean-true
disableddisable current radioboolean-false
onChangeselected value(val: string | string[]) => void --
dropdownClassNameclassName of dropdown menustring--
dropdownStylestyle of dropdown menuobject--
disableMatchWidthdisable Option from follow Select widthboolean-false
getPopupContainerdropdown render parent element, the default is body() => HTMLElement--
onDropdownVisibleChangedropdown change events(visible: boolean) => void--
refforwardRefSelectRefSelectRef-
...native propsHTMLAttributes'name', 'alt', ...-

Select.Option.Props

AttributeDescriptionTypeAccepted valuesDefault
value(required)unique ident valuestring--
disableddisable current optionboolean-false
dividerdisplay a lineboolean-false
labeldisplay a group titleboolean-false
...native propsHTMLAttributes'name', 'id', ...-

SelectRef

type SelectRef = {
  focus: () => void
  blur: () => void
  scrollTo?: (options?: ScrollToOptions) => void
}

SelectTypes

type SelectTypes = 'default' | 'secondary' | 'success' | 'warning' | 'error'

Geist is an open source project from the community.

And is powered by Netlify.