- Implementation
- SelectField Props
- SelectFieldSync Props
- SelectFieldOption Type
Overview
The select field family includes two components for different use cases:SelectField— For async data loading with support for pagination (page-based, offset-based, or group-based lazy loading)- Includes automatic debouncing of the search input (configurable via the
debounceMsprop) - Includes automatic caching of the search input (configurable via the
cacheprop)
- Includes automatic debouncing of the search input (configurable via the
SelectFieldSync— For client-side filtering of static option arrays
SelectFieldSync (Static Options)
UseSelectFieldSync when you have a static list of options that can be filtered client-side.Filtering and Sorting
By default,SelectFieldSync uses match-sorter to filter options by their label and searchText fields. Results are also ranked by match quality, so the best matches appear first. Before any search is performed, options appear in the order they are supplied.
You can customize this behavior in two ways:Using match-sorter options
Pass a match-sorter options object to customize the default filtering and sorting behavior (e.g., change which keys are matched or adjust ranking):Using a custom filter function
Pass a function for full control over both filtering and sort order. The returned array determines the exact order options appear in the dropdown:SelectField (Async Loading)
UseSelectField when options need to be fetched from an API or when dealing with large datasets that require server-side filtering.Basic Async Loading
Lazy Loading Modes
SelectField supports three lazy loading modes for paginated data:Page-based Pagination
Offset-based Pagination
Group-based Loading
For loading grouped options incrementally:Display Modes
Control how the options menu is displayed using thedisplayMenuAs prop:Caching
SelectField caches loadOptions results by default. Configure caching behavior:Clearing the Cache
Use a ref to imperatively clear the cache:Invalidating Options
Callinvalidate() to clear the cache and reload options from the data source. Use this when the underlying data has changed and the component needs to reflect the update:SelectFieldSync handles this automatically when its options prop changes.Initial Load Behavior
Control when options are first loaded with theinitialLoad prop:Field States
Error State
Display validation errors using theerror prop:Hint and Description
Provide additional context withhint and description:Required Field
Mark a field as required with therequired prop:Disabled and ReadOnly
Whendisabled is set, users cannot interact with the field.readOnly is set, users can see what options exist but cannot change the current value.Prefix and Suffix
Add content before or after the input withprefix and suffix:Markdown in labels
Thelabel prop supports inline markdown: bold (**text**), italic (*text*), bold and italic (***text***), highlight (==text==), and code (`text`).Hide the label
UsehideLabel to visually hide the label. The label string is converted to an aria-label on the input so it remains accessible to screen readers — any inline markdown is stripped to plain text.Disabled Options
Individual options can be disabled by settingdisabled: true on the option:Pinned Options
Pin frequently used or suggested options above the list using thepinned prop. Each pinned section requires a label and an options value, which can be a static array or a dynamic loader function.Static Pinned Options
Pass an object withlabel and a static options array:Dynamic Pinned Options
Pass a function asoptions to compute pinned options based on the current search value. This is useful for AI-powered suggestions or context-aware recommendations:searchReactive: false to call the loader once and reuse the result across all search values:Multiple Pinned Sections
Pass an array of pinned section objects:Grouping Options
Options can be organized into visual groups by adding agroup property to each option. Groups appear as labeled sections in the dropdown.Basic Grouping
Add agroup property to options and provide a groupToString function to display group labels:Group Sorting
UsegroupSorter to control the order of groups. By default, groups appear in the order they are first encountered in the options array. With groupSorter, you can apply custom sorting (e.g., alphabetical, numerical priority).This prop is available on SelectFieldSync and non-lazy SelectField:Mixed Grouped and Ungrouped Options
Options without agroup property appear after all grouped sections:Virtualization
By default, all dropdown options render to the DOM at once. This works well for typical lists but degrades performance with very large option sets as the browser must lay out and paint thousands of elements. Passvirtualize to enable windowed rendering, which only renders the items currently visible in the scroll viewport plus a small overscan buffer.Consider enabling virtualize when the dropdown feels sluggish to open or keyboard navigation becomes laggy. These symptoms typically appear around 200–500 items depending on device performance and item complexity (e.g., items with descriptions are heavier). For smaller lists, the default rendering path is sufficient and avoids the overhead of virtual positioning.Virtualization works with all existing features including lazy loading, pinned options, grouping, and keyboard navigation.Adding New Items
Provide anonAddNewItem handler to render an “Add new item” button below the option list. This affordance lets users create a value that does not exist yet — a new customer, tag, or category — quickly from the field.The button sits in a footer region inside the menu. Clicking or activating it via keyboard closes the menu and invokes the onAddNewItem handler with the current search text.From here, it is your responsibility to launch a Dialog (or Drawer, or any other overlay) for collecting the new item’s details, append the result to the option source, invalidate the cache, and update selection state.You may pair onAddNewItem with addItemLabel to control the button text. The label accepts a static node or a function of the current search text — for example, returning Add "foo" when the user has typed foo.Call
invalidate() on the imperative handle after appending the new option.
This clears the cached search results and forces a refetch the next time the
menu opens, so the new item appears immediately. clearCache() alone wipes
the cache but keeps the previously displayed options on screen until
something else triggers a reload.Disabling Search
PassdisableSearch to replace the searchable text input with a non-editable select trigger. The field uses the listbox ARIA pattern instead of combobox, providing a simpler interaction when typing to filter adds no value.This is useful when the option list is short and well-known or you are integrating with an API that does not support search.