Select one value from a keyboard-accessible list.
import { useState } from 'react';
import { Select } from '@vrum/ui';
import { SelectTrigger, SelectValue, SelectContent, SelectItem } from '@vrum/ui';
export default function Demo() {
const [value, setValue] = useState("design");
return (
<Select
value={value}
disabled={false}
onValueChange={setValue}
>
<SelectTrigger><SelectValue placeholder="Select a team" /></SelectTrigger><SelectContent><SelectItem value="design">Design</SelectItem><SelectItem value="engineering">Engineering</SelectItem><SelectItem value="operations">Operations</SelectItem></SelectContent>
</Select>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | none | Content rendered inside the component. |
open | boolean | none | Controlled visibility. |
defaultOpen | boolean | none | Initial visibility for an uncontrolled component. |
onOpenChange | ((open: boolean) => void) | none | Called when visibility changes. |
dir | Direction | none | dir configuration. |
name | string | none | name configuration. |
autoComplete | string | none | auto complete configuration. |
disabled | boolean | none | Disable user interaction. |
required | boolean | none | required configuration. |
form | string | none | form configuration. |
value | string | none | Controlled value; connect the callback to application state. |
defaultValue | string | none | Initial value for an uncontrolled component. |
onValueChange | ((value: string) => void) | none | Called when the selected value changes. |
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | none | as child configuration. |
disabled | boolean | none | Disable user interaction. |
name | string | none | name configuration. |
type | "submit" | "reset" | "button" | none | type configuration. |
value | string | number | readonly string[] | none | Controlled value. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLButtonElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLButtonElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLButtonElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLButtonElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLButtonElement> | none | on select configuration. |
size | "sm" | "md" | "lg" | "2lg" | "3lg" | "md" | size configuration. |
shape | "square" | "rounded" | "square" | shape configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | React.ReactNode | none | Hint shown when the field is empty. |
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLSpanElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLSpanElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLSpanElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLSpanElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLSpanElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLSpanElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLSpanElement> | none | on select configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
forceMount | true | none | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. |
onCloseAutoFocus | ((event: Event) => void) | none | Event handler called when auto-focusing on close. Can be prevented. |
onEscapeKeyDown | ((event: KeyboardEvent) => void) | none | Event handler called when the escape key is down. Can be prevented. |
onPointerDownOutside | ((event: PointerDownOutsideEvent) => void) | none | Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`. Can be prevented. |
position | Position | none | position configuration. |
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLDivElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |
side | "top" | "bottom" | "left" | "right" | none | side configuration. |
sideOffset | number | none | side offset configuration. |
align | "center" | "end" | "start" | none | align configuration. |
alignOffset | number | none | align offset configuration. |
arrowPadding | number | none | arrow padding configuration. |
avoidCollisions | boolean | none | avoid collisions configuration. |
collisionBoundary | Boundary | Boundary[] | none | collision boundary configuration. |
collisionPadding | number | Partial<Record<"top" | "bottom" | "left" | "right", number>> | none | collision padding configuration. |
sticky | Sticky | none | sticky configuration. |
hideWhenDetached | boolean | none | hide when detached configuration. |
updatePositionStrategy | UpdatePositionStrategy | none | update position strategy configuration. |
container | HTMLElement | null | none | container configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
value* | string | none | Controlled value. |
disabled | boolean | none | Disable user interaction. |
textValue | string | none | text value configuration. |
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLDivElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |