Components
AiBadge
Unstable: says that the content beside it was written or changed by AI. Subtle or solid, in the lime that marks AI everywhere in Nizivo. Import it from @nizivo/react/unstable/ai-badge.
Examples
Basic
Two styles: subtle beside a block of text, solid where it must stand out.
import type { JSX } from 'react';
import { AiBadge } from '@nizivo/react/unstable/ai-badge';
export function AiBadgeExample(): JSX.Element {
return (
<div style={{ display: 'flex', gap: 16, alignItems: 'center' }}>
<AiBadge />
<AiBadge variant="solid" />
</div>
);
}
Label
Next to the content it describes, with its own words.
Hand-thrown stoneware, glazed in small batches.Edited with AI
import type { JSX } from 'react';
import { AiBadge } from '@nizivo/react/unstable/ai-badge';
export function AiBadgeLabelExample(): JSX.Element {
return (
<p style={{ display: 'flex', gap: 8, alignItems: 'center', margin: 0 }}>
Hand-thrown stoneware, glazed in small batches.
<AiBadge labels={{ label: 'Edited with AI' }} />
</p>
);
}
Import
import { AiBadge } from '@nizivo/react/unstable/ai-badge';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/ai-badge.css';Static or interactive
Server. No client JavaScript. How to choose.
Where it goes
Put it next to the content it describes, never as decoration: under a generated product
description, beside an edited caption, in an answer's header. variant="subtle" (the default) is
for text on a page; variant="solid" stands out over busier surfaces. Lime (bg/accent) marks AI
in Nizivo and nothing else.
Words
It says "AI generated". Pass children, or labels={{ label: 'Edited with AI' }}, to say something
more exact. The sparkles mark is decorative; the words carry the meaning.
Props
Server component Renders data-slot="ai-badge" with the class nz-ai-badge. Props: AiBadgeProps. Source: src/unstable/ai-badge/ai-badge.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
labels | Partial<AiBadgeLabels> | – | Replaces "AI generated", for example |
render | RenderProp<Record<string, never>> | – | Must render a |
variant | "subtle" | "solid" | 'subtle' | The look: |
- Also takes every attribute of
<span>. (ComponentPropsWithRef<"span">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
AiBadgeLabelstypeimport type { AiBadgeLabels } from '@nizivo/react/unstable/ai-badge'AiBadge's own strings (§16.4): serialisable, English defaults.
Name Type Default Description labelrequiredstring'AI generated'The text when the badge has no children.
AiBadgePropstypeimport type { AiBadgeProps } from '@nizivo/react/unstable/ai-badge'The props of
AiBadge, 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 |
|---|---|---|
ai-badge.nz-ai-badge | AiBadgeroot (takes render) |
|
ai-badge-icon.nz-ai-badge-icon | AiBadgeinner element (CSS only) | none |
ai-badge-label.nz-ai-badge-label | AiBadgeinner element (CSS only) | 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.
| Hook | Default | Read as |
|---|---|---|
--nz-ai-badge-bg |
|
|
--nz-ai-badge-border |
|
|
--nz-ai-badge-fg |
|
|
Layers: nz.components. Classes: .nz-ai-badge, .nz-ai-badge-icon, .nz-ai-badge-label.
Tokens this stylesheet reads (11)
--nz-bg-accent, --nz-bg-accent-subtle, --nz-border-brand, --nz-border-width-default, --nz-font-label-s, --nz-icon-brand, --nz-radius-full, --nz-space-1, --nz-space-2, --nz-text-brand, --nz-text-on-accent
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.
Accordion
Sections that open and close under their headings, such as FAQs or a checkout's order summary. Each item is a native details element, so it works with no JavaScript, and items that share a name open one at a time.
AiWelcome
Unstable: the empty state of a new conversation, a greeting, what the assistant can see and do, then the starters and the composer. Import it from @nizivo/react/unstable/ai-welcome.