Skip to content
Documentation

DocumentationSelect

Select

One choice or many. Always the right value.

@rentnerkev/selectDocumented version: v6.2.0

Install the package

Use React 19 and import the package stylesheet once in your app’s global CSS. The bundled styles are built for Tailwind CSS 4.

Terminal
bun add @rentnerkev/select
Global stylesheet / styles.css
@import '@rentnerkev/select/tailwind.css';

Combobox: multiple objects and async results#

ComboboxProps<T> is a discriminated union: with multiple: true, value is readonly T[] and onValueChange receives T[]. Single mode keeps T | null. Control searchValue separately and supply unique stable getOptionKey values; selected objects survive new asynchronous result arrays and objects, even when the selected items are absent from the current page. The default equality compares keys. filterMode external renders your supplied results; the application owns fetching, debounce, loading, cancellation and option creation.

example.tsx
import { Combobox } from '@rentnerkev/select/combobox'
import { useState, type FormEvent } from 'react'

type Customer = { id: string; name: string; email: string }

export default function CustomerTeam({
    results,
    loading = false,
}: {
    results: readonly Customer[]
    loading?: boolean
}) {
    const [selected, setSelected] = useState<readonly Customer[]>([])
    const [query, setQuery] = useState('')
    const [submitted, setSubmitted] = useState<string[]>([])
    function handleSubmit(event: FormEvent<HTMLFormElement>) {
        event.preventDefault()
        setSubmitted(new FormData(event.currentTarget).getAll('customers').map(String))
    }
    return (
        <form onSubmit={handleSubmit}>
            <Combobox
                multiple
                clearable
                name="customers"
                label="Customer team"
                value={selected}
                onValueChange={setSelected}
                searchValue={query}
                onSearchValueChange={setQuery}
                options={results}
                loading={loading}
                filterMode="external"
                getOptionKey={(customer) => customer.id}
                getOptionLabel={(customer) => customer.name}
                getOptionDescription={(customer) => customer.email}
                getFormValue={(customer) => customer.id}
            />
            <button type="submit">Read selected IDs</button>
            <output>{submitted.join(', ')}</output>
        </form>
    )
}

Stable first-open positioning and ShadowRoot portals#

CustomSelect and Combobox share popup measurement and visibility readiness. The current popup stays hidden until it is measured with its final viewport constraints, including scrollbar width, so the first open after reload does not flash at stale coordinates. Scroll, viewport changes and a replaced portal remeasure the popup. ShadowRoot portals retain keyboard focus, whole-field blur and outside-dismissal behavior.

example.tsx
import { CustomSelect } from '@rentnerkev/select'
import { useState } from 'react'

export default function LanguageSelect() {
    const [language, setLanguage] = useState('en')
    return (
        <div className="flex justify-end">
            <CustomSelect
                label="Language"
                contentWidth="content"
                value={language}
                onValueChange={setLanguage}
                options={[
                    { value: 'en', label: 'English' },
                    { value: 'de', label: 'Deutsch' },
                ]}
            />
        </div>
    )
}

Grouped Select and Combobox options#

Set option.group on CustomSelect or return a group name from Combobox.getOptionGroup. Group headings are not selectable; entries without a group remain available. Filtering, keyboard navigation, disabled entries and virtualization keep working across groups. classNames.group and groupLabel customize the presentation.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'
import { Combobox } from '@rentnerkev/select/combobox'

const roles = [
    { id: 'owner', name: 'Owner', group: 'Team' },
    { id: 'editor', name: 'Editor', group: 'Team' },
    { id: 'guest', name: 'Guest', group: 'Visitors' },
]

export default function GroupedChoices() {
    const [role, setRole] = useState('editor')
    const [customer, setCustomer] = useState<(typeof roles)[number] | null>(null)
    const [query, setQuery] = useState('')
    return (
        <section className="grid gap-4">
            <CustomSelect
                label="Role"
                options={roles.map(({ id, name, group }) => ({
                    value: id,
                    label: name,
                    group,
                }))}
                value={role}
                onValueChange={setRole}
            />
            <Combobox
                label="Search roles"
                options={roles}
                value={customer}
                onValueChange={setCustomer}
                searchValue={query}
                onSearchValueChange={setQuery}
                getOptionKey={(option) => option.id}
                getOptionLabel={(option) => option.name}
                getOptionGroup={(option) => option.group}
            />
        </section>
    )
}

Create a new Combobox option#

onCreateOption adds a creation row for a nonempty trimmed query when no existing option has the same label, ignoring case. createOptionLabel customizes that row. The callback receives the trimmed query; your application owns creating, storing and selecting the option. Disabled or read-only controls cannot create entries.

example.tsx
import { useState } from 'react'
import { Combobox } from '@rentnerkev/select/combobox'

type Tag = { id: string; label: string }

export default function CreateTag() {
    const [options, setOptions] = useState<Tag[]>([
        { id: 'react', label: 'React' },
    ])
    const [value, setValue] = useState<Tag | null>(null)
    const [query, setQuery] = useState('')
    function createOption(label: string) {
        const option = { id: crypto.randomUUID(), label }
        setOptions((current) => [...current, option])
        setValue(option)
        setQuery('')
    }
    return (
        <Combobox
            label="Tag"
            options={options}
            value={value}
            onValueChange={setValue}
            searchValue={query}
            onSearchValueChange={setQuery}
            getOptionKey={(option) => option.id}
            getOptionLabel={(option) => option.label}
            onCreateOption={createOption}
            createOptionLabel={(label) => 'Create tag: ' + label}
        />
    )
}

Remove individual selected items#

Set removableSelectedItems on a multiple CustomSelect to remove selected labels without opening the popup. It defaults to false. Hover or keyboard focus shows a red strike-through and a localized removal tooltip; click, Enter or Space removes only that value. Disabled selections stay pinned. disabled, readOnly and custom renderValue suppress the built-in removal controls.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

export default function RemoveSelectedRoles() {
    const [values, setValues] = useState<string[]>(['editor', 'locked'])
    return (
        <CustomSelect
            label="Roles"
            name="roles"
            multiple
            clearable
            removableSelectedItems
            value={values}
            onValueChange={setValues}
            options={[
                { value: 'editor', label: 'Editor' },
                { value: 'reviewer', label: 'Reviewer' },
                { value: 'locked', label: 'Required role', disabled: true },
            ]}
            messages={{
                clickToRemove: 'Click to remove',
                removeSelectedItem: (label) => 'Remove ' + label,
            }}
        />
    )
}

