A common form component for choosing a predefined value in a dropdown menu.
Usage guidelines
- Prefer Combobox for large lists: Select isn't filterable, apart from keyboard typeahead to find and highlight items. Prefer Combobox when there are enough items to warrant filtering.
- Special positioning behavior: By default the popup overlaps its trigger, so the selected item's text lines up with the trigger's value. Turn it off with
AlignItemWithTrigger. - Form controls must have an accessible name: Prefer
SelectLabel, or giveSelectTriggeranaria-labelwhen no visible label is rendered. - Closing animations: The popup stays rendered until its closing animation finishes. See Animation.
Anatomy
Import the primitives and assemble the parts:
@using Blazix.Primitives
<SelectRoot>
<SelectLabel />
<SelectTrigger>
<SelectValue />
<SelectIcon />
</SelectTrigger>
<SelectPortal>
<SelectBackdrop />
<SelectPositioner>
<SelectPopup>
<SelectScrollUpArrow />
<SelectArrow />
<SelectList>
<SelectItem>
<SelectItemText />
<SelectItemIndicator />
</SelectItem>
<SelectSeparator />
<SelectGroup>
<SelectGroupLabel />
</SelectGroup>
</SelectList>
<SelectScrollDownArrow />
</SelectPopup>
</SelectPositioner>
</SelectPortal>
</SelectRoot>API Reference
SelectRoot
Doesn't render its own HTML element.
SelectTrigger
Renders a <button> element.
Other attributes are passed to the element it renders.
SelectValue
Renders a <span> element.
Other attributes are passed to the element it renders.
SelectIcon
Renders a <span> element.
Other attributes are passed to the element it renders.
SelectList
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectPortal
Doesn't render its own HTML element.
SelectBackdrop
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectPositioner
Doesn't render its own HTML element.
SelectPopup
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectArrow
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectItem
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectGroup
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectGroupLabel
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectSeparator
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectLabel
Renders a <label> element.
Other attributes are passed to the element it renders.
SelectItemText
Renders a <span> element.
Other attributes are passed to the element it renders.
SelectItemIndicator
Renders a <span> element.
Other attributes are passed to the element it renders.
SelectScrollUpArrow
Renders a <div> element.
Other attributes are passed to the element it renders.
SelectScrollDownArrow
Renders a <div> element.
Other attributes are passed to the element it renders.