Components
Field
The behavior every Salmon input shares - labels, descriptions, errors, sizes, adornments, clearing, form participation, SSR and accessibility - and the public Field wrapper for custom controls.
Every Inputs component renders the same parts: a real <label for>, the
control, a description and an error. label, description,
errorMessage, invalid, validation, validateOn and size are props of
every field; Field is public for custom controls.
import { Field } from '@salmonui/inputs/form';
import '@salmonui/inputs/form/styles.css';
<Field name="plan" label="Plan" description="You can change it later" validation={{ required: true }} value={plan}>
{(field) => <MyControl {...field.inputProps} value={plan} onChange={setPlan} />}
</Field>
Field with a custom control
Open demoA native select wrapped in Field with a label, a description, a required rule and an error placed next to the control.
Field is controlled by its child: pass the control's current value so
the rules can check it. Every built-in field is controlled with value /
onValueChange (or checked / onCheckedChange) and uncontrolled with
defaultValue (or defaultChecked).
Shared behavior
- Labels and help.
aria-describedbylists the description and the visible error,aria-errormessagepoints at the error andaria-invalidis set only while an error is shown. - Error state.
invalidforces it; validation results set it. The root carriesdata-invalidfor styling. - Placeholder. Native
placeholder. - Disabled and read-only. Native
disabledandreadOnly(so<fieldset disabled>works); the root carriesdata-disabled. - Class names and styles.
classNameandstylego to the root,classNamesto the parts, every other prop to the native element. - Direction. The inherited
dirapplies; CSS uses logical properties only. - Locale.
localeTextoverrides every built-in string per component (clear,validation*); the formatting fields (NumberField, Slider) take a BCP 47locale(default'en-US'; the host locale is never read, so server and client agree). - Focus.
refis the native element:focus(),blur(),click(); nativeonFocus/onBlur. - Value events. Native
onChangeplusonValueChange(value, details);value/defaultValuemake the field controlled or uncontrolled. - Forms.
nameandformare native, soFormDataand React 19<form action>see the value; a form reset restoresdefaultValue. - Clearing.
clearableadds a clear button named bylocaleText.clear; Escape clears too. - Adornments.
startAdornment/endAdornmenttake any node. - SSR. Server and client markup are identical; ids come from
useId; browser APIs are touched only after mount. - Size.
size: 'sm' | 'md' | 'lg'picks one of three fixed metric sets (data-size); the theme'sdensity: 'compact'tightens each set (see Density). - Accessibility. axe-core runs on every Inputs component in
light, dark and RTL with errors shown (
npm run test:a11y); each component page has a keyboard table.
Field states
Open demoThe shared field behavior on TextField, NumberField, Slider and Rating - placeholder, disabled, read-only, sizes, RTL, locale and localeText, adornments, clearing, className and style, ref methods, native focus events and controlled versus uncontrolled values.
Name: "Ada"
Fields in a form
Open demoUncontrolled text, masked, number, radio, checkbox, switch, range slider, rating and signature fields in a native form - names and values submitted through FormData, a required incomplete mask blocking the submit, and a form reset restoring every default.
Change some fields, then submit or reset.
(nothing submitted yet)
Keyboard and screen readers
Open demoEvery Inputs control in one tab order with the role, name, value and description the focused element exposes to assistive technology - textbox, masked textbox, spin button, radio group, checkboxes, switch, two-thumb slider, rating and one-time code.
Press Tab to move into the first field.
Design notes
| Behavior | Why | How to |
|---|---|---|
No floating label: the label is a static <label> above the control. |
One look per component; a label inside the input is hard to read at zoom and cut off by translations. | Put hints in placeholder or description. |
| No attribute-bag prop or method. | React props already are the attribute API. | Unknown props spread on the native element (data-id="x", aria-*, inputMode). |
No width prop. |
Sizing belongs to layout CSS. | style={{ inlineSize: 240 }} or className. |
| No built-in persistence. | Components never write storage; it would break server rendering. | Controlled value plus your own storage. |
| No HTML sanitizer option. | No Inputs component renders an HTML string, so there is nothing to sanitize. | Labels and templates are ReactNode. |
| No lifecycle events or imperative teardown and refresh methods. | React owns mounting and unmounting. | Effects in your component; key to remount. |
onChange fires per edit, like the native input event, not on blur. |
It matches React and the DOM. | onBlur or onValueCommit where a component has one. |
| No method that inserts icons into the input. | Imperative DOM insertion breaks React rendering and server markup. | startAdornment / endAdornment. |
| No warning or success states. | Status colors outside the five seeds; a green border tells a screen reader nothing. | description for guidance, error state for problems. |
| No animation option. | The theme has no animation API. | One fixed transition, off under prefers-reduced-motion. |
API
Field prop |
Type |
|---|---|
children |
(field) => ReactNode; field.inputProps carries id, name, required, disabled, ARIA wiring, ref and onBlur |
value |
the control's value, for validation |
name, id, required, disabled |
forwarded through inputProps |
label, description, errorMessage, invalid, validation, validateOn, size, localeText |
shared field props |
errorPlacement |
'auto' | 'manual' ('manual' when the children render FieldError) |
requiredMark |
boolean: true marks the label while the control is required, false opts out under a Form requiredMark (Required marks) |
useFieldContext() returns the enclosing field's state (errors,
invalid, validating, ids); FieldError and FieldDescription are the
error and description parts for custom layouts.
Full signatures: @salmonui/inputs/form API reference
(Field, FieldError, FieldDescription, useFieldContext, FieldCommonProps).