Skip to content
Get started

Components

ThinkingIndicator

Unstable: the wait before an AI answer's first word, three stepping dots and a label that can name the step. A polite status region; the dots stop under reduced motion. Import it from @nizivo/react/unstable/thinking-indicator.

Server component, no client JSUnstable

Examples

Basic

Before the first word, and naming the step when the assistant knows it.

Thinking…
Reading last week’s orders…
import type { JSX } from 'react';
import { ThinkingIndicator } from '@nizivo/react/unstable/thinking-indicator';

export function ThinkingIndicatorExample(): JSX.Element {
  return (
    <div style={{ display: 'grid', gap: 12, justifyItems: 'start' }}>
      <ThinkingIndicator />
      <ThinkingIndicator>Reading last week’s orders…</ThinkingIndicator>
    </div>
  );
}

Import

import { ThinkingIndicator } from '@nizivo/react/unstable/thinking-indicator';

// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/thinking-indicator.css';

Static or interactive

Server. No client JavaScript: the dots are CSS. How to choose.

Name the step

It says "Thinking…". When the assistant knows what it is doing, say it: children replace the label (<ThinkingIndicator>Reading last week's orders…</ThinkingIndicator>). Replace the indicator with the answer once the first words arrive.

Screen readers and motion

The indicator is role="status", so a screen reader announces the label, and each new step, politely. The dots are decorative. Under reduced motion they stand still and only the label changes.

Props

Server component Renders data-slot="thinking-indicator" with the class nz-thinking-indicator. Props: ThinkingIndicatorProps. Source: src/unstable/thinking-indicator/thinking-indicator.tsx.

NameTypeDefaultDescription
labelsPartial<ThinkingIndicatorLabels>–

Replaces "Thinking…". Children (the step, such as "Reading last week's orders…") win.

renderRenderProp<Record<string, never>>–

Must render a <div>.

  • Also takes every attribute of <div>. (ComponentPropsWithRef<"div">)

render takes an element, or, in client code, a function of the props and no state.

Other exports

ThinkingIndicatorLabels type

import type { ThinkingIndicatorLabels } from '@nizivo/react/unstable/thinking-indicator'

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

NameTypeDefaultDescription
labelrequiredstring'Thinking…'

The label when the indicator has no children.

ThinkingIndicatorProps type

import type { ThinkingIndicatorProps } from '@nizivo/react/unstable/thinking-indicator'

The props of ThinkingIndicator, 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
thinking-indicator
.nz-thinking-indicator
ThinkingIndicator
root (takes render)
none
thinking-indicator-label
.nz-thinking-indicator-label
ThinkingIndicator
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.

This stylesheet reads no public hook.

Layers: nz.components. Classes: .nz-thinking-indicator, .nz-thinking-indicator-dot, .nz-thinking-indicator-dots, .nz-thinking-indicator-label.

Tokens this stylesheet reads (9)

--nz-bg-brand, --nz-border-control, --nz-duration-spin, --nz-font-label-m, --nz-radius-full, --nz-space-0-5, --nz-space-1, --nz-space-2, --nz-text-secondary

Accessibility

Nothing in this component takes focus or keyboard input.

Keyboard

None.

On this page