Select
Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
API Reference
Root
Contains all the parts of a select. It inherits props from the Select primitive Root part.
Trigger
The button that toggles the select. This component inherits props from the Select primitive Trigger and Value parts. It supports common margin props.
Content
The component that pops out when the select is open. It inherits props from the Select.Portal primitive and Select.Content primitive parts.
Item
The component that contains the select items. It inherits props from the Select.Item primitive part.
Group
Used to group multiple items. It inherits props from the Select.Group primitive part. Use in conjunction with Select.Label to ensure good accessibility via automatic labelling.
Label
Used to render the label of a group, it isn't focusable using arrow keys. It inherits props from the Select.Label primitive part.
Separator
Used to visually separate items in the Select. It inherits props from the Select.Separator primitive part.
Examples
Size
Use the size prop to control the size.
Variant
Use the variant prop on Trigger and Content to customize the visual style.
Ghost
Use the ghost trigger variant to render the trigger without a visually containing element. Ghost triggers behave differently in layout as they use a negative margin to optically align themselves against their siblings while maintaining their padded active and hover states.
Color
Use the color prop on Trigger and Content to assign a specific color value.
High-contrast
Use the highContrast prop on Content to increase item contrast.
Radius
Use the radius prop to assign a specific radius value.
Placeholder
Use the placeholder prop to create a Trigger that doesn’t need an initial value.
Position
Set position="popper" prop to position the select menu below the trigger.
With SSR
When using server-side rendering, you might notice a layout shift after hydration. This is because Trigger executes client-side code to display the selected item’s text. To avoid that layout shift, you can render it manually by mapping values.
With an icon
You can customise how Trigger renders the value by controlling its children manually. For example, you can render an icon next to the selected item’s text.