Inputs
Text field
A text field takes a short typed value, such as a description or an amount, under a label that stays visible above it; use it when the answer can't be picked from a list.
In kanso-ui as TextField
Variants and sizes
- Default (
k-field,k-field__input): 48px (size-control-lg), for phones and roomy web forms. - Amount (
k-field__input--mono):font-monowith tabular figures, so 12.50 and 241.86 line up; the unit goes in the label, "Amount (R$)". - Multiline (
textarea.k-field__input): at least 96px tall; the person can drag it taller. - Compact (
k-field--compact): 40px (size-control-md), for dense web forms only. - Error (
k-field--error): see States.
States
- Rest: a 1px
outlineborder onsurface. Hover changes only the cursor. - Focus: a 2px
focus-ringring 1px outside, and aninkborder. It shows on every focus, pointer or keyboard, since typing goes there. - Filled: the value in
inkreplaces the placeholder. - Error: a 2px
criticalborder, and the helper line becomes the message incritical, after theerroricon. Never red alone: about 1 in 12 men has a colour vision deficiency, and in dark modecriticalis a pale pink, so the error also thickens the border, adds a shape and says the fix: "Enter an amount, like 12.50". It iscritical, nevernegative, so a broken field can't read as a debt. - Disabled: don't disable a field; show a fixed value as text and say why.
Do and don’t
Do
Keep the label above the field, visible while the person types.
Use the placeholder for an example value, like "Coffee with Ada".
Write the error as the fix: "Enter an amount, like 12.50", not "Invalid value".
Don’t
Put rules or instructions in the placeholder; use helper text.
Flag an error while the person is still typing; check on leaving the field or on save.
Use compact fields on phones.
What you provide
- Label (required) and an
id; the value; a placeholder example (optional). - Helper text (optional), and the error message when the value is invalid.
- Input type and
inputmode; multiline or compact.