Select 6.0: native popup migration#

Version 6.0.0 replaces Radix Select with a React/DOM popup. Component imports and props stay unchanged. The popup is nonmodal: Tab and Shift+Tab close it and move through the surrounding controls; outside clicks close it and activate their target. Escape and single selection return focus to the trigger. Options, including renderOption content, mount only while open; closed typeahead uses option.label.

example.tsx
import { CustomSelect } from '@rentnerkev/select'
import { useState } from 'react'

export default function NativeSelect() {
    const [value, setValue] = useState('standard')
    return (
        <CustomSelect
            label="Delivery"
            onValueChange={setValue}
            options={[
                { value: 'standard', label: 'Standard' },
                { value: 'express', label: 'Express' },
            ]}
            value={value}
        />
    )
}

Combobox: external search results#

New in 5.2.0: Combobox<T> accepts your domain objects with stable unique getOptionKey and getOptionLabel. value and searchValue are independent: typing only changes the query, and selection only changes the value. Update both in the selection handler when the label should replace the query. filterMode defaults to external, displaying supplied results unchanged; local enables label filtering. Your application owns requests, debounce and cancellation. Selection survives result-page changes. loading hides stale results; loadingText, emptyText and messages.loading customize status text.

example.tsx
import { Combobox } from '@rentnerkev/select/combobox'
import { useState } from 'react'

type Customer = { id: string; name: string; email: string }

export default function CustomerSearch({
    results,
    loading = false,
}: {
    results: readonly Customer[]
    loading?: boolean
}) {
    const [customer, setCustomer] = useState<Customer | null>(null)
    const [query, setQuery] = useState('')
    return (
        <Combobox
            clearable
            filterMode="external"
            getOptionDescription={(option) => option.email}
            getOptionKey={(option) => option.id}
            getOptionLabel={(option) => option.name}
            getFormValue={(option) => option.id}
            label="Customer"
            loading={loading}
            name="customerId"
            onSearchValueChange={setQuery}
            onValueChange={(next) => {
                setCustomer(next)
                setQuery(next?.name ?? '')
            }}
            options={results}
            searchValue={query}
            value={customer}
        />
    )
}

Text slots, wrapping & popup width#

New in 5.2.0: controlSize sm/md/lg sets 36/44/48 px; omitted size preserves existing geometry. textOverflow is truncate by default or wrap for long text. An unsized wrapping trigger can grow; an explicit size keeps its height. contentWidth is trigger by default or content, with the trigger as minimum and viewport as maximum. Text slots style optionLabel, optionDescription, optionIndicator, selectedLabel and selectedDescription without descendant selectors. Slots replace visual defaults; nested providers inherit them individually and an empty string removes a default. Combobox uses search for its input, falling back to trigger.

example.tsx
import { CustomSelect, SelectProvider } from '@rentnerkev/select'
import { useState } from 'react'

export default function Delivery() {
    const [value, setValue] = useState('standard')
    return (
        <SelectProvider
            contentWidth="content"
            portalClassName="font-sans"
            portalZIndex={12000}
            textOverflow="wrap"
            classNames={{
                optionLabel: 'font-semibold',
                selectedLabel: 'text-sky-700',
            }}
        >
            <CustomSelect
                label="Delivery"
                onValueChange={setValue}
                options={[
                    {
                        value: 'standard',
                        label: 'Standard delivery with shipment tracking',
                        subOption: 'Three business days',
                    },
                    {
                        value: 'express',
                        label: 'Express delivery',
                        subOption: 'Next business day',
                    },
                ]}
                value={value}
            />
        </SelectProvider>
    )
}

UI-free form adapter#

getSelectFieldProps from /form connects structural fields to CustomSelect or Combobox without importing React or a form runtime. It returns name, value, onValueChange, whole-field onBlur and error. Errors appear after touch by default; errorVisibility accepts touched, always or never. getReadableSelectError accepts strings or objects with a string message; mapError handles other shapes. A null error intentionally leaves validation to the form. Call the helper inside a subscribed field render; a Combobox still needs its separate searchValue handlers.

example.tsx
import { CustomSelect } from '@rentnerkev/select'
import {
    getReadableSelectError,
    getSelectFieldProps,
} from '@rentnerkev/select/form'
import type { SelectFormField } from '@rentnerkev/select/form'

export default function RegionField({
    field,
}: {
    field: SelectFormField<string>
}) {
    return (
        <CustomSelect
            {...getSelectFieldProps(field, {
                errorVisibility: 'touched',
                mapError: getReadableSelectError,
            })}
            label="Region"
            options={[{ value: 'eu', label: 'Europe' }]}
        />
    )
}

Shared theme tokens#

All packages share --rentner-* CSS variables for control, surface, foreground, muted, border, accent, accent-hover, accent-foreground, danger, success, warning, info and radius. The Tailwind entry includes theme.css automatically; the separate theme.css export contains tokens, not the complete component styles. Set variables on :root for a global theme. A scoped theme must also reach the actual portal destination. Existing customDesign and legacy tokens remain supported.

styles.css
@import 'tailwindcss';
@import '@rentnerkev/select/tailwind.css';

:root {
    --rentner-control: #ffffff;
    --rentner-surface: #f8fafc;
    --rentner-foreground: #0f172a;
    --rentner-muted: #475569;
    --rentner-border: #64748b;
    --rentner-accent: #0369a1;
    --rentner-accent-hover: #075985;
    --rentner-accent-foreground: #ffffff;
    --rentner-danger: #be123c;
    --rentner-success: #047857;
    --rentner-warning: #b45309;
    --rentner-info: #0369a1;
    --rentner-radius: 0.5rem;
}

Local AI helpers: metadata & guides#

Import the /ai entry in a local Node.js or Bun script. These synchronous, read-only helpers use node:fs to read the installed package without importing its UI. getPackageInfo() returns PackageInfo, including the installed version, public exports and peer dependencies. getPackageDocumentation() returns a PackageDocument with path and content; its default is usage, and readme selects README.md. Only these two packaged documents are accepted. Results describe your installed version, which can differ from this website.

inspect-package.ts · Node.js / Bun
import { getPackageDocumentation, getPackageInfo } from '@rentnerkev/select/ai'
import type { PackageDocument, PackageInfo } from '@rentnerkev/select/ai'

const info: PackageInfo = getPackageInfo()
const usage: PackageDocument = getPackageDocumentation()
const readme = getPackageDocumentation('readme')

