Skip to content

Tokenizer

@astryxdesign/core v0.7.1 · Tokenizer

Tokenizer Props ​

NameTypeDefaultDescription
modelValueT[][]Selected items.
searchSourceSearchSource<T>RequiredStatic or async source.
labelstringRequiredField label.
descriptionstring—Helper text under the label.
labelTooltipstring—Tooltip text on an info icon next to the label.
isLabelHiddenbooleanfalseHides the label visually while keeping it accessible. labelHidden is the older name; either one hides it.
containerClass / controlClassclass—Field shell and input box. A root class lands on the box, not the native input. Item actions behave like Typeahead.
placeholderstringAdd… / 添加…Input placeholder. Shown only while no tokens are selected.
hasCreatebooleanfalseLet users turn free text into a new token. A "Create …" row appears for text that matches nothing else, and the change type is create.
creatablebooleanfalseLegacy name for hasCreate. Either one turns it on.
overflow'none' | 'unfocused-inline' | 'unfocused-layer''none'Whether blur collapses the tokens to one line with +N.
maxEntriesnumber—Maximum number of tokens. The input becomes read-only at the limit.
debounceMsnumber150Wait after typing before searching.
minQueryLengthnumber1Shortest query that gets searched, counted in visible characters. Below it nothing is searched and the menu stays closed — unless hasCreate is on, because a "Create …" row comes from the typed text and costs no search.
hasEntriesOnFocusbooleanfalseShow results on focus before the user types.
showOnFocusbooleanfalseLegacy name for hasEntriesOnFocus. Either one turns it on.
hasAutoFocusbooleanfalseFocus the input on mount.
menuWidthnumber—Requested dropdown width in pixels. Never narrower than the field, and clamped to the viewport.
maxMenuItemsnumber10Maximum number of results in the menu. A "Create …" row is offered on top of them.
hasClearbooleanfalseShow a clear-all button that removes every token.
clearablebooleanfalseLegacy name for hasClear. Either one turns it on.
emptySearchTextstring | null'No results found' / '未找到结果'Text shown when the query matched nothing. null means "not given" and falls through to the default; an empty string renders nothing. For rich content use the empty slot.
emptyTextstring | null—Legacy name for emptySearchText.
disabledbooleanfalseDisable the field and every token interaction.
disabledMessagestring—Explains why the field is disabled. With disabled, the input stays focusable through aria-disabled and readonly, and the message shows as a tooltip on hover or keyboard focus.
disabledReasonstring—Legacy name for disabledMessage.
status'default' | 'success' | 'warning' | 'error''default'Status style.
statusMessagestring—Status text under the field.
size'sm' | 'md' | 'lg''md'Input and token size.
requiredbooleanfalseMarks the field as required.
optionalbooleanfalseShows an optional indicator on the label.
namestring—Form field name. Each selected id is submitted once.
widthnumber | string—Width of the whole field (number = pixels, string used as-is).

Tokenizer Emits ​

NameParametersDescription
update:modelValuevalue: T[]Emitted when the selected items change.
changevalue: T[], change: TokenizerChangeIncludes the change type: add, create, remove, or clear.
changeQueryquery: stringEmitted when the query text changes.
searchquery: stringLegacy name for changeQuery. Both fire.
openChangeisOpen: booleanEmitted when the menu opens or closes.
focusevent: FocusEventEmitted when focus enters the field from outside.
blurevent: FocusEventEmitted when focus leaves the whole field, not just the input.

Tokenizer Slots ​

NameParametersDescription
icon—Icon at the start of the field, before any token.
end—Content at the end of the field, such as a button or a result count.
token{ item, remove }Custom selected token. Replaces the default Token.
item{ item, isActive, isSelected }Custom menu row. Replaces the default TypeaheadItem.
empty—Custom empty state.

Native attributes and listeners that are not listed above land on the input element, so @keydown, @paste and aria-* work as they would on a plain <input>. A keydown listener runs before the internal token navigation; call event.preventDefault() to skip it.