Feedback & Status
Tag
A compact label for categories, keywords, or filters. Optionally removable.
Preview
Section titled “Preview”<nana-tag variant="primary">Design</nana-tag> <script lang="ts">
import { NanaTag } from '$lib/components/ui/tag';
let tags = $state(['Furnished', 'Parking', 'Pet friendly']);
</script>
<div class="flex flex-wrap items-center gap-2">
<NanaTag variant="primary">Design</NanaTag>
<NanaTag variant="success" shape="pill">Active</NanaTag>
<NanaTag variant="warning" outline>Pending</NanaTag>
{#each tags as tag (tag)}
<NanaTag removeLabel={tag} onRemove={() => (tags = tags.filter((t) => t !== tag))}
>{tag}</NanaTag
>
{/each}
</div> Installation
Section titled “Installation”Install the package for a versioned dependency:
npm install @nana-tec/ui-componentsOr copy the source in and own it:
npx @nana-tec/ui add tag --framework web-componentsnpx @nana-tec/ui add tag --framework svelteLands in src/lib/components/ui/tag/ as NanaTag.svelte, styled with Tailwind
classes that resolve to the design tokens. Requires Tailwind v4.
Import
Section titled “Import”
Import the autoloader once, in your app's entry point. Every <nana-*> tag then works anywhere, and
each component downloads only the first time a page uses it:
import "@nana-tec/ui-components/autoloader";import "@nana-tec/ui-components/theme";The second line gives every component the Nana look and the design tokens behind it. Leave it out to style the components entirely yourself.
Import a component directly when it must be ready at once: on screen at first paint, or when you call its methods straight away. The two mix freely:
import "@nana-tec/ui-components/tag";
Copied in with npx @nana-tec/ui add tag? Import your project's own
@/lib/nana-ui/autoloader.js once instead; the CLI keeps it up to date.
<script lang="ts"> import { NanaTag } from '$lib/components/ui/tag';</script>
<NanaTag variant="success">Paid</NanaTag><NanaTag removeLabel="Parking" onRemove={() => remove('parking')}>Parking</NanaTag>Give it onRemove and it grows a remove button, named “Remove” plus
removeLabel for screen readers.
Basic usage
Section titled “Basic usage”<nana-tag variant="primary">Design</nana-tag>Variants
Section titled “Variants”<nana-tag variant="primary">Primary</nana-tag>
<nana-tag variant="success">Success</nana-tag>
<nana-tag variant="warning">Warning</nana-tag>
<nana-tag variant="danger">Danger</nana-tag>
<nana-tag variant="info">Info</nana-tag>
<nana-tag variant="neutral">Neutral</nana-tag> Properties
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
disabled | disabled | boolean | false | Disable the tag and its remove button. |
outline | outline | boolean | false | Outline style with a transparent fill. |
removable | removable | boolean | false | Show a remove button. |
shape | shape | TagShape | 'rounded' | Corner shape. |
size | size | TagSize | 'md' | Tag size. |
variant | variant | TagVariant | 'neutral' | Visual colour variant. |
Events
| Event | Description |
|---|---|
nana-remove | Emitted when the remove button is activated. |
Slots
| Slot | Description |
|---|---|
(default) | The tag's text content. |
CSS parts
| Part | Description |
|---|---|
::part(base) | The component's host container. |
::part(content) | The text content wrapper. |
::part(remove-button) | The remove button (when removable). |
CSS custom properties
| Property | Description |
|---|---|
--nana-tag-bg | Background colour. |
--nana-tag-color | Text colour. |
--nana-tag-border | Border colour. |
NanaTag
| Prop | Type | Default |
|---|---|---|
variant | TagVariant | 'neutral' |
size | TagSize | 'md' |
shape | TagShape | 'rounded' |
outline | boolean | false |
disabled | boolean | false |
removeLabel | string | '' |
onRemove | () => void | |
children | Snippet |
Also accepts Omit<HTMLAttributes<HTMLSpanElement>, 'class'>.