Text Field
Takes one line of text in a native input, with the adornments, buttons and count that sit inside its border.
Printed on every invoice and packing slip.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { TextField } from '@slotted/react/text-field';export default function TextFieldBasic() { return ( <Field required> <FieldLabel>Company name</FieldLabel> <TextField autoComplete="organization" clearable defaultValue="Northwind Traders" /> <FieldDescription>Printed on every invoice and packing slip.</FieldDescription> </Field> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesimport { TextField, TextFieldAction, TextFieldDefaultsProvider } from '@slotted/react';Sizes
size sets the height, the padding, the type and the icons to one step of the control scale: sm for dense tables and toolbars, md for most forms, lg for sparse forms. Inside a field, a text field that states no size takes the field’s.
import { Glyph, Icon } from '@slotted/react/icon';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldSizes() { return ( <Stack gap={4}> <TextField aria-label="Filter order lines" placeholder="Filter order lines" size="sm" start={ <Icon> <Glyph name="search" /> </Icon> } type="search" /> <TextField aria-label="Search customers" placeholder="Search customers" size="md" start={ <Icon> <Glyph name="search" /> </Icon> } type="search" /> <TextField aria-label="Search the catalog" placeholder="Search the catalog" size="lg" start={ <Icon> <Glyph name="search" /> </Icon> } type="search" /> </Stack> );}Variants
variant sets how much frame the control draws. outline, the default, draws a border on the ground it sits on. subtle fills the control with a sunken ground. plain draws no border and no ground at rest; hover tints the ground and focus draws the ring inside the same box, so a table cell that holds one does not change size under the pointer. mono sets the value in the monospaced font with tabular figures, for identifiers, codes and keys.
import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldVariants() { return ( <Stack gap={4}> <Field> <FieldLabel>Customer</FieldLabel> <TextField defaultValue="Northwind Traders" variant="outline" /> </Field> <Field> <FieldLabel>Purchase order</FieldLabel> <TextField defaultValue="PO-2026-0412" variant="subtle" /> </Field> <Field> <FieldLabel>SKU</FieldLabel> <TextField defaultValue="NW-TEA-1042" mono variant="plain" /> </Field> </Stack> );}States
A text field inside a field reads invalid, readOnly and disabled from it. invalid sets aria-invalid on the input and draws the frame in the danger tone. readOnly sets the native readonly: the value keeps full contrast, stays focusable and selectable, and is still submitted. disabled sets the native disabled, which takes the input out of the tab order and out of form submission. A state written on the text field itself wins over the field’s.
Error:A German VAT number has nine digits after DE.
Assigned when the order was placed.
Set by the customer’s price list.
import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldStates() { return ( <Stack gap={5}> <Field invalid> <FieldLabel>VAT number</FieldLabel> <TextField defaultValue="DE 81234" /> <FieldError>A German VAT number has nine digits after DE.</FieldError> </Field> <Field readOnly> <FieldLabel>Order number</FieldLabel> <TextField defaultValue="SO-2026-00418" mono /> <FieldDescription>Assigned when the order was placed.</FieldDescription> </Field> <Field disabled> <FieldLabel>Currency</FieldLabel> <TextField defaultValue="USD" /> <FieldDescription>Set by the customer’s price list.</FieldDescription> </Field> </Stack> );}Types and keyboards
type is the input’s own: email, tel, url, search and password change the on-screen keyboard and what the browser offers to fill in. autoComplete names the value for autofill, and inputMode asks for a keyboard without changing the type, so a ZIP code takes inputMode="numeric" and keeps its leading zeros. Every native attribute you write reaches the input.
import { Field, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldTypes() { return ( <Stack gap={4}> <Field> <FieldLabel>Work email</FieldLabel> <TextField autoComplete="email" placeholder="name@northwind.com" type="email" /> </Field> <Field> <FieldLabel>Phone</FieldLabel> <TextField autoComplete="tel" placeholder="+1 206 555 0134" type="tel" /> </Field> <Field> <FieldLabel>Website</FieldLabel> <TextField autoComplete="url" placeholder="https://northwind.com" type="url" /> </Field> <Field> <FieldLabel>ZIP code</FieldLabel> <TextField autoComplete="postal-code" inputMode="numeric" placeholder="98101" /> </Field> </Stack> );}Passwords
revealable on a type="password" field draws a button that shows the characters and hides them again, keeping the caret where it was. The button keeps one name and carries its state in aria-pressed. While the password has focus and Caps Lock is on, a mark appears before the button and a screen reader hears the warning once.
At least 12 characters.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Glyph, Icon } from '@slotted/react/icon';import { TextField } from '@slotted/react/text-field';export default function TextFieldPassword() { return ( <Field required> <FieldLabel>New password</FieldLabel> <TextField autoComplete="new-password" minLength={12} revealable start={ <Icon> <Glyph name="lock" /> </Icon> } type="password" /> <FieldDescription>At least 12 characters.</FieldDescription> </Field> );}Adornments
start and end hold content before and after the value in the reading direction: a currency, a unit, a protocol, an icon or a key. They are named for the reading direction, not for a side, so in a right-to-left document start stays before the value. An icon inside them takes the control’s icon size. A Kbd shows the shortcut; binding the key is up to the application.
import { Field, FieldLabel } from '@slotted/react/field';import { Glyph, Icon } from '@slotted/react/icon';import { Kbd } from '@slotted/react/kbd';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldAdornments() { return ( <Stack gap={4}> <Field> <FieldLabel>Unit price</FieldLabel> <TextField defaultValue="24.90" end="USD" inputMode="decimal" start="$" /> </Field> <Field> <FieldLabel>Shipping weight</FieldLabel> <TextField defaultValue="1.25" end="kg" inputMode="decimal" /> </Field> <Field> <FieldLabel>Storefront address</FieldLabel> <TextField defaultValue="shop.northwind.com" start="https://" /> </Field> <TextField aria-label="Search orders" end={<Kbd>/</Kbd>} placeholder="Search orders" start={ <Icon> <Glyph name="search" /> </Icon> } type="search" /> </Stack> );}Clear button
clearable draws a button that empties the value and returns focus to the input. It appears once there is a value, and it is withdrawn while the field is empty, read-only or disabled. The change it requests carries the reason clear.
import { Glyph, Icon } from '@slotted/react/icon';import { TextField } from '@slotted/react/text-field';export default function TextFieldClearable() { return ( <TextField aria-label="Search invoices" clearable defaultValue="invoice 2026" enterKeyHint="search" start={ <Icon> <Glyph name="search" /> </Icon> } type="search" /> );}Copy button
copyable draws a button that writes the value to the clipboard, shows a check for two seconds and announces the outcome to screen readers. It stays on a read-only value, which is where an invite link, an API key or a signing secret lives. onValueCopy in React and (valueCopy) in Angular report whether the clipboard accepted the value.
Anyone with the link joins as a viewer.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldCopy() { return ( <Stack gap={5}> <Field> <FieldLabel>Invite link</FieldLabel> <TextField copyable defaultValue="https://northwind.slotted.app/join/8f3a2c" readOnly /> <FieldDescription>Anyone with the link joins as a viewer.</FieldDescription> </Field> <Field> <FieldLabel>Webhook signing secret</FieldLabel> <TextField copyable defaultValue="whsec_4f9c2a7e1b8d6350" mono readOnly /> </Field> </Stack> );}Character count
showCount publishes the length of the value to the field, which draws the count at the end of the label row. With maxLength, the browser stops input at the limit. With countMax alone, the limit is soft: the value can pass it, and the count turns to the danger tone. Type past 11 characters in the second field.
Carriers cut sender names after 11 characters.
import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';export default function TextFieldCount() { return ( <Stack gap={5}> <Field> <FieldLabel>Email subject</FieldLabel> <TextField defaultValue="Your order SO-2026-00418 has shipped" maxLength={60} showCount /> </Field> <Field> <FieldLabel>SMS sender name</FieldLabel> <TextField countMax={11} defaultValue="Northwind" showCount /> <FieldDescription>Carriers cut sender names after 11 characters.</FieldDescription> </Field> </Stack> );}Buttons inside the field
TextFieldAction in React and slTextFieldAction in Angular place a button of your own in start or end. It defaults to type="button"; write type="submit" to submit the form the field belongs to. A button named by its text is padded; one named by aria-label is square, like the clear and copy buttons. Edit the code and press Apply or Enter.
import { useState, type SubmitEvent } from 'react';import { Field, FieldDescription, FieldLabel } from '@slotted/react/field';import { TextField, TextFieldAction } from '@slotted/react/text-field';export default function TextFieldActionExample() { const [applied, setApplied] = useState(''); const apply = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); const code = new FormData(event.currentTarget).get('code'); setApplied(typeof code === 'string' ? code.trim().toUpperCase() : ''); }; return ( <form onSubmit={apply}> <Field> <FieldLabel>Discount code</FieldLabel> <TextField autoComplete="off" defaultValue="SPRING10" end={<TextFieldAction type="submit">Apply</TextFieldAction>} mono name="code" /> <FieldDescription> {applied === '' ? 'One code per order.' : `${applied} is applied to this order.`} </FieldDescription> </Field> </form> );}Menu inside the field
The action takes a menu trigger, so a choice that qualifies the value, such as a country code, opens a menu from inside the frame. The trigger stays pressed while the menu is open, and Enter, Space and ArrowDown open it from the keyboard.
import { useState } from 'react';import { Field, FieldLabel } from '@slotted/react/field';import { Glyph, Icon } from '@slotted/react/icon';import { Menu, MenuContent, MenuRadioGroup, MenuRadioItem, MenuTrigger } from '@slotted/react/menu';import { TextField, TextFieldAction } from '@slotted/react/text-field';import { VisuallyHidden } from '@slotted/react/visually-hidden';export default function TextFieldMenu() { const [country, setCountry] = useState('+1'); return ( <Field> <FieldLabel>Phone</FieldLabel> <Menu> <TextField autoComplete="tel-national" defaultValue="206 555 0134" start={ <MenuTrigger render={(props) => ( <TextFieldAction {...props}> <VisuallyHidden>Country code</VisuallyHidden> {country} <Icon> <Glyph name="chevron-down" /> </Icon> </TextFieldAction> )} /> } type="tel" /> <MenuContent> <MenuRadioGroup value={country} onValueChange={setCountry}> <MenuRadioItem value="+1">United States +1</MenuRadioItem> <MenuRadioItem value="+44">United Kingdom +44</MenuRadioItem> <MenuRadioItem value="+49">Germany +49</MenuRadioItem> <MenuRadioItem value="+81">Japan +81</MenuRadioItem> </MenuRadioGroup> </MenuContent> </Menu> </Field> );}Checking the value
loading draws a spinner before the buttons and sets aria-busy on the input while something checks the value. The input stays editable, so the reader keeps typing while the check runs. Keep loading bound to a boolean, false included, rather than removing it: the spinner keeps its place in the frame and leaves with a transition instead of disappearing. Type admin to see a handle that is taken.
Lowercase letters, digits and hyphens.
Error:
import { useEffect, useRef, useState } from 'react';import { Field, FieldDescription, FieldError, FieldLabel } from '@slotted/react/field';import { TextField } from '@slotted/react/text-field';/** Stands in for the request that checks whether a handle is free. */const TAKEN = new Set(['admin', 'northwind', 'support']);export default function TextFieldLoading() { const [handle, setHandle] = useState('northwind-ops'); const [checking, setChecking] = useState(false); const [taken, setTaken] = useState(false); const timer = useRef<ReturnType<typeof setTimeout>>(undefined); useEffect(() => () => clearTimeout(timer.current), []); const change = (next: string) => { setHandle(next); setTaken(false); clearTimeout(timer.current); setChecking(next !== ''); if (next === '') return; timer.current = setTimeout(() => { setChecking(false); setTaken(TAKEN.has(next)); }, 900); }; return ( <Field invalid={taken ? true : undefined}> <FieldLabel>Handle</FieldLabel> <TextField autoComplete="username" clearable loading={checking} onValueChange={change} spellCheck={false} start="@" value={handle} /> <FieldDescription>Lowercase letters, digits and hyphens.</FieldDescription> <FieldError live="polite" reserve> {taken ? `@${handle} is already taken.` : ''} </FieldError> </Field> );}Validation
Validate when the form is submitted, then set invalid on the field and write the error. The React example owns the value through value and onValueChange; the Angular example binds the input to a reactive form control, because slTextFieldInput is a ControlValueAccessor. Submit the empty form, then a malformed address, then a valid one.
import { useState, type SubmitEvent } from 'react';import { Button } from '@slotted/react/button';import { Field, FieldError, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { TextField } from '@slotted/react/text-field';const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;export default function TextFieldValidation() { const [email, setEmail] = useState(''); const [submitted, setSubmitted] = useState(false); const [sent, setSent] = useState(false); const error = !submitted ? '' : email.trim() === '' ? 'Enter the address the invoice goes to.' : EMAIL.test(email) ? '' : 'Enter an address in the format name@company.com.'; const submit = (event: SubmitEvent<HTMLFormElement>) => { event.preventDefault(); setSubmitted(true); setSent(EMAIL.test(email)); }; return ( <form noValidate onSubmit={submit}> <Stack gap={4}> <Field required invalid={error !== '' ? true : undefined}> <FieldLabel>Billing email</FieldLabel> <TextField autoComplete="email" onValueChange={(next) => { setEmail(next); setSent(false); }} type="email" value={email} /> <FieldError live="polite" reserve> {error} </FieldError> </Field> <Inline gap={3} align="center"> <Button type="submit">Send invoice</Button> {sent ? <span role="status">Invoice sent.</span> : null} </Inline> </Stack> </form> );}Defaults for a section
TextFieldDefaultsProvider in React and provideTextFieldDefaults in Angular set size, variant and mono once for every text field under them. A text field that states a value of its own keeps it, and inside a field the field’s size wins over the provider’s.
import { Grid } from '@slotted/react/grid';import { TextField, TextFieldDefaultsProvider } from '@slotted/react/text-field';export default function TextFieldDefaults() { return ( <TextFieldDefaultsProvider size="sm" variant="subtle"> <Grid gap={2} minItemWidth="xs"> <TextField aria-label="Customer" clearable placeholder="Customer" /> <TextField aria-label="Order number" mono placeholder="Order number" /> <TextField aria-label="Ship to city" placeholder="Ship to city" /> </Grid> </TextFieldDefaultsProvider> );}Accessibility
- There is no WAI-ARIA Authoring Practices pattern for a text field: the APG lists thirty patterns, and none of them is a single-line text input. The sources are the HTML specification for the input element, the APG practice Providing Accessible Names and Descriptions (w3.org/WAI/ARIA/apg/practices/names-and-descriptions/) for its name, and the ARIA textbox role for what may sit inside it.
- The frame has no role. WAI-ARIA requires the children of a textbox to be non-interactive and presentational, so the clear and reveal buttons are siblings of the input inside a box that announces nothing.
- The input takes its name from the field’s label, whose for attribute points at the identifier the field generates. The APG naming practice records that some combinations of browser and assistive technology compute no name from a label that wraps its control.
- Inside a required field the input carries aria-required, never the native required, because the native attribute turns on browser constraint validation and changes how the form submits. Write required on the input to opt into the platform’s validation; TextField leaves it unchanged. disabled and readonly are the native attributes.
- The clear and reveal buttons are native buttons with names you translate once through messages. Each is at least 24 CSS pixels wide at every size and density, which meets WCAG 2.2 success criterion 2.5.8. The reveal button keeps one name and carries its state in aria-pressed, which is the APG rule for a toggle button.
- The copy button announces its outcome through the shared live announcer, Copied or Copy failed, because the check that replaces the copy mark is only visible. The Caps Lock mark is hidden from assistive technology; its message is announced once when Caps Lock turns on while the password field has focus.
- loading sets aria-busy on the input and leaves it enabled, so the keyboard stays on the input while an asynchronous check runs. The spinner is hidden from assistive technology.
- A menu inside the frame follows the APG menu button pattern (w3.org/WAI/ARIA/apg/patterns/menu-button/). The menu trigger on the action supplies aria-haspopup, aria-expanded, and Enter, Space and ArrowDown to open.
- No key is bound to Escape. Some browsers clear a search input on Escape, and a text field that consumed the key inside a dialog would leave a keyboard user unable to close the dialog. WCAG success criterion 2.1.4 addresses the defects that single-key shortcuts cause.
- The invalid state does not rely on color alone: aria-invalid announces it, the field’s error states it in words, and the inline message writes a visually hidden “Error:” before the sentence. In the high-contrast scheme the border cannot carry the state, so nothing depends on it.
API
TextField
Props
valuestring- Makes the value controlled for the life of the component. Without it the input keeps its own value, and a native form reset restores defaultValue.
defaultValuestring- The value an uncontrolled text field starts from. It is read once and written to the input as the native attribute.
size'sm' | 'md' | 'lg'Defaultmd- On TextField, TextFieldDefaultsProviderThe step of the control scale. Without it the text field takes the size of the field around it, then the provider’s. Height, padding, type and icon size come from the control scales, which the theme restates for each density.
variant'outline' | 'subtle' | 'plain'Defaultoutline- On TextField, TextFieldDefaultsProviderHow much frame the control draws. plain draws no border at rest and keeps the same box, for a dense table cell.
monobooleanDefaultfalse- On TextField, TextFieldDefaultsProviderSets the value in the monospaced font with tabular figures, for identifiers, hashes and keys.
clearablebooleanDefaultfalse- Draws a button that empties the value with reason "clear" and returns focus to the input. The button is withdrawn while the value is empty, disabled or read-only.
revealablebooleanDefaultfalse- Draws a toggle that shows a password as characters. It appears only on type="password" and is withdrawn while the input is disabled.
copyablebooleanDefaultfalse- Draws a button that writes the value to the clipboard, shows a check for two seconds and announces the outcome. It is hidden while the value is empty or the input is disabled.
loadingbooleanDefaultfalse- Draws the shared spinner before the buttons and sets aria-busy on the input; the value stays editable. Once loading is set, false included, the spinner keeps its place so it can leave with a transition.
revealedboolean- Makes the password toggle controlled. defaultRevealed sets the uncontrolled starting state.
showCountbooleanDefaultfalse- Publishes the length of the value to the field around it, which draws the count at the end of its label row.
countMaxnumberDefaultmaxLength- The limit the count is measured against. Without maxLength it is a soft limit: the value can pass it, and the count turns to the danger tone before validation runs.
startReactNode- Content before the value in the reading direction. It is its own bidirectional run, and an icon inside it takes the control’s icon size.
endReactNode- Content after the value in the reading direction.
disabledbooleanDefault from the field, or false- Unset by default, so the text field takes the state of the field around it. When set, it wins, and it is the native attribute: the input leaves the tab order and form submission.
readOnlybooleanDefault from the field, or false- Unset by default, so the text field takes the state of the field around it. It is the native readonly: the input stays focusable and selectable, and its value is submitted.
invalidbooleanDefault from the field, or false- Unset by default, so the text field takes the state of the field around it. It sets aria-invalid on the input and data-invalid on the frame.
requiredboolean- The input’s own attribute, passed through unchanged; TextField never writes it. A field marks a required value with aria-required instead, because the native attribute turns on browser constraint validation.
type'text' | 'search' | 'email' | 'url' | 'tel' | 'password'Defaulttext- The input’s own type, one of the six listed. A date, a time, a month or a number is not a TextField: use date-picker (forms.md FM-16), time-picker or number-field. Other strings still reach the element for compatibility and are not supported.
messagesPartial<TextFieldMessages>- Replaces words of the active language, key by key. clear, reveal and copy name the buttons; reveal does not change with the state, because aria-pressed carries it. copied and copyFailed announce the outcome of a copy. capsLock is announced once when Caps Lock turns on in a focused password field.
Events
| Name | Payload | When |
|---|---|---|
onValueChange | (value: string, request: ChangeRequest<string>) | Before the value changes. The request carries the new value, the value it replaces, the reason ("keyboard" for an edit in the input, "clear" for the clear button), the originating event, and cancel(), which refuses the change before it commits. |
onRevealedChange | (revealed: boolean, request: ChangeRequest<boolean>) | Before the password toggle changes, with reason "pointer" or "keyboard" read from the click. A form that hides the password again on blur controls revealed and listens here. |
onValueCopy | ({ copied, reason, source, value }: TextFieldCopyDetail) | After the copy button has asked the clipboard. copied is false when the clipboard refused the value, and reason is "pointer" or "keyboard". onCopy remains the input’s native clipboard event. |
onChange, onInput, onFocus, onBlur, onKeyDown, onKeyUp | the element’s own events | Whenever the input fires them. TextField composes your handler with its own instead of replacing it: yours runs first, and always runs. |
Composition
render(props: TextFieldRootProps) => ReactNode- Renders the frame into another element and passes it every attribute. The props are typed against HTMLAttributes<HTMLElement>, so they can be spread onto a label or a fieldset. The input cannot be replaced, because it holds the value, the identifier and the wiring.
TextFieldActionComponentPropsWithRef<"button"> & { render? }Defaulttype="button"- On start, endA button you place inside the frame. Every native prop reaches the button, and render replaces it. MenuTrigger, PopoverTrigger and TooltipTrigger pass their wiring to it through their own render.
refRef<HTMLInputElement>- Reaches the input. focus(), select() and setSelectionRange() are the element’s own, so TextField adds no imperative handle.
className / stylestring / CSSProperties- Reach the frame, because the frame is what a reader sees. Every other native prop reaches the input.
TextFieldDefaultsProvider{ size, variant, mono }- On a subtreeSets size, variant and mono once for every text field under it. A field outranks it for size, so a text field inside a field takes the field’s size.
useField()() => FieldContextValue | undefined- On inside a FieldWhat TextField reads from the field around it: the identifier, the description, the disabled, read-only, invalid and required states, and the channel it publishes its count on. A text field inside a field needs no wiring of its own.
Parts
| Part | Element | Required | Purpose |
|---|---|---|---|
root | div, or the element render returns | Yes | The frame. It carries data-ui="text-field", data-size, data-variant and data-mono, and data-disabled, data-invalid, data-readonly and data-loading. It has no role: WAI-ARIA allows a textbox only non-interactive children, so the buttons sit beside the input inside a box that announces nothing. className and style reach this element. |
input | input | Yes | The control. It holds the value and the identifier, and receives every native attribute you write: type, autoComplete, inputMode, enterKeyHint, pattern, maxLength, name, form and required. ref reaches it, so focus(), select() and setSelectionRange() are the element’s own. |
start | span | No | Content before the value in the reading direction, such as a currency, an icon or an @. It is its own bidirectional run, so R$ keeps its order in a right-to-left document, and an icon inside it takes the control’s icon size. |
end | span | No | Content after the value in the reading direction, such as a unit, a domain or a suffix. |
action | button (TextFieldAction), inside start or end | No | A button you place inside the frame: a submit, a menu trigger or a tooltip trigger. It is square when named by aria-label and padded when named by its text. aria-expanded="true" keeps it pressed while the menu it opened is open. |
busy | span[data-ui="spinner"] | No | The shared spinner, before the buttons, while loading is true. It is rendered whenever loading is set and hidden while loading is false, so it can leave with a transition. It is hidden from assistive technology; aria-busy on the input carries the state. |
caps-lock | span | No | A mark in a password field while Caps Lock is on and the input has focus. It is hidden from assistive technology; the capsLock message is announced once when Caps Lock turns on. |
clear | button | No | Empties the value with reason "clear" and returns focus to the input. It is rendered while clearable is set, hidden while the value is empty or cannot be changed, and never smaller than 24 CSS pixels. |
copy | button | No | Writes the value to the clipboard, shows a check with data-complete for two seconds and announces the outcome. It stays on a read-only value and is hidden while the value is empty or the input is disabled. |
reveal | button | No | Shows the password as characters and hides it again, keeping the caret where it was. Its name does not change with its state, which is the APG rule for a toggle button; aria-pressed carries the state. |
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every text field inside it.
Text Field tokens
| Token | Default |
|---|---|
--slotted-text-field-action-active-background | var(--slotted-tone-secondary-subtle-active) |
--slotted-text-field-action-color | var(--slotted-text-muted, GrayText) |
--slotted-text-field-action-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-text-field-action-label-color | var(--slotted-text, CanvasText) |
--slotted-text-field-action-size | min(calc(var(--_icon-size) + 2 * var(--slotted-space-2, 0.25rem)), var(--_inner-size)) |
--slotted-text-field-adornment-color | var(--slotted-text-muted, GrayText) |
--slotted-text-field-autofill-background | var(--slotted-tone-accent-surface) |
--slotted-text-field-background | var(--slotted-control-surface, Field) |
--slotted-text-field-border-color | var(--slotted-control-border-color, ButtonBorder) |
--slotted-text-field-caps-lock-color | var(--slotted-tone-warning-text, CanvasText) |
--slotted-text-field-color | var(--slotted-text, CanvasText) |
--slotted-text-field-copy-complete-color | var(--slotted-tone-success-text, CanvasText) |
--slotted-text-field-disabled-background | var(--slotted-disabled-background) |
--slotted-text-field-disabled-border-color | var(--slotted-disabled-border) |
--slotted-text-field-disabled-color | var(--slotted-disabled-foreground) |
--slotted-text-field-hover-border-color | var(--slotted-tone-accent-border) |
--slotted-text-field-icon-size-min | 14px |
--slotted-text-field-invalid-border-color | var(--slotted-tone-danger-border) |
--slotted-text-field-invalid-edge-width | var(--slotted-control-invalid-edge-width, 1px) |
--slotted-text-field-invalid-focus-ring-color | var(--slotted-focus-ring-color-invalid, Highlight) |
--slotted-text-field-placeholder-color | var(--slotted-text-muted, GrayText) |
--slotted-text-field-plain-hover-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-text-field-radius | var(--slotted-control-radius, 4px) |
--slotted-text-field-readonly-background | var(--slotted-tone-secondary-subtle-hover) |
--slotted-text-field-shadow | var(--slotted-control-shadow, none) |
--slotted-text-field-subtle-background | var(--slotted-surface-sunken, Canvas) |
--slotted-text-field-subtle-border-color | var(--slotted-border-subtle, ButtonBorder) |
--slotted-text-field-subtle-hover-background | var(--slotted-tone-secondary-subtle-hover) |
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-border-subtle | Set per scheme by the theme |
--slotted-control-border-color | Set per scheme by the theme |
--slotted-control-border-width | var(--slotted-border-width-thin) |
--slotted-control-focus-ring-offset | var(--slotted-focus-ring-offset) |
--slotted-control-font-family | var(--slotted-font-family-sans) |
--slotted-control-font-size-lg | comfortable 14px · compact 13px · dense 12px |
--slotted-control-font-size-md | comfortable 13px · compact 12px · dense 12px |
--slotted-control-font-size-sm | comfortable 12px · compact 12px · dense 12px |
--slotted-control-gap-lg | comfortable 8px · compact 6px · dense 6px |
--slotted-control-gap-md | comfortable 8px · compact 6px · dense 4px |
--slotted-control-gap-sm | comfortable 6px · compact 4px · dense 4px |
--slotted-control-height-lg | comfortable 38px · compact 32px · dense 30px |
--slotted-control-height-md | comfortable 34px · compact 28px · dense 26px |
--slotted-control-height-sm | comfortable 30px · compact 26px · dense 24px |
--slotted-control-icon-size-lg | comfortable 18px · compact 16px · dense 14px |
--slotted-control-icon-size-md | comfortable 16px · compact 14px · dense 13px |
--slotted-control-icon-size-sm | comfortable 14px · compact 13px · dense 12px |
--slotted-control-inner-size-lg | comfortable 28px · compact 24px · dense 22px |
--slotted-control-inner-size-md | comfortable 24px · compact 20px · dense 18px |
--slotted-control-inner-size-sm | comfortable 22px · compact 18px · dense 16px |
--slotted-control-invalid-edge-width | var(--slotted-border-width-thin) |
--slotted-control-padding-inline-lg | comfortable 16px · compact 12px · dense 10px |
--slotted-control-padding-inline-md | comfortable 13px · compact 10px · dense 8px |
--slotted-control-padding-inline-sm | comfortable 10px · compact 8px · dense 6px |
--slotted-control-radius | var(--slotted-radius-sm) |
--slotted-control-shadow | Set per scheme by the theme |
--slotted-control-shadow-focus-geometry | 0 1px 4px -1px |
--slotted-control-surface | Set per scheme by the theme |
--slotted-control-transition-duration | var(--slotted-duration-short) |
--slotted-control-transition-easing | var(--slotted-easing-standard) |
--slotted-disabled-background | Set per scheme by the theme |
--slotted-disabled-border | Set per scheme by the theme |
--slotted-disabled-foreground | Set per scheme by the theme |
--slotted-duration-short | 120ms |
--slotted-easing-enter | cubic-bezier(0.05, 0.7, 0.1, 1) |
--slotted-easing-exit | cubic-bezier(0.3, 0, 0.8, 0.15) |
--slotted-focus-ring-color | Set per scheme by the theme |
--slotted-focus-ring-color-invalid | Set per scheme by the theme |
--slotted-focus-ring-offset | var(--slotted-border-width-thick) |
--slotted-focus-ring-width | var(--slotted-border-width-thick) |
--slotted-font-family-mono | 'Geist Mono Variable', ui-monospace, SFMono-Regular, Menlo, monospace |
--slotted-font-weight-medium | 500 |
--slotted-radius-none | 0px |
--slotted-radius-xs | 2px |
--slotted-space-2 | 0.25rem |
--slotted-space-3 | 0.375rem |
--slotted-surface-sunken | Set per scheme by the theme |
--slotted-target-comfortable | 44px |
--slotted-target-min | 24px |
--slotted-text | Set per scheme by the theme |
--slotted-text-muted | Set per scheme by the theme |
--slotted-tone-accent-border | Set per scheme by the theme |
--slotted-tone-accent-surface | Set per scheme by the theme |
--slotted-tone-danger-border | Set per scheme by the theme |
--slotted-tone-secondary-subtle-active | Set per scheme by the theme |
--slotted-tone-secondary-subtle-hover | Set per scheme by the theme |
--slotted-tone-success-text | Set per scheme by the theme |
--slotted-tone-warning-text | Set per scheme by the theme |