Skip to main content

TextField

Captures single-line text input from merchants. Use to collect short, free-form information.

string

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.

boolean
Default: false

Disables the field, disallowing any interaction.

string

Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.

string

A unique identifier for the element.

string

Content to use as the field label.

number
Default: Infinity

Specifies the maximum number of characters allowed.

string

A short hint that describes the expected value of the field.

boolean
Default: false

Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the error property.

string

The current value for the field. If omitted, the field will be empty.

Was this section helpful?

Learn more about using slots

HTMLElement

Additional content to be displayed in the field. Commonly used to display clickable text.

Was this section helpful?

Learn more about registering events

(event: <"s-text-field">) => void

Callback when the element loses focus.

(event: <"s-text-field">) => void

Callback after editing completes (typically on blur).

(event: <"s-text-field">) => void

Callback when the element receives focus.

(event: <"s-text-field">) => void

Callback when the user makes any changes in the field.

Was this section helpful?

Code

<s-text-field
label="Store name"
value="Snowdevil"
required
/>

Preview

Advanced usage patterns for TextField component

Handle TextField events: onInput, onFocus, onBlur, and onChange.

Add action buttons using the accessory slot. Only s-button and s-clickable are supported, with text content only

Common TextField props for validation, constraints, and user guidance.

Was this section helpful?

Event handling

<s-text-field
label="Product SKU"
placeholder="Enter SKU"
onInput={(event) => {
console.log('Input:', event.target.value);
console.log('Current error:', event.target.error);
}}
onFocus={(event) => {
console.log('Focused with value:', event.target.value);
}}
onBlur={(event) => {
console.log('Blurred with value:', event.target.value);
}}
onChange={(event) => {
console.log('Changed to:', event.target.value);
}}
/>