Text field
The text field component captures single-line text input. Use it to collect short, free-form information like names, titles, or identifiers.
The component supports various input configurations including placeholders, character limits, and validation. For multi-line text entry, use the text area component.
Supported targets
Supported targets
Anchor to PropertiesProperties
Configure the following properties on the TextField component.
- Anchor to detailsdetailsdetailsstringstring
The additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user. This will also be exposed to screen reader users.
- Anchor to disableddisableddisabledbooleanbooleanDefault: falseDefault: false
Whether the field is disabled, preventing user interaction. Use when the field is temporarily unavailable due to application state, permissions, or dependencies.
- Anchor to errorerrorerrorstringstring
An error message to indicate a problem to the user. The field will be given specific stylistic treatment to communicate issues that must be resolved immediately.
- Anchor to idididstringstring
A unique identifier for the element used for targeting with CSS, JavaScript, or accessibility features.
- Anchor to labellabellabelstringstring
The content to use as the field label that describes the text information being requested.
- Anchor to maxLengthmaxLengthmaxLengthnumbernumberDefault: InfinityDefault: Infinity
The maximum number of characters allowed in the text field.
- Anchor to placeholderplaceholderplaceholderstringstring
A short hint that provides guidance about the expected value of the field.
- Anchor to requiredrequiredrequiredbooleanbooleanDefault: falseDefault: false
Whether the field needs a value. This requirement adds semantic value to the field but doesn't cause an error to appear automatically. Use the
errorproperty to present validation errors.- Anchor to valuevaluevaluestringstring
The current text content entered in the field. An empty string means no text is entered.
Anchor to SlotsSlots
The text field component supports slots for additional content placement within the field. Learn more about using slots.
- Anchor to accessoryaccessoryaccessoryHTMLElementHTMLElement
The additional content to be displayed in the field. Commonly used to display clickable text or action elements. Only button and clickable components with text content only are supported in this slot. Use the
slot="accessory"attribute to place elements in this area.
Anchor to EventsEvents
The text field component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to blurblurblur(event: CallbackEvent<"s-text-field">) => void(event: CallbackEvent<"s-text-field">) => void
Called when the element loses focus.
- Anchor to changechangechange(event: CallbackEvent<"s-text-field">) => void(event: CallbackEvent<"s-text-field">) => void
Called after editing completes, typically on blur.
- Anchor to focusfocusfocus(event: CallbackEvent<"s-text-field">) => void(event: CallbackEvent<"s-text-field">) => void
Called when the element receives focus.
- Anchor to inputinputinput(event: CallbackEvent<"s-text-field">) => void(event: CallbackEvent<"s-text-field">) => void
Called when the user makes any changes in the field.
CallbackEvent
Represents the event object passed to callback functions when interactive events occur. Contains metadata about the event, including the target element, event phase, and propagation behavior.
- bubbles
Whether the event bubbles up through the DOM tree.
boolean - cancelable
Whether the event can be canceled.
boolean - composed
Whether the event will trigger listeners outside of a shadow root.
boolean - currentTarget
The element that the event listener is attached to.
HTMLElementTagNameMap[T] - detail
Additional data associated with the event.
any - eventPhase
The current phase of the event flow.
number - target
The element that triggered the event.
HTMLElementTagNameMap[T] | null
Anchor to ExamplesExamples
Anchor to Capture text input with a text fieldCapture text input with a text field
Capture single-line text input using a text field component with validation support. This example shows a basic text field with label and placeholder text.Capture text input with a text field

Capture text input with a text field
Add action buttons to the text field using the accessory slot for quick actions like clearing text or submitting input. This example shows how to use s-button and s-clickable components with text content in the accessory slot, enabling inline actions without leaving the input context.
Add accessory buttons
Anchor to Configure validation and guidanceConfigure validation and guidance
Configure common text field properties for validation, character limits, and user guidance. This example demonstrates using props like maxlength, required, helperText, and error to create a well-guided input experience with proper validation feedback.Configure validation and guidance
Anchor to Handle input eventsHandle input events
Subscribe to text field events including onInput, onFocus, onBlur, and onChange to respond to user interactions. This example shows how to handle different input events for real-time validation, autosave functionality, or dynamic form behavior.Handle input events
Anchor to Best practicesBest practices
- Use for single-line text input: Choose text field for short values like names, titles, or identifiers. For multi-line content, use text area.
- Show character limit feedback: When approaching
maxLength, display remaining characters in thedetailstext. - Write descriptive labels: Use specific labels like "Product Name" or "Reference Code" rather than generic terms.
Anchor to LimitationsLimitations
The accessory slot supports only button and clickable components with text content only—other component types or complex layouts can't be used for field accessories.