Components
ModelSelector
Unstable: which model answers, as a trade-off in plain words (Fast, Balanced, Deep), in a pill that opens a list describing each one. Import it from @nizivo/react/unstable/model-selector.
Examples
Basic
Three trade-offs, named in words, with Balanced chosen.
import type { JSX } from 'react';
import { ModelSelector } from '@nizivo/react/unstable/model-selector';
const MODELS = [
{ value: 'fast', label: 'Fast', description: 'Quick answers for simple tasks' },
{ value: 'balanced', label: 'Balanced', description: 'Good for most work' },
{ value: 'deep', label: 'Deep', description: 'Slower, more careful reasoning' },
];
export function ModelSelectorExample(): JSX.Element {
return <ModelSelector models={MODELS} defaultValue="balanced" />;
}
Import
import { ModelSelector } from '@nizivo/react/unstable/model-selector';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css and @nizivo/react/css/popover.css and @nizivo/react/css/select.css
import '@nizivo/react/css/model-selector.css';Static or interactive
Client. It is a Select: the same keyboard, typeahead and hidden
native <select> for forms. How to choose.
Models
models lists the choices, each with a value, a label that names the trade-off ("Balanced",
never a version number) and a description that says it in words ("Good for most work").
value, defaultValue (the first model by default) and onValueChange hold the choice. The
trigger shows the chosen name only; its accessible name ends with labels.label ("Balanced Model").
Props
Client component Renders data-slot="model-selector" with the class nz-model-selector. Props: ModelSelectorProps. Source: src/unstable/model-selector/model-selector.client.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
className | string | – | |
defaultValue | string | the first model | The model at first (uncontrolled). |
disabled | boolean | – | |
labels | Partial<ModelSelectorLabels> | – | |
modelsrequired | readonly ModelOption[] | – | |
name | string | – | Submitted with a form, as Select's hidden native |
onValueChange | (value: string, details: ChangeDetails<SelectValueReason>) => void | – | |
value | string | – | The chosen model (controlled). |
Other exports
ModelOptiontypeimport type { ModelOption } from '@nizivo/react/unstable/model-selector'One choice.
Name Type Default Description descriptionstring– What it trades, in words: "Good for most work".
disabledboolean– labelrequiredstring– The trade-off's name: "Balanced".
valuerequiredstring– ModelSelectorLabelstypeimport type { ModelSelectorLabels } from '@nizivo/react/unstable/model-selector'ModelSelector's own strings (§16.4): serialisable, English defaults.
Name Type Default Description labelrequiredstring'Model'Names the trigger, after the chosen model ("Balanced Model"), as every Select reads.
ModelSelectorPropstypeimport type { ModelSelectorProps } from '@nizivo/react/unstable/model-selector'The props of
ModelSelector, 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 |
|---|---|---|
model-selector.nz-model-selector | ModelSelectorroot (no render) | none |
model-selector-item.nz-model-selector-item | ModelSelectorinner element (CSS only); interactive, focus: engine | none |
model-selector-trigger.nz-model-selector-trigger | ModelSelectorinner element (CSS only); interactive, focus: self | none |
model-selector-value.nz-model-selector-value | ModelSelectorinner 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-model-selector, .nz-model-selector-chevron, .nz-model-selector-description, .nz-model-selector-item, .nz-model-selector-name, .nz-model-selector-popup, .nz-model-selector-text, .nz-model-selector-trigger, .nz-model-selector-value, .nz-select-chevron, .nz-select-icon, .nz-select-item, .nz-select-popup, .nz-select-trigger.
Tokens this stylesheet reads (15)
--nz-border-default, --nz-font-body-s, --nz-font-label-m, --nz-font-label-m-strong, --nz-icon-brand, --nz-radius-full, --nz-radius-sm, --nz-space-0-5, --nz-space-1-5, --nz-space-10, --nz-space-2, --nz-space-3, --nz-space-8, --nz-text-primary, --nz-text-secondary
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:
model-selector-item: draws the focus outline when the engine reports keyboard focus, not on pointer hover.model-selector-trigger: draws the focus outline itself on keyboard focus.
Keyboard
To be written.
MobileTopBar
The bar above the page below 640 px, with the store's mark or a back link, the page's name, and icon buttons for search and notifications.
Motion
CountUp: a number that counts up to its value on the client, while the server renders the final value in NumberValue's element. Tabular digits that keep their width, 0 ms under reduced motion, and nothing announced while it counts. Also useCountUp, for an element of your own.