HextaUI

Switch: Right to left

The thumb starts on the right and slides left, and dragging follows.

import { Switch } from "@/components/ui/switch"

export function SwitchRtl() {
  return (
    <div dir="rtl" className="flex flex-col gap-4 text-sm">
      <label className="flex items-center gap-3">
        <Switch defaultChecked icons />
        الإشعارات
      </label>
      <label className="flex items-center gap-3">
        <Switch />
        الوضع الداكن
      </label>
    </div>
  )
}

This adds the example as components/examples/switch/rtl.tsx, together with the Switch component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/switch-rtl.json

To add only the component, follow the Switch installation.

Props in this example

The Switch props this example sets, from the API reference.

PropTypeDefault
defaultChecked
booleanfalse
iconsShow on and off marks in the track.
booleanfalse

Every prop is in the Switch API reference.

See them all, with keyboard support and accessibility notes, on the Switch page.