Select
Single select combobox widget to allow selection from a fixed set of options.
#
Documentation
#
#
Usage
#
App.tsx
import { Box } from "@optiaxiom/react";
import {
Select,
SelectContent,
SelectRadioItem,
SelectTrigger,
SelectValue,
} from "@optiaxiom/react/unstable";
import { colors } from "./data";
export function App() {
return (
<Select
isItemDisabled={(item) => Boolean(item.isDisabled)}
items={colors}
itemToString={(item) => (item ? item.label : "")}
>
<SelectTrigger>
<SelectValue placeholder="Select a color..." />
</SelectTrigger>
<SelectContent>
{colors.map((color) => (
<SelectRadioItem
icon={
<Box
rounded="sm"
style={{ aspectRatio: 1, backgroundColor: color.color }}
/>
}
item={color}
key={color.value}
>
{color.label}
</SelectRadioItem>
))}
</SelectContent>
</Select>
);
}
#
Anatomy
#
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectRadioItem,
SelectSeparator,
SelectTrigger,
SelectValue,
} from "@optiaxiom/react";
export default () => (
<Select>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem />
<SelectRadioItem />
<SelectGroup>
<SelectLabel />
<SelectItem />
<SelectRadioItem />
</SelectGroup>
<SelectSeparator />
</SelectContent>
</Select>
);
#
Related
#
Combobox
Multi-purpose combobox widget to allow selection from a dynamic set of options.
DropdownMenu
Display a dropdown menu.
#
Props
#
#
Select
#
Doesn't render its own HTML element.
Prop |
---|
defaultOpen
Default: |
defaultValue
|
disabled
|
isItemDisabled
|
items*
|
itemToKey
Default: |
itemToString
Default: |
onOpenChange
|
onValueChange
|
open
|
value
|
#
SelectTrigger
#
Supports all Button props in addition to its own. Renders a <button>
element.
Prop |
---|
addonAfter Display content inside the button after
|
addonBefore Display content inside the button before
|
appearance Control the appearance by selecting between the different button types.
|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
disabled Whether the button is disabled.
|
icon Display an icon before or after the button content or omit
|
iconPosition Control whether to show the icon before or after the button content.
|
loading Whether to show loading spinner inside the button.
|
size Control the size of the button.
|
square Whether button should have square shape.
|
virtualRef
|
#
SelectValue
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
placeholder
|
#
SelectContent
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
align
Default: |
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
loading Whether to show loading spinner inside the menu.
|
maxH Whether to restrict the max-height of the content. Content is also restricted by the available height in the screen relative to the trigger.
|
minW Whether to set the min-width to the width of the trigger.
|
side
Default: |
#
SelectItem
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
item*
|
#
SelectRadioItem
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
addonAfter Display content inside the item after
|
addonBefore Display content inside the item before
|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
description Add secondary text after the primary label.
|
icon Display an icon before the item content.
|
intent Control the appearance by selecting between the different item types.
|
item*
|
#
SelectGroup
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
#
SelectLabel
#
Supports all Box props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
#
SelectSeparator
#
Supports all Separator props in addition to its own. Renders a <div>
element.
Prop |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
decorative Whether or not the component is purely decorative. When true, accessibility-related attributes are updated so that that the rendered element is removed from the accessibility tree.
|
orientation
|
#
Changelog
#
#
0.2.0
#
- Added component