console.log(info.name, info.version, info.exports, info.peerDependencies)
console.log(usage.path, usage.content)
console.log(readme.path, readme.content)

Local AI helpers: public declarations#

getPackageApi() returns PackageApi with package, installed version, selected subpaths and declarations as PackageDocument objects. It reads public typed entries and their local declaration dependencies; /ai itself is excluded. Use subpath such as . or ./types to select a public entry. symbol validates that a name is exported by the selected entry; it does not trim declaration files to that symbol. Unknown subpaths, invalid names and names not exported by the selected entry throw errors. Callers cannot provide arbitrary file paths.

inspect-api.ts · Node.js / Bun
import { getPackageApi } from '@rentnerkev/select/ai'
import type { PackageApi } from '@rentnerkev/select/ai'

const api: PackageApi = getPackageApi()
const selected = getPackageApi({ subpath: '.', symbol: 'CustomSelect' })

console.log(api.package, api.version, api.subpaths)
for (const declaration of selected.declarations) {
    console.log(declaration.path, declaration.content)
}

Local AI helpers: search & examples#

searchPackageDocumentation(query) searches README.md and docs/usage.md using a trimmed, case-insensitive literal query. It returns PackageSearchMatch objects with path, a one-based line number and matching text; an empty query returns an empty array. getPackageExamples() returns every fenced code block from the installed usage guide as a PackageExample with language and code. These helpers return text for your own tools; they do not execute examples or contact an AI service.

search-package.ts · Node.js / Bun
import { getPackageExamples, searchPackageDocumentation } from '@rentnerkev/select/ai'
import type { PackageExample, PackageSearchMatch } from '@rentnerkev/select/ai'

const matches: PackageSearchMatch[] = searchPackageDocumentation('CustomSelect')
const examples: PackageExample[] = getPackageExamples()

for (const match of matches) {
    console.log(match.path, match.line, match.text)
}
for (const example of examples) {
    console.log(example.language, example.code)
}

CustomSelect & typed options#

Pass options with value and label and control the selection with value/onValueChange. TValue is inferred from your values and may be a string, number or object. An option can include subOption for supporting text and disabled to prevent selection. label, description, placeholder and icon describe the field; fallbackOption labels a selected value missing from the options list.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

const options = [
    { value: 'tooltips', label: 'Tooltips', subOption: 'Helpful hints' },
    { value: 'toasts', label: 'Toasts' },
    { value: 'coming-soon', label: 'Coming soon', disabled: true },
]

export default function PackageSelect() {
    const [value, setValue] = useState('')
    return (
        <CustomSelect
            label="Package"
            onValueChange={setValue}
            options={options}
            value={value}
        />
    )
}

Multiple selection & limits#

Set multiple and use an array of values. onValueChange returns a new array. minSelection and maxSelection express selection limits; maxSelection prevents additional choices beyond the limit. required and error integrate validation. Disabled options cannot be selected.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

const options = ['Tooltips', 'Toasts', 'Inputs'].map((name) => ({
    value: name,
    label: name,
}))

export default function MultiplePackages() {
    const [values, setValues] = useState<string[]>([])
    return (
        <CustomSelect
            label="Packages"
            maxSelection={2}
            minSelection={1}
            multiple
            onValueChange={setValues}
            options={options}
            value={values}
        />
    )
}

Clearable values & emptyValue#

For a directly clearable single select, use clearable with nullable state; clearing emits null through onValueChange. emptyValue lets you choose a different empty sentinel, such as an empty string. The legacy onClear callback remains available when you manage clearing separately. Multiple selection clears to an empty array.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

export default function ClearablePackage() {
    const [value, setValue] = useState<string | null>(null)
    return (
        <CustomSelect
            clearable
            label="Package"
            onValueChange={setValue}
            options={[{ value: 'tooltips', label: 'Tooltips' }]}
            value={value}
        />
    )
}

Search & keyboard navigation#

searchable enables the search field in the popup; set it to false for a short fixed list. The control supports keyboard navigation, selection and dismissal. messages customizes search labels, the search placeholder and empty results. Supply an accessible label even when a visible label is omitted.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

export default function SearchablePackages() {
    const [value, setValue] = useState('')
    return (
        <CustomSelect
            label="Find a package"
            messages={{
                searchPlaceholder: 'Type a package name',
                noResults: 'No matching package',
            }}
            onValueChange={setValue}
            options={[
                { value: 'inputs', label: 'Inputs' },
                { value: 'calendar', label: 'Calendar' },
            ]}
            searchable
            value={value}
        />
    )
}

Object values & equality#

When values are objects, use isOptionEqualToValue to compare stable keys instead of object identity. This keeps the selection correct when options are loaded again. getFormValue serializes an object value for native forms.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

type Package = { id: number; name: string }
const options = [{ value: { id: 1, name: 'Tooltips' }, label: 'Tooltips' }]

export default function ObjectSelect() {
    const [value, setValue] = useState<Package | null>(null)
    return (
        <CustomSelect
            clearable
            getFormValue={(item) => String(item.id)}
            isOptionEqualToValue={(option, selected) =>
                option.id === selected.id
            }
            label="Package"
            name="packageId"
            onValueChange={setValue}
            options={options}
            value={value}
        />
    )
}

Custom option & value rendering#

renderOption receives the option and its selected/disabled state. renderValue receives an array of selected options, including in single mode. Return React content to add badges or secondary information while keeping the control’s keyboard and selection behavior.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

export default function RichOptions() {
    const [value, setValue] = useState('')
    return (
        <CustomSelect
            label="Package"
            onValueChange={setValue}
            options={[{ value: 'tooltips', label: 'Tooltips' }]}
            renderOption={(option, state) => (
                <span>
                    {state.selected ? '✓ ' : ''}
                    {option.label}
                </span>
            )}
            renderValue={(selected) =>
                selected.map((option) => option.label).join(', ')
            }
            value={value}
        />
    )
}

Native forms, focus & field states#

name creates native form values; getFormValue converts custom values to strings. Multiple fields submit repeated values, which you can read with FormData.getAll. omitEmptyFormValue omits the empty multiple selection. id, label, description, error, required and ARIA props describe validation. disabled prevents interaction; readOnly prevents editing. triggerRef focuses the button, onBlur tracks leaving the field, and nonce supplies a CSP nonce when needed for the component’s styles.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'

