snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
57
apps/v4/examples/base/switch-rtl.tsx
Normal file
57
apps/v4/examples/base/switch-rtl.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
|
||||
import {
|
||||
useTranslation,
|
||||
type Translations,
|
||||
} from "@/components/language-selector"
|
||||
import {
|
||||
Field,
|
||||
FieldContent,
|
||||
FieldDescription,
|
||||
FieldLabel,
|
||||
} from "@/styles/base-nova/ui-rtl/field"
|
||||
import { Switch } from "@/styles/base-nova/ui-rtl/switch"
|
||||
|
||||
const translations: Translations = {
|
||||
en: {
|
||||
dir: "ltr",
|
||||
values: {
|
||||
label: "Share across devices",
|
||||
description:
|
||||
"Focus is shared across devices, and turns off when you leave the app.",
|
||||
},
|
||||
},
|
||||
ar: {
|
||||
dir: "rtl",
|
||||
values: {
|
||||
label: "المشاركة عبر الأجهزة",
|
||||
description:
|
||||
"يتم مشاركة التركيز عبر الأجهزة، ويتم إيقاف تشغيله عند مغادرة التطبيق.",
|
||||
},
|
||||
},
|
||||
he: {
|
||||
dir: "rtl",
|
||||
values: {
|
||||
label: "שיתוף בין מכשירים",
|
||||
description: "המיקוד משותף בין מכשירים, וכבה כשאתה עוזב את האפליקציה.",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export function SwitchRtl() {
|
||||
const { dir, t } = useTranslation(translations, "ar")
|
||||
|
||||
return (
|
||||
<Field orientation="horizontal" className="max-w-sm" dir={dir}>
|
||||
<FieldContent>
|
||||
<FieldLabel htmlFor="switch-focus-mode-rtl" dir={dir}>
|
||||
{t.label}
|
||||
</FieldLabel>
|
||||
<FieldDescription dir={dir}>{t.description}</FieldDescription>
|
||||
</FieldContent>
|
||||
<Switch id="switch-focus-mode-rtl" dir={dir} />
|
||||
</Field>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user