ResponsiveSelect

The styled popup on desktop, the OS picker on mobile.

<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

PropTypeDefault
childrenReactNode
defaultValuestring
disabledboolean
namestringSubmitted under this name (hidden input on desktop, the <select> on mobile).
onValueChange((value: string) => void)
requiredboolean
valuestring

Plus the DOM props of the element it renders. Source: responsive-select/components/responsive-select-root.tsx.

ResponsiveSelect.Content

PropTypeDefault
alignAlignHow to align the popup relative to the specified side.
alignItemWithTriggerbooleanWhether 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.
alignOffsetnumber | OffsetFunctionAdditional 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:
childrenReactNode
classNamestring | ((state: SelectPopupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
collisionPaddingPaddingAdditional space to maintain from the edge of the collision boundary.
finalFocusboolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)Determines the element to focus when the select popup is closed.
renderComponentRenderFn<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.
sideSideWhich side of the anchor element to align the popup against. May automatically change to avoid collisions.
sideOffsetnumber | OffsetFunctionDistance 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:
styleCSSProperties | ((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

PropTypeDefault
classNamestring | ((state: SelectGroupState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<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.
styleCSSProperties | ((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

PropTypeDefault
childrenReactNode
classNamestring | ((state: SelectItemState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
disabledbooleanWhether the component should ignore user interaction.
labelstringSpecifies the text label to use when the item is matched during keyboard text navigation. Defaults to the item text content if not provided.
nativeButtonbooleanWhether 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.
renderComponentRenderFn<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.
styleCSSProperties | ((state: SelectItemState) => CSSProperties | undefined)Style applied to the element, or a function that returns a style object based on the component's state.
valueanyA 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

PropTypeDefault
classNamestring | ((state: SelectGroupLabelState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
renderComponentRenderFn<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.
styleCSSProperties | ((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

PropTypeDefault
size"default" | "sm"
childrenReactNode
classNamestring | ((state: SelectTriggerState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
disabledbooleanWhether the component should ignore user interaction.
nativeButtonbooleanWhether 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>).
renderComponentRenderFn<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.
styleCSSProperties | ((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

PropTypeDefault
children((value: any) => ReactNode) | ReactNodeAccepts a function that returns a ReactNode to format the selected value.
classNamestring | ((state: SelectValueState) => string | undefined)CSS class applied to the element, or a function that returns a class based on the component's state.
placeholderReactNodeThe 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.
renderComponentRenderFn<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.
styleCSSProperties | ((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.