Documentation / Data
Chip
A compact tag for a status, a category, an active filter or a recipient. Six semantic colours (default, primary, success, warning, error, info), four variants (solid, outlined, soft, dot) and three sizes.
The content goes in as label or as children. closable adds a remove button that calls onClose without propagating the click; clickable and selected give it the look of an interactive filter. For a filter to be reachable from the keyboard, render it as as="button": it does not submit the form it is in and, with closable, the cross is a second button beside the first, in the same pill.
Examples
Basic usage
A label, a semantic colour.
import { Chip } from "@synertech/ui";
export function Basic() {
return (
<div className="flex flex-wrap gap-2">
<Chip label="Brouillon" />
<Chip label="Publié" color="success" />
<Chip label="Archivé" color="warning" />
</div>
);
}Variants and sizes
soft for dense lists, outlined to stay discreet, dot for a status.
import { Chip } from "@synertech/ui";
export function Variants() {
return (
<div className="flex flex-wrap items-center gap-2">
<Chip label="Solid" color="primary" variant="solid" size="sm" />
<Chip label="Outlined" color="primary" variant="outlined" />
<Chip label="Soft" color="primary" variant="soft" />
<Chip label="En ligne" color="success" variant="dot" size="lg" />
<Chip label="Carré" color="info" variant="soft" rounded="md" />
</div>
);
}Icon and avatar
icon sits before the label; avatar, which takes precedence, rounds it into a pill.
import { Avatar, Chip } from "@synertech/ui";
const TagIcon = () => (
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} aria-hidden="true">
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M7 7h.01M7 3h5l8.5 8.5a2 2 0 010 2.83l-5.17 5.17a2 2 0 01-2.83 0L4 11V6a3 3 0 013-3z"
/>
</svg>
);
export function WithIconAndAvatar() {
return (
<div className="flex flex-wrap items-center gap-2">
<Chip icon={<TagIcon />} label="Comptabilité" variant="soft" color="info" />
<Chip avatar={<Avatar fallback="CM" size="xs" />} label="Claire Martin" variant="outlined" />
</div>
);
}Removable tags
closable shows the cross; the application removes the item in onClose.
import { useState } from "react";
import { Chip } from "@synertech/ui";
export function Closable() {
const [tags, setTags] = useState(["Paris", "Lyon", "Bordeaux"]);
return (
<div className="flex flex-wrap gap-2">
{tags.map((tag) => (
<Chip
key={tag}
label={tag}
variant="soft"
color="primary"
closable
onClose={() => setTags((current) => current.filter((t) => t !== tag))}
/>
))}
{tags.length === 0 && <span className="text-sm text-gray-500">Aucune ville</span>}
</div>
);
}Selectable filters
Rendered as as="button", the chip becomes focusable; selected marks the active filter with a ring, and aria-pressed announces it.
import { useState } from "react";
import { Chip } from "@synertech/ui";
export function Filters() {
const categories = ["Tous", "Factures", "Devis", "Avoirs"];
const [active, setActive] = useState("Tous");
return (
<div className="flex flex-wrap gap-2" role="group" aria-label="Type de document">
{categories.map((category) => (
<Chip
key={category}
as="button"
label={category}
variant={category === active ? "solid" : "outlined"}
color="primary"
clickable
selected={category === active}
aria-pressed={category === active}
onClick={() => setActive(category)}
/>
))}
<Chip as="button" label="Brouillons" variant="outlined" disabled />
</div>
);
}Active filters that can be removed
as="button" and closable together: the pill holds two buttons side by side, the filter and its cross, each one reachable from the keyboard. Neither submits the form they are in.
import { useState } from "react";
import { Chip } from "@synertech/ui";
export function RemovableFilters() {
const [filters, setFilters] = useState(["Factures", "2026", "Impayées"]);
const [last, setLast] = useState<string | null>(null);
return (
<form className="flex flex-col gap-3" onSubmit={(event) => event.preventDefault()}>
<div className="flex flex-wrap gap-2" role="group" aria-label="Filtres actifs">
{filters.map((filter) => (
<Chip
key={filter}
as="button"
label={filter}
variant="soft"
color="primary"
clickable
closable
onClick={() => setLast(filter)}
onClose={() => setFilters((current) => current.filter((f) => f !== filter))}
/>
))}
</div>
<p className="text-sm text-gray-600 dark:text-gray-300">
{last
? `Dernier filtre ouvert : ${last}`
: "Cliquez un filtre, ou retirez-le par sa croix."}
</p>
</form>
);
}API reference
Components
import { Chip } from "@synertech/ui";Props — ChipProps
| Prop | Type | Default | Description |
|---|---|---|---|
as |
"span" | "div" | "button" |
"span" |
|
avatar |
ReactNode |
— | |
bgColor |
string |
— | |
borderColor |
string |
— | |
children |
ReactNode |
— | |
clickable |
boolean |
false |
|
closable |
boolean |
false |
|
color |
ChipColor |
"default" |
|
disabled |
boolean |
false |
|
endIcon |
ReactNode |
— | |
icon |
ReactNode |
— | |
label |
string |
— | |
onClose |
() => void |
— | |
removeLabel |
string |
— | Accessible name of the remove button. Defaults to the |
rounded |
"none" | "sm" | "md" | "lg" | "full" |
"full" |
|
selected |
boolean |
false |
|
size |
ChipSize |
"md" |
|
textColor |
string |
— | |
variant |
ChipVariant |
"solid" |
+ 277 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
ChipColor
Typetype ChipColor = "default" | "primary" | "success" | "warning" | "error" | "info"ChipSize
Typetype ChipSize = "sm" | "md" | "lg"ChipVariant
Typetype ChipVariant = "solid" | "outlined" | "soft" | "dot"