Skip to content

TokenizedSearch

import { TokenizedSearch } from '@requence/tokenized-search'
PropTypeDefaultDescription
tokens(TokenizedSearchTokenDefinition | null)[][]Token key definitions
valuestring—Controlled search value
defaultValuestring''Default value (uncontrolled)
onChange(value, segments, expression) => void—Called on text change. expression is the parsed boolean tree
onSearch(segments, rawText, expression) => void—Called on Enter submit. expression is the parsed boolean tree
autoCommitbooleanfalseFires onSearch on every change (with the technical query, once async options resolve) instead of only on Enter/submit, and hides the submit button
complexbooleanfalseEnable boolean operators (AND, OR) and grouping parentheses. When off, they are treated as literal text. See Boolean Operators
smallbooleanfalseSmall variant
disabledbooleanfalseDisables editing, dropdowns, and submit; greys out the input
classNamestring—Root container class
onKeyDown(event) => void—Key handler (when dropdown is closed)
refRef<TokenizedSearchHandle>—Imperative handle
autoFocusbooleanfalseAuto-focus on mount
childrenReactNode—Slot 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]: and aria-busy variants). Not rendered when autoCommit is set
<Dropdown>Container stylingNested dropdown slotsDropdown container

Must be children of <Input>.

SlotclassNamechildrenDescription
<Placeholder>Text stylingPlaceholder textShown when editor is empty
<TokenKey>Mark styling—Inline mark for token keys (e.g. Status:)
<TokenValue>Mark styling—Inline mark for token values (e.g. Active)
<TokenNegation>Mark styling—Inline mark for negation prefix (e.g. not:)
<TokenOperator>Mark styling—Inline mark for boolean operators and parens (AND, OR, (, )). Gets data-invalid when the operator is part of a malformed expression — target with the data-[invalid]:* variant

Must be children of <Dropdown>.

SlotclassNamechildrenDescription
<DropdownOption>Option styling—Regular dropdown option (aria-selected: for highlight)
<DropdownNotOption>Option stylingNegation label (default "not")“Not” option for negatable tokens (aria-selected: for highlight)
<DropdownSeparator>Border/divider styling—Separator between options and “Not” option
<HighlightMatch>Text color—Matched substring within options
<FilterByLabel>Text stylingLabel text (e.g. “Filter by”)Header above key suggestions
<OperationLabel>Text stylingLabel text (e.g. “Operation”)Header above the AND / OR suggestions (complex mode)
<SuggestionIcon>Icon wrapper styling—Icon 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
aria-busy<SubmitButton>Async token values are being resolved (e.g. after paste)
data-resolving<SubmitButton>Same as aria-busy — alternative CSS hook
data-disabled, aria-disabledRoot containerThe disabled prop is set — target with data-disabled:* Tailwind variants
data-invalidRoot containerThe current query is a malformed boolean expression — target with data-invalid:* Tailwind variants
data-disabled<SubmitButton>The disabled prop is set (button also gets the native disabled attribute)