--- title: Migrate to the Polaris switch component description: >- Learn how to migrate the Switch component to Polaris web components in checkout and customer account UI extensions. source_url: html: >- https://shopify.dev/docs/apps/build/checkout/migrate-to-web-components/switch md: >- https://shopify.dev/docs/apps/build/checkout/migrate-to-web-components/switch.md --- # Migrate to the Polaris switch component The Polaris switch component provides a toggle control for binary options. It replaces the previous [`Switch`](https://shopify.dev/docs/api/checkout-ui-extensions/2025-07/ui-components/forms/switch) component and is available as [``](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch) in API versions 2025-10 and newer. *** ## Updated properties The following properties are different in the Polaris switch component. ### on​Change The previous `Switch` `onChange` prop now receives an `Event` instead of the new boolean value. Read the checked state from `event.currentTarget.checked`. ## Migrating onChange ##### Latest (Preact) ```jsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; export default function extension() { render(, document.body); } function Extension() { return ( { console.log('Checked:', event.currentTarget.checked); }} /> ); } ``` ##### Pre-Polaris (2025-07) ```jsx import { reactExtension, Switch, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.checkout.block.render', () => , ); function Extension() { return ( console.log('Checked:', value)} /> ); } ``` ### value The previous `Switch` `value` prop was a `boolean` alias for `checked`, used to drive the controlled checked state. On the Polaris switch, use [`checked`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-checked) for controlled usage, or [`defaultChecked`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-defaultchecked) to set only the initial state for uncontrolled usage. ## Migrating value ##### Latest (Preact) ```jsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; import {useState} from 'preact/hooks'; export default function extension() { render(, document.body); } function Extension() { const [isEnabled, setIsEnabled] = useState(true); return ( setIsEnabled(event.currentTarget.checked)} /> ); } ``` ##### Pre-Polaris (2025-07) ```jsx import { reactExtension, Switch, } from '@shopify/ui-extensions-react/checkout'; import {useState} from 'react'; export default reactExtension( 'purchase.checkout.block.render', () => , ); function Extension() { const [isEnabled, setIsEnabled] = useState(true); return ( ); } ``` The Polaris switch repurposes [`value`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-value) as a `string` used as the form submission value, and it's only submitted when the switch is checked. Pair it with [`name`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-name) to participate in form submission: ## Using value for form submission ```jsx ``` *** ## Removed properties ### toggles The Polaris switch component no longer supports `toggles`. Use [`command="--toggle"`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-command) with [`commandFor`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-commandfor) instead, targeting the element you want to show or hide when the switch is toggled. | Previous value | New pattern | | - | - | | `toggles=""` | Use `command="--toggle"` with `commandFor=""` on ``. | ## Migrating toggles to command and commandFor ##### Latest (Preact) ```tsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; export default function extension() { render(, document.body); } function Extension() { return ( <> ); } ``` ##### Pre-Polaris (2025-07) ```tsx import { Disclosure, Switch, TextField, View, reactExtension, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.checkout.block.render', () => , ); function Extension() { return ( ); } ``` *** ## New properties The Polaris switch component introduces the following new properties: | New prop | Type | Description | | - | - | - | | [`command`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-command) | `'--auto'` \| `'--toggle'` \| `'--show'` \| `'--hide'` | Command to execute when toggled. | | [`commandFor`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-commandfor) | `string` | ID of the element to target. | | [`defaultChecked`](https://shopify.dev/docs/api/checkout-ui-extensions/latest/web-components/forms/switch#properties-propertydetail-defaultchecked) | `boolean` | Default checked state for uncontrolled usage. | ***