Marvz UI
Components

Tags input

Tag inputs render tags inside an input, followed by an actual text input. By default, tags are added when text is typed in the input field and the Enter or Comma key is pressed. Throughout the interaction, DOM focus remains on the input element.

TODO: proper styling

hello
world

Installation

pnpx shadcn@latest add https://ui.marviuz.me/r/tags-input.json

Usage

import { X } from 'lucide-react';
import {
  TagsInputInput,
  TagsInputItem,
  TagsInputItemDeleteTrigger,
  TagsInputItemInput,
  TagsInputItemPreview,
  TagsInputItems,
  TagsInputProvider,
  TagsInputRoot,
} from './tags-input';
<TagsInputProvider defaultValue={['hello', 'world']}>
  <TagsInputRoot>
    <TagsInputItems
      render={(item, index) => (
        <TagsInputItem index={index} key={index} value={item}>
          <TagsInputItemPreview index={index} value={item}>
            {item}
          </TagsInputItemPreview>
          <TagsInputItemDeleteTrigger index={index} value={item}>
            <X />
          </TagsInputItemDeleteTrigger>
          <TagsInputItemInput index={index} value={item} />
        </TagsInputItem>
      )}
    />
    <TagsInputInput />
  </TagsInputRoot>
</TagsInputProvider>

On this page