export default function PackageForm() {
    const [values, setValues] = useState<string[]>([])
    return (
        <form
            onSubmit={(event) => {
                event.preventDefault()
                console.log(
                    new FormData(event.currentTarget).getAll('packages'),
                )
            }}
        >
            <CustomSelect
                label="Packages"
                multiple
                name="packages"
                omitEmptyFormValue
                onValueChange={setValues}
                options={[{ value: 'inputs', label: 'Inputs' }]}
                value={values}
            />
            <button type="submit">Save</button>
        </form>
    )
}

SelectProvider#

Configure locale, messages, classNames, searchable and nonce for a group of selects. Per-component settings override the nearest provider.

example.tsx
import { useState } from 'react'
import { CustomSelect, SelectProvider } from '@rentnerkev/select'

export default function SharedDefaults() {
    const [value, setValue] = useState('')
    return (
        <SelectProvider locale="en" searchable={false}>
            <CustomSelect
                label="Package"
                onValueChange={setValue}
                options={[{ value: 'toasts', label: 'Toasts' }]}
                value={value}
            />
        </SelectProvider>
    )
}

isSingleValueEmpty()#

The /value helper treats an empty string, null and undefined as empty single values. It returns a boolean and narrows the TypeScript type.

example.ts
import { isSingleValueEmpty } from '@rentnerkev/select/value'

export const hasSelection = !isSingleValueEmpty('tooltips')
export const isEmpty = isSingleValueEmpty(null)

toggleSelectedValue()#

Toggle a value in a readonly selection array using your equality function. Existing values are removed; new values are appended. Returns null when adding would exceed maxSelection. The original array is not mutated.

example.ts
import { toggleSelectedValue } from '@rentnerkev/select/value'

export const next = toggleSelectedValue(
    ['tooltips'],
    'toasts',
    (option, value) => option === value,
    2,
)

Translations & resolveSelectMessages()#

selectMessageCatalog includes en, de, es and fr. resolveSelectMessages merges your overrides with that locale. Messages cover required/minimum/maximum selection, search, empty states and clearing. minSelection and maxSelection messages are functions receiving the count.

example.ts
import { resolveSelectMessages, selectMessageCatalog } from '@rentnerkev/select'

export const messages = resolveSelectMessages('en', {
    noResults: 'No package found',
    maxSelection: (count) => 'Choose up to ' + count + ' packages',
    clearSelection: selectMessageCatalog.en.clearSelection,
})

Class slots & custom design#

className styles the outer component. classNames has root, trigger, content, search, viewport, option, empty, label, description and clear slots. Supply only the slots you want to change and keep shared defaults on SelectProvider. Import the Tailwind stylesheet once.

example.tsx
import { useState } from 'react'
import { CustomSelect } from '@rentnerkev/select'
import type { SelectClassNames } from '@rentnerkev/select/types'

const classNames: SelectClassNames = {
    trigger: 'border-2 border-amber-700 bg-amber-50 text-stone-900',
    content: 'bg-amber-50 text-stone-900',
    label: 'font-bold',
}

export default function StyledSelect() {
    const [value, setValue] = useState('')
    return (
        <CustomSelect
            classNames={classNames}
            label="Package"
            onValueChange={setValue}
            options={[{ value: 'calendar', label: 'Calendar' }]}
            value={value}
        />
    )
}

Docs for your AI tools

Connect a compatible MCP client to read package APIs, guides and examples. Public access, no account or API key required.

Remote access is optional: add this public URL yourself to your MCP client. Clients use Streamable HTTP; the configuration format may vary. The local package /ai helpers read the installed version in Node.js or Bun and never connect to this server automatically.

MCP / Streamable HTTP
{
    "mcpServers": {
        "rentnerPackages": {
            "url": "https://packages.rentner.dev/mcp"
        }
    }
}

Tools: list_packages, read_package_docs, read_package_api, read_package_examples and search_package_docs.

API & types

Published signatures, props and types for this version. Expand an entry to inspect its definition and available import paths.

CustomSelectfunction
  • @rentnerkev/select
  • @rentnerkev/select/select
CustomSelect.d.ts
export function CustomSelect<TValue = string>(props: LegacySingleSelectProps<TValue>): ReactElement
export function CustomSelect<TValue = string>(props: DirectClearableSingleSelectProps<TValue>): ReactElement
export function CustomSelect<TValue = string>(props: ConfiguredClearableSingleSelectProps<TValue>): ReactElement
export function CustomSelect<TValue = string>(props: DefaultSingleSelectProps<TValue>): ReactElement
export function CustomSelect<TValue = string>(props: MultipleSelectProps<TValue>): ReactElement
export function CustomSelect<TValue = string>(props: CustomSelectProps<TValue>): ReactElement
export function CustomSelect(props: CustomSelectProps<string>): ReactElement
SelectProviderfunction
  • @rentnerkev/select
SelectProvider.d.ts
export function SelectProvider({ children, ...props }: SelectProviderProps): import("react").JSX.Element
resolveSelectMessagesfunction
  • @rentnerkev/select
  • @rentnerkev/select/messages
resolveSelectMessages.d.ts
export function resolveSelectMessages(locale?: SelectLocale, messages?: Partial<SelectMessages>): SelectMessages
selectMessageCatalogconst
  • @rentnerkev/select
  • @rentnerkev/select/messages
selectMessageCatalog.d.ts
export const selectMessageCatalog: Record<SelectLocale, SelectMessages>
CustomSelectPropstype
  • @rentnerkev/select
  • @rentnerkev/select/types
CustomSelectProps.d.ts
export type CustomSelectProps<TValue = string> = SingleSelectProps<TValue> | MultipleSelectProps<TValue>
MultipleSelectPropstype
  • @rentnerkev/select
  • @rentnerkev/select/types
MultipleSelectProps.d.ts
export type MultipleSelectProps<TValue = string> = SharedCustomSelectProps<TValue> & ClearableSelectProps & {
    value: ReadonlyArray<TValue>
    onValueChange: (value: Array<TValue>) => void
    multiple: true
    /** Enable removal from the built-in closed selection labels. Defaults to false renderValue takes precedence. */
    removableSelectedItems?: boolean
    emptyValue?: never
    omitEmptyFormValue?: boolean
    minSelection?: number
    maxSelection?: number
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}

type ClearableSelectProps = {
    clearable: true
    onClear?: () => void
} | {
    clearable?: false
    onClear?: never
}
SelectClassNamesinterface
  • @rentnerkev/select
  • @rentnerkev/select/types
