--- title: Using Polaris web components description: Polaris web components are Shopify's UI toolkit for building interfaces that match the Shopify Point of Sale design system. This toolkit provides a set of custom HTML elements (web components) that you can use to create consistent, accessible, and performant user interfaces for the POS UI Extensions. api_version: 2025-10 api_name: pos-ui-extensions source_url: html: https://shopify.dev/docs/api/pos-ui-extensions/latest/using-polaris-components md: https://shopify.dev/docs/api/pos-ui-extensions/latest/using-polaris-components.md --- # Using Polaris web components Polaris web components are Shopify's UI toolkit for building interfaces that match the Shopify Point of Sale design system. This toolkit provides a set of custom HTML elements (web components) that you can use to create consistent, accessible, and performant user interfaces for the POS UI Extensions. *** ## Styling Polaris web components come with built-in styling that follows Shopify's design system. The components will automatically apply the correct styling based on the properties you set and the context in which they are used. For example, headings automatically display at progressively less prominent sizes based on how many levels deep they are nested inside of sections. All components inherit a merchant's brand settings and the CSS cannot be altered or overridden. ### Examples * #### Example ##### JSX ```jsx Content ; ``` ## Custom layout When you need to build custom layouts you can use `s-stack` and `s-box`. * `s-stack` do not include spacing between children by default. To apply white space between children use the `gap` property * When `s-stack` is `direction="inline"` it will automatically wrap children to a new line when space is limited. ## Scale Our components use a middle-out scale for multiple properties like `padding`, `size` and `gap`. Our scale moves from the middle out: * `small-300` is smaller than `small-100` * `large-300` is bigger than `large-100` * `small-100` and `large-100` have aliases of `small` and `large` * `base` is the default value ### Examples * #### Example ##### Default ```ts export type Scale = | 'small-300' | 'small-200' | 'small-100' | 'small' // alias of small-100 | 'base' | 'large' // alias of large-100 | 'large-100' | 'large-200' | 'large-300'; ``` ## Variant tone and color The `tone` is used to apply a group of color design tokens to the component such as `critical`, `success` or `info`. The `color` adjusts the intensity of the `tone` making it more `subdued` or `strong`. The `variant` is used to change how the component is rendered to match the design language this is different for each component. ### Examples * #### Example ##### Default ```jsx Primary Critical Button Success Strong Badge ``` ## Using with Preact For UI Extensions, Shopify provides Preact as the framework of choice. Using Polaris web components with Preact is very similar to using them with React. ### Examples * #### Example ##### JSX ```jsx export function ProductExtension() { return ( Enable special pricing ); } ``` ## Properties vs attributes Polaris web components follow the same property and attribute patterns as standard HTML elements. Understanding this distinction is important for using the components effectively. Key concepts 1. **Attributes** are HTML attributes that appear in the HTML markup. 2. **Properties** are JavaScript object properties accessed directly on the DOM element. 3. Most attributes in Polaris web components are reflected as properties, with a few exceptions like `value` and `checked` which follow HTML's standard behavior. How JSX properties are applied When using Polaris web components in JSX, the framework determines how to apply your props based on whether the element has a matching property name. If the element has a property with the exact same name as your prop, the value is set as a property. Otherwise, it's applied as an attribute. Here's how this works in pseudocode: Examples For Polaris web components, you can generally just use the property names as documented, and everything will work as expected. ### Examples * #### ## Handling events Handling events in UI extensions are the same as you would handle them in a web app. You can use the `addEventListener` method to listen for events on the components or use the `on[event]` property to listen for events from the components. When using Preact, event handlers can be registered by passing props beginning with `on`, and the event handler name is case-insensitive. For example, the JSX `` registers `fn` as a "click" event listener on the button. ### Examples * #### Handling events ##### JSX ```jsx export default function HandlingEvents() { const handleClick = () => { console.log('s-button clicked'); }; return Click me; } // or export default function HandlingEvents() { const handleClick = () => { console.log('s-button clicked'); }; const button = document.createElement('s-button'); button.addEventListener('click', handleClick); document.body.appendChild(button); } ``` ## Slots Slots allow you to insert custom content into specific areas of Polaris web components. Use the `slot` attribute to specify where your content should appear within a component. Key points: * Named slots (e.g., `slot="title"`) place content in designated areas * Multiple elements can share the same slot name * Elements without a slot attribute go into the default (unnamed) slot ### Examples * #### Examples ##### Banner ```jsx The order has been created successfully. View order ; ``` ## Commands Commands provide a declarative way for components to control other components without JavaScript. Using the `commandFor` and `command` properties, you can create interactive behaviors directly in your markup. Key points: * `commandFor` specifies the ID of the target component to control * `command` defines the action to perform on the target (e.g., `--toggle`, `--show`, `--hide`) * Commands work with components that support being controlled (like modals, popovers, and other interactive elements) * The default command is `--auto`, which performs the most appropriate action for the target component * No JavaScript event handlers are required—the browser handles the interaction automatically ### Examples * #### Examples ##### Commands ```jsx {/* Modal that will be controlled by the buttons */} This modal is controlled using the commands API. No JavaScript event handlers are needed—the browser handles all interactions automatically. {/* Button inside modal that can hide it */} Close {/* Button controls using different command actions */} Modal Controls {/* Toggle button - most common use case */} Toggle Modal {/* Explicit show button */} Show Modal {/* Explicit hide button */} Hide Modal {/* Auto command (default) - performs the most appropriate action */} Auto Command (Toggle) ```