Skip to content
Nana UI

Feedback & Status

Tag

A compact label for categories, keywords, or filters. Optionally removable.

View .md Download
Design
Design Active Pending Furnished Parking Pet friendly

Install the package for a versioned dependency:

npm install @nana-tec/ui-components

Or copy the source in and own it:

npx @nana-tec/ui add tag --framework web-components
npx @nana-tec/ui add tag --framework svelte

Lands in src/lib/components/ui/tag/ as NanaTag.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

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.

<nana-tag variant="primary">Design</nana-tag>
Primary Success Warning Danger Info Neutral

Properties

PropertyAttributeTypeDefaultDescription
disableddisabledbooleanfalseDisable the tag and its remove button.
outlineoutlinebooleanfalseOutline style with a transparent fill.
removableremovablebooleanfalseShow a remove button.
shapeshapeTagShape'rounded'Corner shape.
sizesizeTagSize'md'Tag size.
variantvariantTagVariant'neutral'Visual colour variant.

Events

EventDescription
nana-removeEmitted when the remove button is activated.

Slots

SlotDescription
(default)The tag's text content.

CSS parts

PartDescription
::part(base)The component's host container.
::part(content)The text content wrapper.
::part(remove-button)The remove button (when removable).

CSS custom properties

PropertyDescription
--nana-tag-bgBackground colour.
--nana-tag-colorText colour.
--nana-tag-borderBorder colour.

NanaTag

PropTypeDefault
variantTagVariant'neutral'
sizeTagSize'md'
shapeTagShape'rounded'
outlinebooleanfalse
disabledbooleanfalse
removeLabelstring''
onRemove() => void
childrenSnippet

Also accepts Omit<HTMLAttributes<HTMLSpanElement>, 'class'>.