listbox
A list of options that allows a user to optionally select one or more of them.
Import
Import just the listbox styles.
@import "@winnie-ui/css/spatial/listbox";@import "@winnie-ui/css/visual/listbox";Anatomy
Attach the appropriate data attributes in the structure below.
<ul data-component="listbox"> <li data-component="listbox-item"> <span data-slot="label"></span> </li> <div data-component="separator"></div> <section data-component="section"> <header data-slot="header"> <span data-slot="label"></span> </header> <li data-component="listbox-item"> <i data-slot="indicator"></i> <span data-slot="label"></span> </li> <li data-component="listbox-item"> <i data-slot="icon"></i> <span data-slot="label"></span> </li> <li data-component="listbox-item"> <span data-slot="label"></span> <kbd data-slot="shortcut"></kbd> </li> </section></ul>Examples
Size
Use the data-size attribute to change the size.
Radius
Use the data-radius attribute to change the size.
Color
Use the data-accent-color attribute to change the color a specific item.
Separator
Add a separator using the separator component.
Icon
Add an icon to an item using the icon slot attribute as a child of a list item.
Sections
Use the section, header, and separator attributes to group items.
Indicators
Add an icon or checkbox to indicate that an item has been selected using the indicator slot as a child of a list item. Note, if you want to reduce layout shift when using indicators that dynamically render on selection, see Mode.
Mode
Use the data-mode attribute to account for dynamically rendered indicators. This allows you to avoid layout shift in components that could potentially transition from having zero items selected to one or more.
Descriptions
Use the description slot in different variations to achieve the layout that works for your use case.
Column
You can create a column layout with the help of listbox-group component and placing the label and description slots as children.
Row
Simlar to the column layout, you can create a row based layout with staggared alignment using the listbox-group component.
Inline
Finally, if you prefer to align all descriptions, you can skip the group component and provide the description slot as a child of listbox-item.
Shortcuts
Use the shortcut slot as a child of the list item to show a keyboard shortcut.
Disabled
Use the data-disabled or aria-disabled attribute to prevent user iteraction.
Reference
listbox
Groups all of the parts of the listbox item together.
section-header
Represents the header of a listbox section.
listbox-item
Groups all of the parts of the listbox item together.