Field
What the user types or picks in a form. The intent decides the element (<input>, <textarea>, <select>) and sets type, inputMode and autoComplete.
Other components
Examples
A labelled field with a hint
The label is a text.label rendered as <label>. The intent sets type, inputMode and autoComplete.
Only used for signing in.
<Layout intent="layout.field" className="w-full max-w-sm">
<Text intent="text.label" as="label" htmlFor="example-email">Email</Text>
<Field intent="field.email" id="example-email" placeholder="you@example.com" aria-describedby="example-email-hint" />
<Text intent="text.caption" id="example-email-hint">Only used for signing in.</Text>
</Layout>An error
aria-invalid marks the field; the message is a feedback.error under it.
That handle is taken.
<Layout intent="layout.field" className="w-full max-w-sm">
<Text intent="text.label" as="label" htmlFor="example-handle">Handle</Text>
<Field intent="field.text" id="example-handle" defaultValue="ada" aria-invalid aria-describedby="example-handle-error" />
<Text intent="feedback.error" id="example-handle-error">That handle is taken.</Text>
</Layout>A list to pick from
field.select renders a <select>; the options are its children.
<Layout intent="layout.field" className="w-full max-w-sm">
<Text intent="text.label" as="label" htmlFor="example-zone">Time zone</Text>
<Field intent="field.select" id="example-zone" defaultValue="Europe/London">
<option>America/New_York</option>
<option>Europe/London</option>
<option>Asia/Tokyo</option>
</Field>
</Layout>Several lines
field.multiline renders a <textarea>.
<Field intent="field.multiline" aria-label="Bio" rows={3} placeholder="A few words about you" width="full" />Intents it renders
One domain, with its own page of neighbours and examples. The intent decides the element; these are the starter intents.
Field field.*
14 intentsfield.textShort free text on one line: names, titles, handles
<input type="text">field.emailAn email address
<input type="email">field.passwordA password, with room for a show/hide control. Set autoComplete="new-password" when creating one
<input type="password">field.password.shownA password field while its content is revealed
<input type="text">field.searchThe main search of a page: find people, products, anything
<input type="search">field.filterNarrows a list that is already shown, usually in a toolbar: "Search this feed"
<input type="search">field.numberA quantity or amount
<input type="number">field.rangeA value picked by sliding along a scale: volume, a playback position, a price limit. Give it min, max, value and an aria-label
<input type="range">field.urlA full web address
<input type="url">field.multilineLonger free text over several lines: bios, messages, notes
<textarea>field.checkboxA yes/no choice that is sent with a form: remember me, agree to terms. Pair with a text.label
<input type="checkbox">field.switchA setting that turns on or off immediately: show images, compact mode. Pair with a text.label
<input type="checkbox">field.selectOne value from a list too long to show as options: country, time zone. Children are <option>s
<select>field.colorAny colour, picked with the system colour picker
<input type="color">
Props
Plus its element’s usual attributes (id, onClick, aria-*, data-*) and the shared layout props below. No className or style.
intentrequiredWhat is being entered:
field.email,field.password,field.multiline...FieldIntentlabelThe label. With it, Field renders the whole
layout.field: label, field, hint and error, connected for screen readers.ReactNodehintHelp under the field (
text.caption). Needslabel.ReactNodeerrorWhat is wrong with the value (
feedback.error). Marks the field invalid. Needslabel.ReactNoderowsHeight of a multiline field, in lines.
numberchildrenFor select fields: the
<option>s.ReactNoderefReaches the underlying element.
Ref<HTMLInputElement>unsafeClassNameBypasses the intent. Needs a
// prongs-unsafe: <reason>comment on the line above, andprongs checkcounts it.string
Layout props
Where the element sits, never how it looks. Spacing between elements comes from the parent <Layout>.
alignOn text, the text alignment. On anything else, pushes it to that end of its row or column.
'start' | 'center' | 'end'widthFull width, or a maximum width.
'auto' | 'full' | 'prose' | 'sm' | 'md' | 'lg'hideBelowHidden on screens narrower than this breakpoint.
'sm' | 'md' | 'lg'showBelowShown only on screens narrower than this breakpoint.
'sm' | 'md' | 'lg'truncateOne line, cut off with an ellipsis.
booleannowrapKeeps the text on one line.
boolean
Rules
Do not pass
type: the intent sets it.Label it with
label(plushintanderror), which renders and wires the whole field; or give it anaria-labelwhen the label is visible elsewhere, like a search box.It takes the usual input attributes:
value,onChange,name,placeholder,required...