Duostrap Switch
A Duostrap design-language extension switch built over Base Switch, supporting field compositions, RTL, and dragging.
Duostrap Switch is a design-language extension that adapts classic beveled gradients and inset track depth into a Root / Thumb anatomy while inheriting Base Switch keyboard semantics, RTL mirroring, and optional pointer dragging.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="flex flex-wrap items-center gap-6">
<div class="inline-flex items-center gap-2.5">
<proto-ui-duostrap-switch-root>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
<span class="sr-only">Airplane Mode</span>
</proto-ui-duostrap-switch-root>
<span class="text-sm font-medium">Airplane Mode</span>
</div>
<div class="inline-flex items-center gap-2.5">
<proto-ui-duostrap-switch-root default-checked>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
<span class="sr-only">Release alerts</span>
</proto-ui-duostrap-switch-root>
<span class="text-sm font-medium">Release alerts</span>
</div>
<div class="inline-flex items-center gap-2.5">
<proto-ui-duostrap-switch-root disabled>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
<span class="sr-only">Archived alerts</span>
</proto-ui-duostrap-switch-root>
<span class="text-sm font-medium">Archived alerts</span>
</div>
</div>Installation
Section titled “Installation”Currently available from workspace source via @proto.ui/prototypes-duostrap/switch. Browse the implemented subset.
import { switchRoot, switchThumb } from '@proto.ui/prototypes-duostrap/switch';<proto-ui-duostrap-switch-root default-checked> <proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb> <span class="sr-only">Release alerts</span></proto-ui-duostrap-switch-root>- Root manages the state: Supports controlled
checkedand uncontrolleddefaultChecked, click and keyboard activation, beveled hover/active feedback, focus, and disabled state. - Derived Thumb: Place inside
Rootto track on/off state, live drag percentage, anddirection, with automaticprefers-reduced-motion: reducesuppression.
Examples
Section titled “Examples”Description
Section titled “Description” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-field-root
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-duostrap-field-label>
Share across devices
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-description>
Focus is shared across devices, and turns off when you leave
the app.
</proto-ui-duostrap-field-description>
</div>
<proto-ui-duostrap-field-switch>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
</proto-ui-duostrap-field-switch>
</proto-ui-duostrap-field-root>Disabled
Section titled “Disabled” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-field-root
disabled
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-duostrap-field-label>
Disabled (off)
</proto-ui-duostrap-field-label>
</div>
<proto-ui-duostrap-field-switch>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
</proto-ui-duostrap-field-switch>
</proto-ui-duostrap-field-root>Invalid
Section titled “Invalid” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-field-root
invalid
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-duostrap-field-label>
Accept terms and conditions
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-description>
You must accept the terms and conditions to continue.
</proto-ui-duostrap-field-description>
</div>
<proto-ui-duostrap-field-switch>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
</proto-ui-duostrap-field-switch>
</proto-ui-duostrap-field-root>Draggable & RTL
Section titled “Draggable & RTL” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-duostrap-field-root
dir="rtl"
class="flex max-w-sm flex-row items-center justify-between gap-4"
>
<div class="flex min-w-0 flex-1 flex-col gap-1">
<proto-ui-duostrap-field-label>
المشاركة عبر الأجهزة
</proto-ui-duostrap-field-label>
<proto-ui-duostrap-field-description>
يتم مشاركة التركيز عبر الأجهزة، ويتم إيقاف تشغيله عند مغادرة
التطبيق.
</proto-ui-duostrap-field-description>
</div>
<proto-ui-duostrap-field-switch
direction="rtl"
draggable
default-checked
>
<proto-ui-duostrap-switch-thumb></proto-ui-duostrap-switch-thumb>
</proto-ui-duostrap-field-switch>
</proto-ui-duostrap-field-root>The following props and events belong to Root (Thumb has no props):
| Prop / Event | Type | Default |
|---|---|---|
checked | boolean undefined | uncontrolled |
defaultChecked | boolean | false |
disabled | boolean | false |
draggable | boolean | false |
direction | 'ltr' 'rtl' | 'ltr' |
checkedChange | event ({ checked: boolean }) | — |
focusSelf | method (options?: FocusRequestOptions) => void | — |