Homelogologo
Sponsor

TagsInput

A component that allows users to enter multiple values as tags.

Usage

The TagsInput component is a compound component used for entering and managing a list of tags.

import { TagsInput, Button, Icon } from "@elemnts-ui/react"; <TagsInput.Root defaultValue={["React", "TypeScript"]}> <TagsInput.Label>Frameworks</TagsInput.Label> <TagsInput.Control> <TagsInput.Context> {({ value }) => value.map((item, index) => ( <TagsInput.Item key={index} index={index} value={item}> <TagsInput.ItemPreview> <TagsInput.ItemText>{item}</TagsInput.ItemText> <TagsInput.ItemDeleteTrigger asChild> <Button variant="tertiary" size="xs"> <Icon icon="tabler:x" width="12" height="12" /> </Button> </TagsInput.ItemDeleteTrigger> </TagsInput.ItemPreview> <TagsInput.ItemInput /> </TagsInput.Item> )) } </TagsInput.Context> <TagsInput.Input placeholder="Add tag..." /> </TagsInput.Control> </TagsInput.Root>;

Clearable

Use the TagsInput.ClearTrigger to allow users to remove all tags at once.

API Reference

TagsInput

The root component that manages the tags input state.

PropTypeDefault
addOnPastebooleanfalse
allowDuplicatesbooleanfalse
allowOverflowboolean-
asChildbooleanfalse
autoFocusboolean-
blurBehavior"clear" | "add"-
defaultInputValuestring-
defaultValuestring[]-
delimiterstring | RegExp","
disabledboolean-
editablebooleantrue
formstring-
idstring-
idsPartial<{ root: string; input: string; hiddenInput: string; clearBtn: string; label: string; control: string; item: (opts: ItemProps) => string; itemDeleteTrigger: (opts: ItemProps) => string; itemInput: (opts: ItemProps) => string }>-
inputValuestring-
invalidboolean-
maxnumberInfinity
maxLengthnumber-
namestring-
onFocusOutside(event: FocusOutsideEvent) => void-
onHighlightChange(details: HighlightChangeDetails) => void-
onInputValueChange(details: InputValueChangeDetails) => void-
onInteractOutside(event: InteractOutsideEvent) => void-
onPointerDownOutside(event: PointerDownOutsideEvent) => void-
onValueChange(details: ValueChangeDetails) => void-
onValueInvalid(details: ValidityChangeDetails) => void-
placeholderstring-
readOnlyboolean-
requiredboolean-
sanitizeValue(value: string) => string(value) => value.trim()
translationsIntlTranslations-
validate(details: ValidateArgs) => boolean-
valuestring[]-

TagsInputLabel

The label for the tags input.

PropTypeDefault
asChildbooleanfalse

TagsInputControl

Wraps the tags and input elements.

PropTypeDefault
asChildbooleanfalse

TagsInputInput

The text input used to add tags.

PropTypeDefault
asChildbooleanfalse

TagsInputItem

Wraps an individual tag.

PropTypeDefault
indexstring | numberrequired
valuestringrequired
asChildbooleanfalse
disabledboolean-

TagsInputItemPreview

Displays an individual tag when it is not being edited.

PropTypeDefault
asChildbooleanfalse

TagsInputItemText

Displays the value of an individual tag.

PropTypeDefault
asChildbooleanfalse

TagsInputItemDeleteTrigger

Removes an individual tag.

PropTypeDefault
asChildbooleanfalse

TagsInputClearTrigger

Removes all tags.

PropTypeDefault
asChildbooleanfalse