Components
Tag
Unstable: a filter chip or a removable token, 32 px and fully rounded, that toggles with a check and removes with its own named button. Import it from @nizivo/react/unstable/tag.
Examples
Basic
The states: a removable token, a filter on and off, and a disabled one.
import type { JSX } from 'react';
import { Tag } from '@nizivo/react/unstable/tag';
export function TagExample(): JSX.Element {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
<Tag label="Ceramics" removable />
<Tag label="Ceramics" selected removable />
<Tag label="Glassware" selected={false} />
<Tag label="Ceramics" removable disabled />
</div>
);
}
Import
import { Tag } from '@nizivo/react/unstable/tag';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/tag.css';Static or interactive
Server. No client JavaScript: its buttons call onToggle and onRemove.
How to choose.
Filter or token
With selected the tag is a filter: a button with aria-pressed that shows a check when on, so the
state is not colour alone. Without it, the label is plain text. removable adds a 24 px remove
button named "Remove Ceramics" (labels.remove, with {label}); the two are sibling buttons.
For read-only status, use Badge; for a set of choices in a form, use
ChipGroup.
Props
Server component Renders data-slot="tag" with the class nz-tag. Props: TagProps. Source: src/unstable/tag/tag.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
disabled | boolean | false | |
labelrequired | string | – | What the tag says: "Ceramics". |
labels | Partial<TagLabels> | – | |
onRemove | () => void | – | The remove button calls it. |
onToggle | () => void | – | The toggle calls it, when |
removable | boolean | false | Adds the remove button. |
render | RenderProp<Record<string, never>> | – | Must render a |
selected | boolean | – | A filter: whether it is on. Leave it out for a token that does not toggle. |
- Also takes every attribute of
<span>exceptchildren;onToggleis redeclared above. (Omit<ComponentPropsWithRef<"span">, "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
TagLabelstypeimport type { TagLabels } from '@nizivo/react/unstable/tag'Tag's own strings (§16.4): serialisable, English defaults.
Name Type Default Description removerequiredstring'Remove {label}'The remove button's name:
{label}is the tag's.TagPropstypeimport type { TagProps } from '@nizivo/react/unstable/tag'The props of
Tag, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
tag.nz-tag | Tagroot (takes render) |
|
tag-label.nz-tag-label | Taginner element (CSS only) | none |
tag-remove.nz-tag-remove | Taginner element (CSS only); interactive, focus: self | none |
tag-toggle.nz-tag-toggle | Taginner element (CSS only); interactive, focus: self | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
This stylesheet reads no public hook.
Layers: nz.components. Classes: .nz-tag, .nz-tag-check, .nz-tag-label, .nz-tag-remove, .nz-tag-toggle.
Tokens this stylesheet reads (24)
--nz-bg-brand-subtle, --nz-bg-disabled, --nz-bg-hover, --nz-bg-surface, --nz-border-brand, --nz-border-default, --nz-border-strong, --nz-border-subtle, --nz-border-width-default, --nz-duration-fast, --nz-easing-standard, --nz-font-label-m, --nz-icon-secondary, --nz-radius-full, --nz-size-icon-sm, --nz-space-1-5, --nz-space-2, --nz-space-3, --nz-space-6, --nz-space-8, --nz-text-brand, --nz-text-disabled, --nz-text-primary, --nz-text-secondary
Accessibility
These parts are interactive. Each gets the focus outline and touch-action rule from @nizivo/react/css/base.css (the nz.base layer), so the floor survives a restyle:
tag-remove: draws the focus outline itself on keyboard focus.tag-toggle: draws the focus outline itself on keyboard focus.
Keyboard
To be written.
Tabs
In-page views of one subject, one panel at a time, as WAI-ARIA tabs. Only the selected panel is rendered, on the server too; keepMounted keeps a panel's state while it is hidden. When each view is a URL, use TabNav; to pick a range or a value, use SegmentedControl.
TestimonialCard
Unstable: a real, attributed customer quote in a figure, with the person's name, job and avatar. Import it from @nizivo/react/unstable/testimonial-card.