Skip to content
Get started

Components

SuggestionChip

Unstable: prompt starters and follow-ups. A chip is a button that fills the composer so people can edit before they send; a SuggestionGroup wraps a few of them as a labelled group. Import them from @nizivo/react/unstable/suggestion-chip.

Server component, no client JSUnstable

Examples

Basic

Prompt starters under an empty composer; each fills it, and people still press send.

import type { JSX } from 'react';
import { SuggestionChip, SuggestionGroup } from '@nizivo/react/unstable/suggestion-chip';

export function SuggestionChipExample(): JSX.Element {
  return (
    <SuggestionGroup style={{ maxInlineSize: 560 }}>
      <SuggestionChip>Write a product description</SuggestionChip>
      <SuggestionChip>Summarise this week’s orders</SuggestionChip>
      <SuggestionChip>Find slow-moving stock</SuggestionChip>
      <SuggestionChip>Draft a launch post</SuggestionChip>
    </SuggestionGroup>
  );
}

Import

import { SuggestionChip, SuggestionGroup } from '@nizivo/react/unstable/suggestion-chip';

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

Static or interactive

Server. No client JavaScript of its own: each chip is a button, and what its onClick does is your component's code. How to choose.

Fill, don't send

A chip puts its words in the composer; people still press send. Do that in onClick, and move focus to the composer so they can edit. Keep about five in view at most, under an empty composer or after an answer as follow-ups.

The group

SuggestionGroup wraps the chips with 8 px between them and is a group named "Suggestions" (labels.label, or your own aria-label or aria-labelledby).

Props

SuggestionChip

Server component Renders data-slot="suggestion-chip" with the class nz-suggestion-chip. Props: SuggestionChipProps. Source: src/unstable/suggestion-chip/suggestion-chip.tsx.

NameTypeDefaultDescription
renderRenderProp<Record<string, never>>–

Must render a <button>.

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

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

SuggestionGroup

Server component Renders data-slot="suggestion-group" with the class nz-suggestion-group. Props: SuggestionGroupProps. Source: src/unstable/suggestion-chip/suggestion-chip.tsx.

NameTypeDefaultDescription
labelsPartial<SuggestionGroupLabels>–
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

SuggestionChipProps type

import type { SuggestionChipProps } from '@nizivo/react/unstable/suggestion-chip'

The props of SuggestionChip, listed above.

SuggestionGroupLabels type

import type { SuggestionGroupLabels } from '@nizivo/react/unstable/suggestion-chip'

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

NameTypeDefaultDescription
labelrequiredstring'Suggestions'

The group's accessible name, unless aria-label or aria-labelledby names it.

SuggestionGroupProps type

import type { SuggestionGroupProps } from '@nizivo/react/unstable/suggestion-chip'

The props of SuggestionGroup, 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
suggestion-chip
.nz-suggestion-chip
SuggestionChip
root (takes render); interactive, focus: self
none
suggestion-chip-label
.nz-suggestion-chip-label
SuggestionChip
inner element (CSS only)
none
suggestion-group
.nz-suggestion-group
SuggestionGroup
root (takes render)
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-suggestion-chip-bg--nz-bg-surface
  • background on .nz-suggestion-chip

Layers: nz.components. Classes: .nz-suggestion-chip, .nz-suggestion-chip-icon, .nz-suggestion-chip-label, .nz-suggestion-group.

Tokens this stylesheet reads (18)

--nz-bg-disabled, --nz-bg-hover, --nz-bg-pressed, --nz-bg-surface, --nz-border-default, --nz-border-strong, --nz-border-width-default, --nz-font-label-m, --nz-icon-brand, --nz-radius-full, --nz-size-icon-sm, --nz-space-0-5, --nz-space-1, --nz-space-2, --nz-space-3, --nz-space-8, --nz-text-disabled, --nz-text-primary

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:

  • suggestion-chip: draws the focus outline itself on keyboard focus.

Keyboard

To be written.

On this page