SelectClassNames.d.ts
export interface SelectClassNames {
    root?: string
    trigger?: string
    content?: string
    search?: string
    viewport?: string
    option?: string
    group?: string
    groupLabel?: string
    createOption?: string
    empty?: string
    label?: string
    description?: string
    clear?: string
    control?: string
    error?: string
    leading?: string
    trailing?: string
    optionLabel?: string
    optionDescription?: string
    optionIndicator?: string
    selectedLabel?: string
    selectedDescription?: string
    selectedItems?: string
    selectedItem?: string
}
SelectOptionStateinterface
  • @rentnerkev/select
  • @rentnerkev/select/types
SelectOptionState.d.ts
export interface SelectOptionState {
    selected: boolean
    disabled: boolean
}
SingleSelectPropstype
  • @rentnerkev/select
  • @rentnerkev/select/types
SingleSelectProps.d.ts
export type SingleSelectProps<TValue = string> = LegacySingleSelectProps<TValue> | DirectClearableSingleSelectProps<TValue> | ConfiguredClearableSingleSelectProps<TValue> | DefaultSingleSelectProps<TValue>
SelectProviderPropsinterface
  • @rentnerkev/select
  • @rentnerkev/select/types
SelectProviderProps.d.ts
export interface SelectProviderProps extends SelectCustomizationProps {
    children: ReactNode
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
}
SelectVirtualizationOptionsinterface
  • @rentnerkev/select
  • @rentnerkev/select/types
SelectVirtualizationOptions.d.ts
export interface SelectVirtualizationOptions {
    estimateSize?: number
    overscan?: number
}
Optioninterface
  • @rentnerkev/select
  • @rentnerkev/select/types
Option.d.ts
export interface Option<TValue = string> {
    value: TValue
    label: string
    subOption?: string
    group?: string
    disabled?: boolean
}
SelectLocaletype
  • @rentnerkev/select
  • @rentnerkev/select/messages
  • @rentnerkev/select/types
SelectLocale.d.ts
export type SelectLocale = 'de' | 'en' | 'es' | 'fr'
SelectMessagesinterface
  • @rentnerkev/select
  • @rentnerkev/select/messages
  • @rentnerkev/select/types
SelectMessages.d.ts
export interface SelectMessages {
    loading?: string
    createOption?: (value: string) => string
    clickToRemove?: string
    removeSelectedItem?: (label: string) => string
    required: string
    minSelection: (count: number) => string
    maxSelection: (count: number) => string
    searchOptions: string
    searchPlaceholder: string
    noResults: string
    noOptions: string
    clearSelection: string
}
Comboboxfunction
  • @rentnerkev/select
  • @rentnerkev/select/combobox
Combobox.d.ts
export function Combobox<T>(props: SingleComboboxProps<T>): ReactElement
export function Combobox<T>(props: MultipleComboboxProps<T>): ReactElement
export function Combobox<T>(props: ComboboxProps<T>): ReactElement
ComboboxPropstype
  • @rentnerkev/select
  • @rentnerkev/select/combobox
  • @rentnerkev/select/combobox/types
ComboboxProps.d.ts
export type ComboboxProps<T> = SingleComboboxProps<T> | MultipleComboboxProps<T>
getSelectFieldPropsfunction
  • @rentnerkev/select
  • @rentnerkev/select/form
getSelectFieldProps.d.ts
export function getSelectFieldProps<T>(field: SelectFormField<T>, options?: SelectFormOptions): SelectFieldProps<T>
getReadableSelectErrorfunction
  • @rentnerkev/select
  • @rentnerkev/select/form
getReadableSelectError.d.ts
export function getReadableSelectError(error: unknown): string | undefined
SelectFormFieldinterface
  • @rentnerkev/select
  • @rentnerkev/select/form
SelectFormField.d.ts
export interface SelectFormField<T> {
    name: string
    state: {
        value: T
        meta?: {
            errors?: ReadonlyArray<unknown>
            isTouched?: boolean
        }
    }
    handleChange: (value: T) => void
    handleBlur: () => void
}
SelectFormOptionsinterface
  • @rentnerkev/select
  • @rentnerkev/select/form
SelectFormOptions.d.ts
export interface SelectFormOptions {
    errorVisibility?: 'touched' | 'always' | 'never'
    mapError?: (error: unknown) => string | undefined
}
SelectFieldPropsinterface
  • @rentnerkev/select
  • @rentnerkev/select/form
SelectFieldProps.d.ts
export interface SelectFieldProps<T> {
    name: string
    value: T
    onValueChange: (value: T) => void
    onBlur: () => void
    error: string | null
}
SelectCustomizationPropsinterface
  • @rentnerkev/select
  • @rentnerkev/select/types
SelectCustomizationProps.d.ts
export interface SelectCustomizationProps {
    /** Auto by default: CustomSelect >= 250 options, Combobox >= 1000 true/options force on, false forces off. */
    virtualized?: boolean | 'auto' | SelectVirtualizationOptions
    controlSize?: 'sm' | 'md' | 'lg'
    textOverflow?: 'truncate' | 'wrap'
    contentWidth?: 'trigger' | 'content'
    portalContainer?: Element | DocumentFragment | null
    portalClassName?: string
    portalZIndex?: number
}
isSingleValueEmptyfunction
  • @rentnerkev/select/value
isSingleValueEmpty.d.ts
export function isSingleValueEmpty(value: unknown): value is '' | null | undefined
toggleSelectedValuefunction
  • @rentnerkev/select/value
toggleSelectedValue.d.ts
export function toggleSelectedValue<TValue>(selectedValues: ReadonlyArray<TValue>, nextValue: TValue, isEqual: SelectValueComparator<TValue>, maxSelection?: number): Array<TValue> | null
SelectValueComparatortype
  • @rentnerkev/select/value
SelectValueComparator.d.ts
export type SelectValueComparator<TValue> = (optionValue: TValue, value: TValue) => boolean
SelectVirtualNavigationinterface
  • @rentnerkev/select/types
SelectVirtualNavigation.d.ts
export interface SelectVirtualNavigation {
    handleKeyDown: (event: KeyboardEvent<HTMLDivElement>) => boolean
    handleContentFocus: () => void
}
LegacySingleSelectPropstype
  • @rentnerkev/select/types
LegacySingleSelectProps.d.ts
export type LegacySingleSelectProps<TValue = string> = SingleSelectPropsBase<TValue> & {
    clearable: true
    onClear: () => void
    emptyValue?: never
    onValueChange: (value: TValue) => void
}

