---
title: Text field
description: >-
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](/docs/api/pos-ui-extensions/2025-10/polaris-web-components/forms/text-area)
component.
api_version: 2025-10
api_name: pos-ui-extensions
source_url:
html: >-
https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/forms/text-field
md: >-
https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/forms/text-field.md
---
# 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](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/forms/text-area) component.
### Support Targets (9)
### Supported targets
* [pos.cart.line-item-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/cart-details#cart-details-action-modal-)
* [pos.customer-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/customer-details#customer-details-action-modal-)
* [pos.draft-order-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/draft-order-details#draft-order-details-action-modal-)
* [pos.exchange.post.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/post-exchange#post-exchange-action-modal-)
* [pos.home.modal.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/home-screen#home-screen-action-modal-)
* [pos.order-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/order-details#order-details-action-modal-)
* [pos.product-details.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/product-details#product-details-action-modal-)
* [pos.purchase.post.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/post-purchase#post-purchase-action-modal-)
* [pos.return.post.action.render](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/targets/post-return#post-return-action-modal-)
#### Use cases
* **Product identifiers:** Collect product names, SKUs, or short identifiers.
* **Customer info:** Capture customer names, reference numbers, or brief labels.
* **Filtering:** Enable text-based filtering or tagging with short text values.
* **Form submissions:** Support single-line text values like names, codes, or identifiers.
## Examples
### Capture 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

### Add accessory buttons
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](https://shopify.dev/docs/api/pos-ui-extensions/%7BAPI_VERSION%7D/polaris-web-components/actions/button) and [s-clickable](https://shopify.dev/docs/api/pos-ui-extensions/%7BAPI_VERSION%7D/polaris-web-components/actions/clickable) components with text content in the accessory slot, enabling inline actions without leaving the input context.
### Configure 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.
### Handle 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.
### Examples
* #### Capture text input with a text field
##### Description
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.
##### Default
```html
```
* #### Add accessory buttons
##### Description
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]\(/docs/api/pos-ui-extensions/{API\_VERSION}/polaris-web-components/actions/button) and \[s-clickable]\(/docs/api/pos-ui-extensions/{API\_VERSION}/polaris-web-components/actions/clickable) components with text content in the accessory slot, enabling inline actions without leaving the input context.
##### Default
```jsx
console.log('Apply discount')}>
Apply
;
```
* #### Configure validation and guidance
##### Description
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.
##### Default
```jsx
setSku(event.currentTarget.value)}
/>
```
* #### Handle input events
##### Description
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.
##### Default
```jsx
{
console.log('Input:', event.currentTarget.value);
console.log('Current error:', event.currentTarget.error);
}}
onFocus={(event) => {
console.log('Focused with value:', event.currentTarget.value);
}}
onBlur={(event) => {
console.log('Blurred with value:', event.currentTarget.value);
}}
onChange={(event) => {
console.log('Changed to:', event.currentTarget.value);
}}
/>
```
## Properties
Configure the following properties on the text field component.
* **details**
**string**
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.
* **disabled**
**boolean**
**Default: false**
Whether the field is disabled, preventing user interaction. Use when the field is temporarily unavailable due to application state, permissions, or dependencies.
* **error**
**string**
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.
* **id**
**string**
A unique identifier for the element used for targeting with CSS, JavaScript, or accessibility features.
* **label**
**string**
The content to use as the field label that describes the text information being requested.
* **maxLength**
**number**
**Default: Infinity**
The maximum number of characters allowed in the text field.
* **placeholder**
**string**
A short hint that provides guidance about the expected value of the field.
* **required**
**boolean**
**Default: 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 `error` property to present validation errors.
* **value**
**string**
The current text content entered in the field. An empty string means no text is entered.
## Slots
The text field component supports slots for additional content placement within the field. Learn more about [using slots](https://shopify.dev/docs/api/polaris/using-polaris-web-components#slots).
* **accessory**
**HTMLElement**
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.
## Events
The text field component provides event callbacks for handling user interactions. Learn more about [handling events](https://shopify.dev/docs/api/polaris/using-polaris-web-components#handling-events).
* **blur**
**(event: CallbackEvent<"s-text-field">) => void**
Called when the element loses focus.
* **change**
**(event: CallbackEvent<"s-text-field">) => void**
Called after editing completes, typically on blur.
* **focus**
**(event: CallbackEvent<"s-text-field">) => void**
Called when the element receives focus.
* **input**
**(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.
```ts
boolean
```
* cancelable
Whether the event can be canceled.
```ts
boolean
```
* composed
Whether the event will trigger listeners outside of a shadow root.
```ts
boolean
```
* currentTarget
The element that the event listener is attached to.
```ts
HTMLElementTagNameMap[T]
```
* detail
Additional data associated with the event.
```ts
any
```
* eventPhase
The current phase of the event flow.
```ts
number
```
* target
The element that triggered the event.
```ts
HTMLElementTagNameMap[T] | null
```
## Best 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](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/forms/text-area).
* **Show character limit feedback:** When approaching `maxLength`, display remaining characters in the `details` text.
* **Write descriptive labels:** Use specific labels like "Product Name" or "Reference Code" rather than generic terms.
## Limitations
The `accessory` slot supports only [button](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/actions/button) and [clickable](https://shopify.dev/docs/api/pos-ui-extensions/2025-10/polaris-web-components/actions/clickable) components with text content only—other component types or complex layouts can't be used for field accessories.