Skip to content

TokenizedSearch

import { TokenizedSearch } from '@requence/tokenized-search'
PropTypeDefaultDescription
tokens(TokenizedSearchTokenDefinition | null)[][]Token key definitions
valuestringControlled search value
defaultValuestring''Default value (uncontrolled)
onChange(value, segments) => voidCalled on text change
onSearch(segments, rawText) => voidCalled on Enter submit
smallbooleanfalseSmall variant
classNamestringRoot container class
onKeyDown(event) => voidKey handler (when dropdown is closed)
refRef<TokenizedSearchHandle>Imperative handle
autoFocusbooleanfalseAuto-focus on mount
negationLabelstring'not'Negation prefix label for i18n
childrenReactNodeSlot sub-components for styling
interface TokenizedSearchHandle {
submit: () => void
}

Access via ref:

const searchRef = useRef<TokenizedSearchHandle>(null)
<TokenizedSearch ref={searchRef} ... />
// Programmatic submit
searchRef.current?.submit()

All slots accept a className prop that is merged with internal base styles via tailwind-merge. Some slots also accept children for content.

SlotclassNamechildrenDescription
<Input>Editor area containerNested input slotsWraps the TipTap editor and clear button
<ClearButton>Button stylingIcon elementClear button (hidden when editor is empty)
<SubmitButton>Button stylingIcon elementSubmit button (supports data-[dirty]: variant)
<Dropdown>Container stylingNested dropdown slotsDropdown container

Must be children of <Input>.

SlotclassNamechildrenDescription
<Placeholder>Text stylingPlaceholder textShown when editor is empty
<TokenKey>Mark stylingInline mark for token keys (e.g. Status:)
<TokenValue>Mark stylingInline mark for token values (e.g. Active)
<TokenNegation>Mark stylingInline mark for negation prefix (e.g. not:)

Must be children of <Dropdown>.

SlotclassNamechildrenDescription
<DropdownOption>Option stylingRegular dropdown option (aria-selected: for highlight)
<DropdownNotOption>Option styling“Not” option for negatable tokens (aria-selected: for highlight)
<DropdownSeparator>Border/divider stylingSeparator between options and “Not” option
<HighlightMatch>Text colorMatched substring within options
<FilterByLabel>Text stylingLabel text (e.g. “Filter by”)Header above key suggestions
<SuggestionIcon>Icon wrapper stylingIcon container in key suggestions
<EmptyMessage>Text stylingMessage textShown when no options match
<Loader>Container stylingSpinner + textShown while loading async options
AttributeElementWhen set
aria-selected<DropdownOption>, <DropdownNotOption>Option is highlighted via keyboard
data-dirty<SubmitButton>Query text differs from last submission