Skip to content
Get started

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.

Server component, no client JSUnstable

Examples

Basic

Two styles: subtle beside a block of text, solid where it must stand out.

AI generatedAI generated
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.

NameTypeDefaultDescription
labelsPartial<AiBadgeLabels>–

Replaces "AI generated", for example labels={{ label: 'Edited with AI' }}. Children win.

renderRenderProp<Record<string, never>>–

Must render a <span> or another phrasing element.

variant"subtle" | "solid"'subtle'

The look: subtle (accent-subtle with a brand edge) or solid (the accent).

  • 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

AiBadgeLabels type

import type { AiBadgeLabels } from '@nizivo/react/unstable/ai-badge'

AiBadge's own strings (§16.4): serialisable, English defaults.

NameTypeDefaultDescription
labelrequiredstring'AI generated'

The text when the badge has no children.

AiBadgeProps type

import 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.

SlotRendered byData attributes
ai-badge
.nz-ai-badge
AiBadge
root (takes render)
  • data-variant: "subtle""solid" ← variant
    The variant prop; values in each component manifest
ai-badge-icon
.nz-ai-badge-icon
AiBadge
inner element (CSS only)
none
ai-badge-label
.nz-ai-badge-label
AiBadge
inner 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.

HookDefaultRead as
--nz-ai-badge-bg
  • default: var(--nz-bg-accent-subtle)
  • data-variant="solid": var(--nz-bg-accent)
  • background on .nz-ai-badge
--nz-ai-badge-border
  • default: var(--nz-border-brand)
  • data-variant="solid": transparent
  • border on .nz-ai-badge
--nz-ai-badge-fg
  • default: var(--nz-text-brand)
  • data-variant="solid": var(--nz-text-on-accent)
  • color on .nz-ai-badge

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.

On this page