Setting Toggle
Every setting is a whole card: a description of the current state, helper text, and one toggle that rewrites the card copy as it flips — how Shopify settings pages breathe.
Real scenarios
The component as it is used in a product — not a specimen grid.
Flip the switch, rewrite the card
Each card owns one setting: flipping the switch rewrites the description and helper copy with it. The locked card shows how Polaris marks what the plan does not include.
Customers receive an SMS with the tracking link the moment an order ships — 124 orders today.
Shipping is always billed separately from the order total.
Refund approved orders without a manual gateway step.
Not available on the Basic planThe classic text control & raw states
Older Polaris settings end the card with a plain text button that names the action it performs; the switch itself comes in four raw states.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| enabled | boolean | 'false' | The setting's state; flipping it rewrites the card's copy as well as the toggle. |
| control | switch|link | 'switch' | Polaris's modern switch or the classic text button «on/off» at the card end. |
| disabled | state | 'false' | A locked card with a faded control and an "unavailable" note. |
Snippet
<div class="plst" x-data="{ on: false }">
<div>
<b>Order tracking by SMS</b>
<p x-text="on ? 'On — customers get a text at every step.' : 'Off'"></p>
</div>
<button class="plst-switch" x-on:click="on = !on"
x-bind:data-on="on" role="switch" x-bind:aria-checked="on"><i></i></button>
</div>
<style>
.plst { display: flex; align-items: center; gap: 16px; padding: 16px;
border-radius: 12px; background: #FFF; box-shadow: 0 1px 4px #00000012; }
.plst-switch { inline-size: 40px; block-size: 24px; border-radius: 999px;
background: #8A8A8A; border: none; cursor: pointer; }
.plst-switch[data-on='true'] { background: #008060; }
.plst-switch i { display: block; inline-size: 20px; aspect-ratio: 1; border-radius: 50%;
background: #FFF; translate: 0 0; transition: translate .15s; }
.plst-switch[data-on='true'] i { translate: 16px 0; }
</style>
// resources/js/Pages/Settings/Notifications.tsx — the toggle posts
// on flip; Inertia keeps `settings` fresh after each patch.
import { Head, router } from '@inertiajs/react';
import SettingToggle from '@/components/polaris/SettingToggle';
export default function SettingsNotifications() {
return (
<>
<Head title="Notification settings" />
{/* onValueChange={(v) => router.patch('/settings/notifications', v)} */}
<SettingToggle />
</>
);
}
import { useState } from 'react';
import '@nabuxai/ui-core/css';
export default function SettingToggle() {
const [on, setOn] = useState(false);
return (
<div className="plst">
<div>
<b>Order tracking by SMS</b>
<p>{on ? 'On — customers get the tracking link the moment an order ships.' : 'Off — customers only get emails.'}</p>
</div>
<button
className="plst-switch" role="switch" aria-checked={on} aria-label="Order tracking by SMS"
data-on={on || undefined} onClick={() => setOn(!on)}
><i /></button>
<style>{`
.plst { display: flex; align-items: center; gap: 16px; padding: 16px;
border-radius: 12px; background: #FFF; box-shadow: 0 1px 4px #00000012; }
.plst-switch { inline-size: 40px; block-size: 24px; border-radius: 999px;
background: #8A8A8A; border: none; cursor: pointer; }
.plst-switch[data-on] { background: #008060; }
.plst-switch i { display: block; inline-size: 20px; aspect-ratio: 1; border-radius: 50%;
background: #FFF; translate: 0 0; transition: translate .15s; }
.plst-switch[data-on] i { translate: 16px 0; }
`}</style>
</div>
);
}
<!-- SettingToggle.vue -->
<script setup lang="ts">
import { ref } from 'vue';
import '@nabuxai/ui-core/css';
const on = ref(false);
</script>
<template>
<div class="plst">
<div>
<b>Order tracking by SMS</b>
<p>{{ on ? 'On — customers get the tracking link the moment an order ships.' : 'Off — customers only get emails.' }}</p>
</div>
<button
class="plst-switch" role="switch" :aria-checked="on" aria-label="Order tracking by SMS"
:data-on="on ? '' : null" @click="on = !on"
><i /></button>
</div>
</template>
<style scoped>
.plst { display: flex; align-items: center; gap: 16px; padding: 16px;
border-radius: 12px; background: #fff; box-shadow: 0 1px 4px #00000012; }
.plst-switch { inline-size: 40px; block-size: 24px; border-radius: 999px;
background: #8a8a8a; border: none; cursor: pointer; }
.plst-switch[data-on] { background: #008060; }
.plst-switch i { display: block; inline-size: 20px; aspect-ratio: 1; border-radius: 50%;
background: #fff; translate: 0 0; transition: translate .15s; }
.plst-switch[data-on] i { translate: 16px 0; }
</style>
<!-- SettingToggle.svelte -->
<script lang="ts">
import '@nabuxai/ui-core/css';
let on = $state(false);
</script>
<div class="plst">
<div>
<b>Order tracking by SMS</b>
<p>{on ? 'On — customers get the tracking link the moment an order ships.' : 'Off — customers only get emails.'}</p>
</div>
<button
class="plst-switch" role="switch" aria-checked={on} aria-label="Order tracking by SMS"
data-on={on || undefined} onclick={() => (on = !on)}
><i /></button>
</div>
<style>
.plst { display: flex; align-items: center; gap: 16px; padding: 16px;
border-radius: 12px; background: #fff; box-shadow: 0 1px 4px #00000012; }
.plst-switch { inline-size: 40px; block-size: 24px; border-radius: 999px;
background: #8a8a8a; border: none; cursor: pointer; }
.plst-switch[data-on] { background: #008060; }
.plst-switch i { display: block; inline-size: 20px; aspect-ratio: 1; border-radius: 50%;
background: #fff; translate: 0 0; transition: translate .15s; }
.plst-switch[data-on] i { translate: 16px 0; }
</style>