<ResponsiveSelect.Root value={value} onValueChange={setValue}>
<ResponsiveSelect.Trigger>
<ResponsiveSelect.Value placeholder="Select a specialty" />
</ResponsiveSelect.Trigger>
<ResponsiveSelect.Content>
<ResponsiveSelect.Item value="designer">Designer</ResponsiveSelect.Item>
</ResponsiveSelect.Content>
</ResponsiveSelect.Root>One declaration drives both surfaces, switching at 768px. Narrow the window on the preview to get the native picker.
API
ResponsiveSelect.Root
| Prop | Type | Default | |
|---|---|---|---|
children | ReactNode | — | |
defaultValue | string | — | |
disabled | boolean | — | |
name | string | — | Submitted under this name (hidden input on desktop, the <select> on mobile). |
onValueChange | ((value: string) => void) | — | |
required | boolean | — | |
value | string | — |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-root.tsx.
ResponsiveSelect.Content
| Prop | Type | Default | |
|---|---|---|---|
align | Align | — | How to align the popup relative to the specified side. |
alignItemWithTrigger | boolean | — | Whether the positioner overlaps the trigger so the selected item's text is aligned with the trigger's value text. This only applies to mouse input and is automatically disabled if there is not enough space. |
alignOffset | number | OffsetFunction | — | Additional offset along the alignment axis in pixels.
Also accepts a function that returns the offset to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: |
children | ReactNode | — | |
className | string | ((state: SelectPopupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
collisionPadding | Padding | — | Additional space to maintain from the edge of the collision boundary. |
finalFocus | boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | — | Determines the element to focus when the select popup is closed. |
render | ComponentRenderFn<HTMLProps, SelectPopupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
side | Side | — | Which side of the anchor element to align the popup against. May automatically change to avoid collisions. |
sideOffset | number | OffsetFunction | — | Distance between the anchor and the popup in pixels.
Also accepts a function that returns the distance to read the dimensions of the anchor
and positioner elements, along with its side and alignment. The function takes a data object parameter with the following properties: |
style | CSSProperties | ((state: SelectPopupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-content.tsx.
ResponsiveSelect.Group
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectGroupState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, SelectGroupState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectGroupState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-group.tsx.
ResponsiveSelect.Item
| Prop | Type | Default | |
|---|---|---|---|
children | ReactNode | — | |
className | string | ((state: SelectItemState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
label | string | — | Specifies the text label to use when the item is matched during keyboard text navigation. Defaults to the item text content if not provided. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to true if the rendered element is a native button. |
render | ComponentRenderFn<HTMLProps, SelectItemState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectItemState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
value | any | — | A unique value that identifies this select item. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-item.tsx.
ResponsiveSelect.Label
| Prop | Type | Default | |
|---|---|---|---|
className | string | ((state: SelectGroupLabelState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | ComponentRenderFn<HTMLProps, SelectGroupLabelState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectGroupLabelState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-label.tsx.
ResponsiveSelect.Trigger
| Prop | Type | Default | |
|---|---|---|---|
size | "default" | "sm" | — | |
children | ReactNode | — | |
className | string | ((state: SelectTriggerState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
disabled | boolean | — | Whether the component should ignore user interaction. |
nativeButton | boolean | — | Whether the component renders a native <button> element when replacing it
via the render prop.
Set to false if the rendered element is not a button (for example, <div>). |
render | ComponentRenderFn<HTMLProps, SelectTriggerState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectTriggerState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-trigger.tsx.
ResponsiveSelect.Value
| Prop | Type | Default | |
|---|---|---|---|
children | ((value: any) => ReactNode) | ReactNode | — | Accepts a function that returns a ReactNode to format the selected value. |
className | string | ((state: SelectValueState) => string | undefined) | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
placeholder | ReactNode | — | The placeholder value to display when no value is selected.
This is overridden by children if specified, or by a null item's label in items. |
render | ComponentRenderFn<HTMLProps, SelectValueState> | ReactElement<unknown, string | JSXElementConstructor<any>> | — | Allows you to replace the component's HTML element
with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render. |
style | CSSProperties | ((state: SelectValueState) => CSSProperties | undefined) | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-value.tsx.