Skip to content
← Inventory

TagSelector

TagSelector - A multi-select tag component with search, create, edit, delete, and reorder capabilities.

Usage

import { TagColor, TagData, TagSelector, TagSelectorContent, TagSelectorContextValue, TagSelectorItem, TagSelectorList, TagSelectorProps, TagSelectorSearch, TagSelectorTrigger, TagSelectorTriggerRenderProps, useTagSelectorContext } from "@desk/ui/components/tag-selector";

Best practices

  • The CRUD affordances are gated — onCreateTag/onEditTag/onDeleteTag/onReorder do nothing unless you also set the matching allowCreate/allowManage/allowReorder flag.

  • value/onChange carry the selected TagData[] and are required — TagSelector is controlled; supply the full option set via tags.

  • A custom trigger render-prop is wrapped in PopoverTrigger asChild, so return a single element that forwards its ref/props (e.g. a Button).

  • Use singleSelect when only one tag may be chosen; for a fixed, non-editable list prefer Combobox/multi-Select and reserve TagSelector for managing the tag set itself.

Props

TagSelector

PropTypeDefaultDescription
allowCreateboolean

Allow creating new tags

allowManageboolean

Allow editing/deleting tags

allowReorderboolean

Allow reordering tags

classNamestring
colorPaletteTagColor[]

Available colors for the color picker

coverTriggerboolean

Whether the popover overlaps the trigger instead of appearing below it

disabledboolean

Disabled state

emptyMessagestring

Empty state message

maxVisibleTagsnumber

Cap how many selected chips the trigger renders. When set and the selection exceeds it, only the first N chips show, followed by a +N overflow count pill. Undefined (default) renders every chip (wrapping or scrolling per wrapTags). Handy for fixed-width table cells.

onChange(required)(tags: TagData[]) => void

Called when selection changes

onCreateTag(label: string, color?: TagColor) => Promise<TagData>

Called when a new tag is created

onDeleteTag(id: string) => Promise<void>

Called when a tag is deleted

onEditTag(id: string, newLabel: string, color?: TagColor) => Promise<void>

Called when a tag is edited

onOpenChange(open: boolean) => void

Called when open state changes

onReorder(tags: TagData[]) => void

Called when tags are reordered

onSearch(query: string) => Promise<TagData[]>

Called when tags list should be refetched (e.g., on search)

openboolean

Controlled open state

reorderAnnouncementsAnnouncements

Override the drag-and-drop screen-reader announcements used while reordering tags. Follows

placeholderstring

Placeholder text

searchPlaceholderstring

Search input placeholder

showColorPickerboolean

Show color picker swatches when creating/editing tags

singleSelectboolean

Single-select mode: only one tag can be selected at a time

sizeimport("../pill").PillSize

Component size

tagsTagData[]

All available tags

trigger(props: TagSelectorTriggerRenderProps) => React.ReactNode

Custom trigger render function. When provided, replaces the default trigger.

truncateChipsboolean

Opt-in per-chip truncation. Long labels ellipsize (CSS truncate + a max-width) instead of pushing the trigger/search row wider, keeping the +N overflow pill and search input visible. Default false = chips keep their natural width.

value(required)TagData[]

Currently selected tags

wrapTagsboolean

Whether tags wrap (true) or scroll horizontally (false)

TagSelectorContent

PropTypeDefaultDescription
children(required)React.ReactNode
classNamestring

TagSelectorItem

PropTypeDefaultDescription
selected(required)boolean

Whether this tag is selected

tag(required)TagData

The tag data

TagSelectorList

PropTypeDefaultDescription
classNamestring
emptyMessagestring

Custom empty state message

TagSelectorSearch

PropTypeDefaultDescription
classNamestring
placeholderstring

Placeholder text for search input

TagSelectorTrigger

PropTypeDefaultDescription
classNamestring
placeholderstring

Placeholder text when no tags selected

Also exports

  • typeTagColor
  • interfaceTagData
  • interfaceTagSelectorContextValue
  • interfaceTagSelectorProps
  • interfaceTagSelectorTriggerRenderProps
  • constuseTagSelectorContext