import { css, on, type Handle } from '@remix-run/ui' import { Glyph } from '@remix-run/ui/glyph' import * as listbox from '@remix-run/ui/listbox' import type { ListboxValue } from '@remix-run/ui/listbox' import { theme } from '@remix-run/ui/theme' /** * @name Listbox Overview * @description A keyboard-navigable listbox with selection, highlighting, and an optional flash-selection animation. * @layout center */ export default function Example(handle: Handle) { let value: ListboxValue = options[0]!.value let activeValue: ListboxValue = options[0]!.value let flashSelection = false return () => { return (
{ value = nextValue handle.update() }} onHighlight={(nextActiveValue) => { activeValue = nextActiveValue handle.update() }} >
{options.map((option) => (
{option.label}
))}

{`value=${value ?? 'null'}`}

) } } const options = [ { label: 'Apple', value: 'apple' }, { label: 'Banana', value: 'banana' }, { label: 'Cherry', value: 'cherry' }, { label: 'Date', value: 'date' }, { label: 'Elderberry', value: 'elderberry' }, { label: 'Fig', value: 'fig' }, { label: 'Grape', value: 'grape' }, ] as const const containerCss = css({ borderColor: theme.colors.border.subtle, padding: theme.space.xs, borderRadius: theme.radius.lg, borderStyle: 'solid', }) const stackCss = css({ display: 'flex', flexDirection: 'column', gap: theme.space.md, width: '100%', }) const controlsCss = css({ display: 'flex', flexDirection: 'column', gap: theme.space.xs, }) const checkboxLabelCss = css({ fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.normal, color: theme.colors.text.secondary, }) const valueCss = css({ margin: 0, fontFamily: theme.fontFamily.mono, fontSize: theme.fontSize.xs, color: theme.colors.text.secondary, })