Tag Group

A Tag Group component is a UI element that displays a collection of tags or labels, allowing users to select, filter, or remove tags. It supports multiple selection modes and removable tags, making it ideal for categorization, filtering, and labeling interfaces.

Demo

Selectable:

React
Vue
Angular
Svelte
SolidJS

Removable:

React
Vue
Angular
Svelte
SolidJS

Usage

import { useState } from 'react';
import { NTagGroup } from '@nayan-ui/react';
const items = [
{ id: 'react', label: 'React' },
{ id: 'vue', label: 'Vue' },
{ id: 'angular', label: 'Angular' }
];
const TagGroup = () => {
const [selected, setSelected] = useState(new Set(['react']));
return (
<NTagGroup
items={items}
selectionMode="multiple"
selectedKeys={selected}
onSelectionChange={setSelected}
/>
);
};
export default TagGroup;

Attributes

NameTypeDefaultDetails
itemsNTagItem[]RequiredList of tag items with id and label.
selectionMode'none' | 'single' | 'multiple''none'Selection mode.
selectedKeysIterable<string>OptionalSelected tag keys.
onSelectionChange(keys: Selection) => voidOptionalCallback when selection changes.
onRemove(keys: Set<string>) => voidOptionalCallback when tags are removed.
size'sm' | 'md' | 'lg''md'Tag size.
variant'default' | 'surface''default'Tag variant.
isDisabledbooleanfalseDisables the tag group.
classNamestring' 'Additional CSS classes.