components/Form
import { … } from 'zidane-ui'ui/src/components/Form.tsx
Components#
CheckboxComponent#
The checkbox glyph for multi-select lists; the row around it is the control.
function Checkbox(props: CheckboxProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | CheckboxProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| checked | boolean | Whether the box is ticked. |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
ErrorNoteComponent#
A failure worth reading: a soft danger wash, no border.
function ErrorNote(props: ErrorNoteProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ErrorNoteProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The error message. |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
FormCardComponent#
An entity card lifted off its section tray (server, provider, environment).
function FormCard(props: FormCardProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | FormCardProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The card's content. |
| className? | string | Extra classes on the card. |
| data-testid? | string | Test id for the card element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
FormSectionComponent#
A labelled group. rows (default) hosts flat rows; cards spaces raised
FormCards apart on the same tray.
function FormSection(props: FormSectionProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | FormSectionProps | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The rows or cards. | |
| className? | string | Extra classes on the section. | |
| layout? | 'rows' | 'cards' | 'rows' |
|
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | ReactNode | Label above the section. The label line is omitted when neither | |
| trailing? | ReactNode | Right side of the label line: a count, a small action. |
HostRowComponent#
A row whose one control sits among other buttons (a picker with Test and
clear, a select, a switch beside a note): it washes on hover like a row
button, and a click anywhere on it but on a button or a field works the
control, the element marked data-row-control (or the button, select or
input inside it; a select opens its list). Keyboard users reach the
control itself.
function HostRow(props: HostRowProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | HostRowProps | The row's |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The row's content, the control marked | |
| disabled? | boolean | false | The control can't be used now: no wash, no forwarding. |
MetaChipComponent#
A status or value chip set into its surface: track tone, meta voice.
function MetaChip(props: MetaChipProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | MetaChipProps | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The chip's content. | |
| className? | string | Extra classes on the chip. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | string | Native tooltip. | |
| tone? | 'danger' | 'muted' | 'text' | 'accent' | 'success' | 'warn' | 'info' | 'muted' | Text colour of the chip. |
NavRowComponent#
A row that navigates somewhere (another modal, a sub-surface).
function NavRow(props: NavRowProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | NavRowProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| action | { description: string; icon: string; label: string; onSelect: () => void } | The row: its |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
OpLineComponent#
One-line feedback for a lifecycle op (install / update / remove).
function OpLine(props: OpLineProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | OpLineProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The feedback text. |
| className? | string | Extra classes on the root element. |
| kind | 'error' | 'busy' | 'notice' | Tone of the line: |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
RowTextComponent#
Label over an optional muted description, the left half of every row.
function RowText(props: RowTextProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | RowTextProps | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| description? | ReactNode | Muted text under the label. | |
| label | ReactNode | The row's main text. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| truncate? | boolean | true | Cut the description to one line with an ellipsis. When off, it wraps. |
SegmentedRowComponent#
Label + description on the left, a Segmented picker on the right.
function SegmentedRow<T extends string>(props: SegmentedRowProps<T>): ElementType parameters
| Name | Type | Description |
|---|---|---|
| T | extends string |
Parameters
| Name | Type | Description |
|---|---|---|
| props | SegmentedRowProps<T> | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| label | string | The row's main text. It also names the choice group. |
| onChange | (v: T) => void | Called with the new value when an option is picked. |
| options | { disabled?: boolean; icon?: string; label: string; title?: string; value: T }[] | The choices, as |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| value | T | The value of the selected option. |
SliderRowComponent#
Labelled range input with a value readout and a reset.
function SliderRow(props: SliderRowProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | SliderRowProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| format | (v: number) => string | Formats the value for the readout beside the slider. |
| label | string | The row's main text. It also names the slider. |
| max | number | Highest value. |
| min | number | Lowest value. |
| onChange | (v: number) => void | Called with the new value while the slider moves. |
| onReset? | () => void | Called when the slider is double-clicked, to restore the default value. |
| step | number | Increment between values. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| value | number | Current value. |
SwitchComponent#
The settings-row switch glyph (SwitchGlyph md); the row around it is the control.
function Switch(props: SwitchProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | SwitchProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| on | boolean | Whether the switch is on. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
SwitchRowComponent#
Plain on/off row for store-backed booleans (not the vendored settings table).
function SwitchRow(props: SwitchRowProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | SwitchRowProps | Component props. |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| label | string | The row's main text. |
| on | boolean | Whether the option is on. |
| onToggle | () => void | Called when the row is clicked. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
ToggleSwitchComponent#
A standalone switch control, for rows that host other buttons too.
function ToggleSwitch(props: ToggleSwitchProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | ToggleSwitchProps | Component props. |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| disabled? | boolean | false | Grey the switch out and ignore clicks. |
| label | string | Accessible name of the switch. It has no visible text. | |
| on | boolean | Whether the switch is on. | |
| onChange | (on: boolean) => void | Called with the new state when the switch is clicked. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | string | Native tooltip. |
Constants#
FIELD_LABEL_CLASSConstant#
Label above a form field.
const FIELD_LABEL_CLASS = 'block text-xs text-[var(--zg-text-muted)] mb-1'FORM_CARD_CLASSConstant#
An inline add / install form: a raised card above the list it feeds.
const FORM_CARD_CLASS = 'zg-raised border rounded-zg-lg p-4 space-y-3'INPUT_CLASSConstant#
Single-line text input: a well set into its surface.
const INPUT_CLASS: 'zg-well w-full h-8 px-2.5 text-zg-ui placeholder:text-[var(--zg-text-subtle)] disabled:opacity-zg-disabled'ROW_BUTTON_CLASSConstant#
A whole-row button inside a section tray: flat, washed on hover.
const ROW_BUTTON_CLASS = ...ROW_CLASSConstant#
A static row whose control (segment, slider, input) takes the input.
const ROW_CLASS = 'flex items-center gap-3 px-3 py-2'ROW_HOST_CLASSConstant#
A HostRow's surface: a row button's wash, giving with the control inside (zg-press-host).
const ROW_HOST_CLASS = ...ROW_TRIGGER_CLASSConstant#
The control of a HostRow that takes the row's width: a picker's trigger, holding the label and the value.
const ROW_TRIGGER_CLASS = ...TEXTAREA_CLASSConstant#
Multi-line / code input.
const TEXTAREA_CLASS: 'zg-well w-full px-2.5 py-2 text-zg-label font-mono leading-relaxed placeholder:text-[var(--zg-text-subtle)] resize-y'Interfaces#
CheckboxPropsInterface#
Props for Checkbox.
interface CheckboxPropsProperties
| Name | Type | Description |
|---|---|---|
| checked | boolean | Whether the box is ticked. |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
ErrorNotePropsInterface#
Props for ErrorNote.
interface ErrorNotePropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The error message. |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
FormCardPropsInterface#
Props for FormCard.
interface FormCardPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The card's content. |
| className? | string | Extra classes on the card. |
| data-testid? | string | Test id for the card element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
FormSectionPropsInterface#
Props for FormSection.
interface FormSectionPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The rows or cards. | |
| className? | string | Extra classes on the section. | |
| layout? | 'rows' | 'cards' | 'rows' |
|
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | ReactNode | Label above the section. The label line is omitted when neither | |
| trailing? | ReactNode | Right side of the label line: a count, a small action. |
HostRowPropsInterface#
Props for HostRow: the row's div attributes, children and disabled.
interface HostRowProps extends HTMLAttributes<HTMLDivElement>Properties
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The row's content, the control marked | |
| disabled? | boolean | false | The control can't be used now: no wash, no forwarding. |
MetaChipPropsInterface#
Props for MetaChip.
interface MetaChipPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | The chip's content. | |
| className? | string | Extra classes on the chip. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | string | Native tooltip. | |
| tone? | 'danger' | 'muted' | 'text' | 'accent' | 'success' | 'warn' | 'info' | 'muted' | Text colour of the chip. |
NavRowPropsInterface#
Props for NavRow.
interface NavRowPropsProperties
| Name | Type | Description |
|---|---|---|
| action | { description: string; icon: string; label: string; onSelect: () => void } | The row: its |
| className? | string | Extra classes on the root element. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
OpLinePropsInterface#
Props for OpLine.
interface OpLinePropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The feedback text. |
| className? | string | Extra classes on the root element. |
| kind | 'error' | 'busy' | 'notice' | Tone of the line: |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
RowTextPropsInterface#
Props for RowText.
interface RowTextPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| description? | ReactNode | Muted text under the label. | |
| label | ReactNode | The row's main text. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| truncate? | boolean | true | Cut the description to one line with an ellipsis. When off, it wraps. |
SegmentedRowPropsInterface#
Props for SegmentedRow.
interface SegmentedRowProps<T extends string>Type parameters
| Name | Type | Description |
|---|---|---|
| T | extends string |
Properties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| label | string | The row's main text. It also names the choice group. |
| onChange | (v: T) => void | Called with the new value when an option is picked. |
| options | { disabled?: boolean; icon?: string; label: string; title?: string; value: T }[] | The choices, as |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| value | T | The value of the selected option. |
SliderRowPropsInterface#
Props for SliderRow.
interface SliderRowPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| format | (v: number) => string | Formats the value for the readout beside the slider. |
| label | string | The row's main text. It also names the slider. |
| max | number | Highest value. |
| min | number | Lowest value. |
| onChange | (v: number) => void | Called with the new value while the slider moves. |
| onReset? | () => void | Called when the slider is double-clicked, to restore the default value. |
| step | number | Increment between values. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
| value | number | Current value. |
SwitchPropsInterface#
Props for Switch.
interface SwitchPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| on | boolean | Whether the switch is on. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
SwitchRowPropsInterface#
Props for SwitchRow.
interface SwitchRowPropsProperties
| Name | Type | Description |
|---|---|---|
| className? | string | Extra classes on the root element. |
| description? | string | Muted text under the label. It wraps. |
| label | string | The row's main text. |
| on | boolean | Whether the option is on. |
| onToggle | () => void | Called when the row is clicked. |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. |
ToggleSwitchPropsInterface#
Props for ToggleSwitch.
interface ToggleSwitchPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| disabled? | boolean | false | Grey the switch out and ignore clicks. |
| label | string | Accessible name of the switch. It has no visible text. | |
| on | boolean | Whether the switch is on. | |
| onChange | (on: boolean) => void | Called with the new state when the switch is clicked. | |
| style? | CSSProperties | Inline styles on the root element, merged after the component's own. | |
| title? | string | Native tooltip. |