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.
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.
| Name | Type | Default | Description |
|---|---|---|---|
render | RenderProp<Record<string, never>> | – | Must render a |
- 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.
| Name | Type | Default | Description |
|---|---|---|---|
labels | Partial<SuggestionGroupLabels> | – | |
render | RenderProp<Record<string, never>> | – | Must render a |
- 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
SuggestionChipPropstypeimport type { SuggestionChipProps } from '@nizivo/react/unstable/suggestion-chip'The props of
SuggestionChip, listed above.SuggestionGroupLabelstypeimport type { SuggestionGroupLabels } from '@nizivo/react/unstable/suggestion-chip'SuggestionGroup's own strings (§16.4): serialisable, English defaults.
Name Type Default Description labelrequiredstring'Suggestions'The group's accessible name, unless
aria-labeloraria-labelledbynames it.SuggestionGroupPropstypeimport 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.
| Slot | Rendered by | Data attributes |
|---|---|---|
suggestion-chip.nz-suggestion-chip | SuggestionChiproot (takes render); interactive, focus: self | none |
suggestion-chip-label.nz-suggestion-chip-label | SuggestionChipinner element (CSS only) | none |
suggestion-group.nz-suggestion-group | SuggestionGrouproot (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.
| Hook | Default | Read as |
|---|---|---|
--nz-suggestion-chip-bg | --nz-bg-surface |
|
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.
StickyBar
A bar of actions that sticks to the bottom of the viewport while its section scrolls, above the device's home indicator and the shell's bottom tab bar.
Surface
A panel of the page's surface colour, solid or glass. Glass is the surface at 72 % over a blurred backdrop, for a panel over a photo, a shader or a busy page, and it stays opaque wherever the blur is not available.