type SingleSelectPropsBase<TValue> = SharedCustomSelectProps<TValue> & {
    value: TValue | null | undefined
    multiple?: false
    removableSelectedItems?: never
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
DirectClearableSingleSelectPropstype
  • @rentnerkev/select/types
DirectClearableSingleSelectProps.d.ts
export type DirectClearableSingleSelectProps<TValue = string> = SingleSelectPropsBase<TValue> & {
    clearable: true
    onClear?: never
    emptyValue?: null
    onValueChange: (value: TValue | null) => void
}

type SingleSelectPropsBase<TValue> = SharedCustomSelectProps<TValue> & {
    value: TValue | null | undefined
    multiple?: false
    removableSelectedItems?: never
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
ConfiguredClearableSingleSelectPropstype
  • @rentnerkev/select/types
ConfiguredClearableSingleSelectProps.d.ts
export type ConfiguredClearableSingleSelectProps<TValue = string> = SingleSelectPropsBase<TValue> & {
    clearable: true
    onClear?: never
    emptyValue: TValue
    onValueChange: (value: TValue) => void
}

type SingleSelectPropsBase<TValue> = SharedCustomSelectProps<TValue> & {
    value: TValue | null | undefined
    multiple?: false
    removableSelectedItems?: never
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
DefaultSingleSelectPropstype
  • @rentnerkev/select/types
DefaultSingleSelectProps.d.ts
export type DefaultSingleSelectProps<TValue = string> = SingleSelectPropsBase<TValue> & {
    clearable?: false
    onClear?: never
    emptyValue?: never
    onValueChange: (value: TValue) => void
}

type SingleSelectPropsBase<TValue> = SharedCustomSelectProps<TValue> & {
    value: TValue | null | undefined
    multiple?: false
    removableSelectedItems?: never
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
SelectDefaultstype
  • @rentnerkev/select/types
SelectDefaults.d.ts
export type SelectDefaults = Omit<SelectProviderProps, 'children'>
SelectOptionHandlersinterface
  • @rentnerkev/select/types
SelectOptionHandlers.d.ts
export interface SelectOptionHandlers<TValue> {
    handleOptionPointerDown: (event?: PointerEvent<HTMLDivElement>) => void
    handleOptionPointerUp?: (event: PointerEvent<HTMLDivElement>, value: string) => void
    handleOptionPointerMove?: (event: PointerEvent<HTMLDivElement>) => void
    handleOptionClick?: (event: MouseEvent<HTMLDivElement>, value: string) => void
    handleOptionFocus: (value: TValue, event?: FocusEvent<HTMLDivElement>) => void
    handleOptionBlur: (event: FocusEvent<HTMLDivElement>) => void
    handleOptionKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void
}
SelectOptionsPropsinterface
  • @rentnerkev/select/types
SelectOptionsProps.d.ts
export interface SelectOptionsProps<TValue> {
    entries: ReadonlyArray<OptionEntry<TValue>>
    multiple: boolean
    renderOption: SharedCustomSelectProps<TValue>['renderOption']
    className: string | undefined
    classNames: SelectClassNames
    textOverflow: 'truncate' | 'wrap'
    isSelected: (value: TValue) => boolean
    isOptionDisabled: (option: Option<TValue>) => boolean
    handler: SelectOptionHandlers<TValue>
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
CustomSelectLogicResultinterface
  • @rentnerkev/select/types
CustomSelectLogicResult.d.ts
export interface CustomSelectLogicResult<TValue> {
    state: SelectCustomizationProps & {
        popupStyle: CSSProperties
        popupId: string
        portalTarget: Element | DocumentFragment | null
        virtualOptionsModule: typeof import('../Components/VirtualSelectOptions.tsx') | null
        virtualized: boolean | SelectVirtualizationOptions
        textOverflow: 'truncate' | 'wrap'
        contentWidth: 'trigger' | 'content'
        name: string | undefined
        required: boolean
        disabled: boolean
        readOnly: boolean
        externalError: string | null | undefined
        label: ReactNode
        description: ReactNode
        icon: ReactNode
        placeholder: string | undefined
        className: string | undefined
        classNames: SelectClassNames
        searchable: boolean
        nonce: string | undefined
        renderOption: SharedCustomSelectProps<TValue>['renderOption']
        renderValue: SharedCustomSelectProps<TValue>['renderValue']
        fallbackOption: string | undefined
        multiple: boolean
        omitEmptyFormValue: boolean
        clearable: boolean
        selectedValues: ReadonlyArray<TValue>
        formEntries: ReadonlyArray<{
            key: string
            value: string
        }>
        ariaProps: AriaAttributes
        ariaLabel: string | undefined
        describedBy: string | undefined
        labelledBy: string | undefined
        showClear: boolean
        showRemovableSelectedItems?: boolean
        isOptionDisabled: (option: Option<TValue>) => boolean
        selectedOptions: ReadonlyArray<Option<TValue>>
        selectedLabel: string
        messages: SelectMessages
        triggerId: string
        labelId: string
        descriptionId: string
        errorId: string
        open: boolean
        searchValue: string
        optionEntries: ReadonlyArray<OptionEntry<TValue>>
        filteredOptions: ReadonlyArray<OptionEntry<TValue>>
        selectedEntries: ReadonlyArray<OptionEntry<TValue>>
        selectedRadixValue: string
        hasError: boolean
        resolvedError: string | null
        hasLeftIcon: boolean
        isOptionEqualToValue: (optionValue: TValue, value: TValue) => boolean
        isValueSelected: (value: TValue) => boolean
    }
    handler: {
        option: SelectOptionHandlers<TValue>
        handleVirtualClose: () => void
        handleContentFocusCapture: (event: FocusEvent<HTMLDivElement>) => void
        handleTriggerPointerDown: (event: PointerEvent<HTMLButtonElement>) => void
        handleTriggerClick: () => void
        handleTriggerKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void
        handleSearchChange: (event: ChangeEvent<HTMLInputElement>) => void
        handleSearchPointerDown: (event: PointerEvent<HTMLInputElement>) => void
        handleSearchKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void
        handleFieldBlur: (event: FocusEvent<HTMLDivElement>) => void
        handleInvalid: (event: InvalidEvent<HTMLInputElement>) => void
        handleValueChange: (value: string) => void
        handleClear: () => void
        handleRemoveSelectedItem?: (optionKey: string) => void
        handleOpenChange: (open: boolean) => void
        closeAfterOptionRemoval: () => void
        handleContentKeyDownCapture: (event: KeyboardEvent<HTMLDivElement>) => void
    }
    refs: {
        root: RefObject<HTMLDivElement | null>
        content: RefObject<HTMLDivElement | null>
        overlayContent: RefCallback<HTMLDivElement>
        trigger: RefCallback<HTMLButtonElement>
        searchInput: RefObject<HTMLInputElement | null>
        validationInput: RefObject<HTMLInputElement | null>
        scroll: RefObject<HTMLDivElement | null>
        virtualNavigation: RefObject<SelectVirtualNavigation | null>
        pendingVirtualNavigation: RefObject<Array<KeyboardEvent<HTMLDivElement>>>
    }
}

interface SharedCustomSelectProps<TValue> extends AriaAttributes, SelectCustomizationProps {
    id?: string
    name?: string
    options: ReadonlyArray<Option<TValue>>
    required?: boolean
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    disabled?: boolean
    readOnly?: boolean
    triggerRef?: Ref<HTMLButtonElement>
    onBlur?: FocusEventHandler<HTMLDivElement>
    icon?: ReactNode
    placeholder?: string
    className?: string
    classNames?: SelectClassNames
    searchable?: boolean
    nonce?: string
    renderOption?: (option: Option<TValue>, state: SelectOptionState) => ReactNode
    renderValue?: (options: ReadonlyArray<Option<TValue>>) => ReactNode
    fallbackOption?: string
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
    isOptionEqualToValue?: (optionValue: TValue, value: TValue) => boolean
    getFormValue?: (value: TValue) => string
}
InternalCustomSelectLogicResulttype
  • @rentnerkev/select/types
InternalCustomSelectLogicResult.d.ts
export type InternalCustomSelectLogicResult<TValue> = CustomSelectLogicResult<TValue> & {
    handler: {
        handleRemoveSelectedItem: (optionKey: string) => void
    }
}
SelectProviderLogicResultinterface
  • @rentnerkev/select/types
SelectProviderLogicResult.d.ts
export interface SelectProviderLogicResult {
    state: {
        contextValue: SelectDefaults
    }
}
SelectValueOptionstype
  • @rentnerkev/select/types
SelectValueOptions.d.ts
export type SelectValueOptions<TValue> = Pick<SingleSelectProps<TValue>, SelectValueKeys> | Pick<MultipleSelectProps<TValue>, SelectValueKeys | 'maxSelection'>

type SelectValueKeys = 'value' | 'onValueChange' | 'multiple' | 'options' | 'emptyValue' | 'onClear' | 'getFormValue' | 'isOptionEqualToValue'
SelectValuesResultinterface
  • @rentnerkev/select/types
SelectValuesResult.d.ts
export interface SelectValuesResult<TValue> {
    state: {
        selectedValues: ReadonlyArray<TValue>
        formEntries: ReadonlyArray<{
            key: string
            value: string
        }>
    }
    handler: {
        handleSelectValue: (value: TValue) => void
        handleClearValues: () => void
    }
}
SelectOptionIdentityResultinterface
  • @rentnerkev/select/types
SelectOptionIdentityResult.d.ts
export interface SelectOptionIdentityResult<TValue> {
    state: {
        optionEntries: ReadonlyArray<OptionEntry<TValue>>
    }
}
PackageInfointerface
  • @rentnerkev/select/ai
PackageInfo.d.ts
export interface PackageInfo {
    name: string
    version: string
    description: string
    license: string
    homepage: string
    repository: {
        type: string
        url: string
    }
    exports: Record<string, string | {
        types?: string
        import?: string
        default?: string
    }>
    peerDependencies: Record<string, string>
}
PackageDocumentinterface
  • @rentnerkev/select/ai
PackageDocument.d.ts
export interface PackageDocument {
    path: string
    content: string
}
PackageApiinterface
  • @rentnerkev/select/ai
PackageApi.d.ts
export interface PackageApi {
    package: string
    version: string
    subpaths: Record<string, string>
    declarations: PackageDocument[]
}
PackageSearchMatchinterface
  • @rentnerkev/select/ai
PackageSearchMatch.d.ts
export interface PackageSearchMatch {
    path: string
    line: number
    text: string
}
PackageExampleinterface
  • @rentnerkev/select/ai
PackageExample.d.ts
export interface PackageExample {
    language: string
    code: string
}
getPackageInfofunction
  • @rentnerkev/select/ai
getPackageInfo.d.ts
export function getPackageInfo(): PackageInfo
getPackageDocumentationfunction
  • @rentnerkev/select/ai
getPackageDocumentation.d.ts
export function getPackageDocumentation(document?: 'readme' | 'usage'): PackageDocument
getPackageApifunction
  • @rentnerkev/select/ai
getPackageApi.d.ts
export function getPackageApi(options?: {
    subpath?: string
    symbol?: string
}): PackageApi
searchPackageDocumentationfunction
  • @rentnerkev/select/ai
searchPackageDocumentation.d.ts
export function searchPackageDocumentation(query: string): PackageSearchMatch[]
getPackageExamplesfunction
  • @rentnerkev/select/ai
getPackageExamples.d.ts
export function getPackageExamples(): PackageExample[]
ComboboxBasePropsinterface
  • @rentnerkev/select/combobox/types
ComboboxBaseProps.d.ts
export interface ComboboxBaseProps<T> extends AriaAttributes, SelectCustomizationProps {
    options: ReadonlyArray<T>
    searchValue: string
    onSearchValueChange: (value: string) => void
    getOptionKey: (option: T) => string
    getOptionLabel: (option: T) => string
    getOptionGroup?: (option: T) => string | undefined
    /** Receives a trimmed query the application owns creating and selecting the new option. */
    onCreateOption?: (searchValue: string) => void
    createOptionLabel?: (searchValue: string) => string
    getOptionDescription?: (option: T) => ReactNode
    isOptionDisabled?: (option: T) => boolean
    isOptionEqualToValue?: (option: T, value: T) => boolean
    renderOption?: (option: T, state: {
        selected: boolean
        active: boolean
        disabled: boolean
    }) => ReactNode
    filterMode?: 'external' | 'local'
    loading?: boolean
    loadingText?: ReactNode
    emptyText?: ReactNode
    clearable?: boolean
    id?: string
    name?: string
    getFormValue?: (value: T) => string
    label?: ReactNode
    description?: ReactNode
    error?: string | null
    required?: boolean
    disabled?: boolean
    readOnly?: boolean
    placeholder?: string
    inputRef?: Ref<HTMLInputElement>
    onBlur?: (event: FocusEvent<HTMLDivElement>) => void
    className?: string
    classNames?: SelectClassNames
    locale?: SelectLocale
    messages?: Partial<SelectMessages>
}
SingleComboboxPropsinterface
  • @rentnerkev/select/combobox/types
SingleComboboxProps.d.ts
export interface SingleComboboxProps<T> extends ComboboxBaseProps<T> {
    multiple?: false
    value: T | null
    onValueChange: (value: T | null) => void
}
MultipleComboboxPropsinterface
  • @rentnerkev/select/combobox/types
MultipleComboboxProps.d.ts
export interface MultipleComboboxProps<T> extends ComboboxBaseProps<T> {
    multiple: true
    value: ReadonlyArray<T>
    onValueChange: (value: T[]) => void
}
ComboboxEntryinterface
  • @rentnerkev/select/combobox/types
ComboboxEntry.d.ts
export interface ComboboxEntry<T> {
    option: T
    key: string
    id: string
    label: string
    group?: string
    position?: number
    description: ReactNode
    disabled: boolean
    selected: boolean
}
ComboboxLogicResultinterface
  • @rentnerkev/select/combobox/types
ComboboxLogicResult.d.ts
export interface ComboboxLogicResult<T> {
    state: {
        virtualOptionsModule: typeof import('../Components/VirtualComboboxOptions.tsx') | null
        inputId: string
        listId: string
        hasLabel: boolean
        labelId: string
        descriptionId: string
        errorId: string
        labelledBy: string | undefined
        describedBy: string | undefined
        open: boolean
        activeId: string | undefined
        activeEntry: ComboboxEntry<T> | undefined
        activeIndex: number
        navigationVersion: number
        virtualization: boolean | SelectVirtualizationOptions
        entries: ReadonlyArray<ComboboxEntry<T>>
        messages: SelectMessages
        classNames: SelectClassNames
        controlSize: SelectCustomizationProps['controlSize']
        textOverflow: 'truncate' | 'wrap'
        portalContainer: Element | DocumentFragment | null | undefined
        portalClassName: string | undefined
        popupStyle: CSSProperties
        multiple: boolean
        selectedItems: ReadonlyArray<{
            key: string
            label: string
            disabled: boolean
            removeLabel: string
        }>
        formValues: ReadonlyArray<{
            key: string
            value: string
        }>
        emptySelection: boolean
        formValue: string
        hasError: boolean
        error: string | null | undefined
        loadingText: ReactNode
        emptyText: ReactNode
        showClear: boolean
        canCreate?: boolean
        createLabel?: string
        createId?: string
        createActive?: boolean
    }
    handler: {
        handleChange: (event: ChangeEvent<HTMLInputElement>) => void
        handleFocus: () => void
        handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void
        handleFieldBlur: (event: FocusEvent<HTMLDivElement>) => void
        handleOptionSelect: (entry: ComboboxEntry<T>) => void
        handleOptionActivate: (key: string) => void
        handleKeepFocus: (event: MouseEvent<HTMLElement>) => void
        handleClear: () => void
        handleRemoveSelectedItem: (key: string) => void
        handleInvalid: (event: InvalidEvent<HTMLInputElement>) => void
        handleCreateOption?: () => void
        handleCreateActivate?: () => void
    }
    refs: {
        root: RefObject<HTMLDivElement | null>
        content: RefObject<HTMLDivElement | null>
        popupContent: RefCallback<HTMLDivElement>
        validation: RefObject<HTMLInputElement | null>
        input: RefCallback<HTMLInputElement>
    }
}
InternalComboboxLogicResulttype
  • @rentnerkev/select/combobox/types
InternalComboboxLogicResult.d.ts
export type InternalComboboxLogicResult<T> = ComboboxLogicResult<T> & {
    state: {
        entries: ReadonlyArray<ComboboxEntry<T> & {
            position: number
        }>
    }
}
ComboboxOptionPropsinterface
  • @rentnerkev/select/combobox/types
ComboboxOptionProps.d.ts
export interface ComboboxOptionProps<T> {
    entry: ComboboxEntry<T>
    state: Pick<ComboboxLogicResult<T>['state'], 'activeId' | 'classNames' | 'textOverflow'>
    handler: Pick<ComboboxLogicResult<T>['handler'], 'handleKeepFocus' | 'handleOptionActivate' | 'handleOptionSelect'>
    renderOption: ComboboxProps<T>['renderOption']
    index?: number
    setSize?: number
    measureElement?: RefCallback<HTMLDivElement>
    style?: CSSProperties
}
VirtualComboboxOptionsPropsinterface
  • @rentnerkev/select/combobox/types
VirtualComboboxOptionsProps.d.ts
export interface VirtualComboboxOptionsProps<T> {
    state: Pick<ComboboxLogicResult<T>['state'], 'multiple' | 'listId' | 'labelledBy' | 'entries' | 'activeId' | 'activeIndex' | 'navigationVersion' | 'virtualization' | 'classNames' | 'textOverflow' | 'popupStyle' | 'canCreate' | 'createId' | 'createLabel' | 'createActive'>
    handler: ComboboxOptionProps<T>['handler'] & Pick<ComboboxLogicResult<T>['handler'], 'handleCreateOption' | 'handleCreateActivate'>
    renderOption: ComboboxProps<T>['renderOption']
    loading?: boolean
    ariaLabel: string
}
ComboboxCreateOptionPropsinterface
  • @rentnerkev/select/combobox/types
ComboboxCreateOptionProps.d.ts
export interface ComboboxCreateOptionProps {
    state: Pick<ComboboxLogicResult<unknown>['state'], 'createId' | 'createLabel' | 'createActive' | 'classNames' | 'entries'>
    handler: Pick<ComboboxLogicResult<unknown>['handler'], 'handleCreateOption' | 'handleCreateActivate' | 'handleKeepFocus'>
}
VirtualComboboxOptionsLogicResultinterface
  • @rentnerkev/select/combobox/types
VirtualComboboxOptionsLogicResult.d.ts
export interface VirtualComboboxOptionsLogicResult<T> {
    state: {
        rows: ReadonlyArray<{
            item: VirtualItem
            entry: ComboboxEntry<T>
        }>
        totalSize: number
        height: number
    }
    refs: {
        viewport: RefObject<HTMLDivElement | null>
    }
    virtualizer: ReactVirtualizer<HTMLElement, HTMLElement>
}