Primitives
Tag
Compact chip with color variants, an optional dot, and a removable close button.
Motionnone (wrap in AnimatePresence for removal)
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { Tag, tagVariants } from "kineto/tag";Preview
ActiveDesignEngineeringProductResearch
tsx
"use client";
import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { X } from "lucide-react";
import { cn } from "@/lib/cn";
const tagVariants = cva(
"inline-flex items-center gap-1.5 rounded-md border px-2 py-0.5 text-xs font-medium",
{
variants: {
variant: {
default: "border-border bg-card text-foreground",
brand: "border-brand/30 bg-brand/10 text-brand",
success: "border-success/30 bg-success/10 text-success",
warning: "border-warning/30 bg-warning/10 text-warning",
destructive: "border-destructive/30 bg-destructive/10 text-destructive",
},
},
defaultVariants: { variant: "default" },
}
);
export interface TagProps
extends React.HTMLAttributes<HTMLSpanElement>,
VariantProps<typeof tagVariants> {
/** Show a leading status dot. */
dot?: boolean;
/** Render a trailing close button that calls this handler. */
onRemove?: () => void;
}
const Tag = React.forwardRef<HTMLSpanElement, TagProps>(
({ className, variant, dot = false, onRemove, children, ...props }, ref) => (
<span ref={ref} className={cn(tagVariants({ variant }), className)} {...props}>
{dot ? <span className="size-1.5 rounded-full bg-current" aria-hidden /> : null}
{children}
{onRemove ? (
<button
type="button"
onClick={onRemove}
aria-label="Remove"
className="-mr-0.5 ml-0.5 inline-flex size-3.5 items-center justify-center rounded-sm opacity-60 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
<X className="size-3" strokeWidth={2.5} />
</button>
) : null}
</span>
)
);
Tag.displayName = "Tag";
export { Tag, tagVariants };src/components/ui/tag.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "brand" | "success" | "warning" | "destructive" | "default" | Color. |
| dot | boolean | — | Leading status dot. |
| onRemove | () => void | — | Renders a trailing close button. |