Display

Tag group

A set of tags, such as the filters on a search, each of which can be removed. To type new tags, use Tag input.

Installation

npx sinaui add tag-group

Examples

Search filters

Remove a tag with its ×, or focus it and press Backspace. The others slide over to close the gap.

  • Optics
  • Baghdad
  • 9th century
  • In Arabic
  • Has scans
<script lang="ts">
	import Button from '#lib/ui/Button.svelte';
	import TagGroup from '#lib/ui/TagGroup.svelte';

	const all = [
		{ id: 'optics', label: 'Optics' },
		{ id: 'baghdad', label: 'Baghdad' },
		{ id: 'c9', label: '9th century' },
		{ id: 'arabic', label: 'In Arabic' },
		{ id: 'scans', label: 'Has scans' }
	];
	let filters = $state([...all]);
</script>

<div class="filters">
	<TagGroup
		label="Filters"
		tags={filters}
		onremove={(t) => (filters = filters.filter((f) => f.id !== t.id))}
		empty="No filters: showing everything."
	/>
	<div class="row">
		<Button variant="ghost" size="sm" disabled={!filters.length} onclick={() => (filters = [])}
			>Clear all</Button
		>
		<Button
			variant="ghost"
			size="sm"
			disabled={filters.length === all.length}
			onclick={() => (filters = [...all])}
		>
			Reset
		</Button>
	</div>
</div>

<style>
	.filters {
		display: grid;
		gap: 0.75rem;
		max-inline-size: min(26rem, 100%);
	}
	/* Centered in the example, lines of tags included. */
	.filters :global(.tags),
	.row {
		justify-content: center;
	}
	.row {
		display: flex;
		gap: 0.25rem;
	}
</style>

Props

PropTypeDefault
labelstringrequired
tags{ id, label }[]required
onremove(tag) => void; without it, tags can't be removed
emptystring, shown with no tags

Accessibility

  • Each removable tag's button is named “Remove Optics”.
  • One tab stop; arrow keys move between tags, Backspace or Delete removes one.
  • After a removal, focus moves to the next tag, and the removal is announced.
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme