Files
shadcn-ui/apps/v4/examples/base/card-rtl.tsx
Francesco 44c8f02d06 fix(rtl): use logical margin for password link in RTL examples
Change ml-auto to ms-auto (margin-inline-start) so the Forgot your
  password link aligns correctly in both LTR and RTL layouts.

  Fixes #9515
2026-02-03 18:36:19 +01:00

117 lines
3.4 KiB
TypeScript

"use client"
import * as React from "react"
import { Button } from "@/examples/base/ui-rtl/button"
import {
Card,
CardAction,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/examples/base/ui-rtl/card"
import { Input } from "@/examples/base/ui-rtl/input"
import { Label } from "@/examples/base/ui-rtl/label"
import {
useTranslation,
type Translations,
} from "@/components/language-selector"
const translations: Translations = {
en: {
dir: "ltr",
values: {
title: "Login to your account",
description: "Enter your email below to login to your account",
signUp: "Sign Up",
email: "Email",
emailPlaceholder: "m@example.com",
password: "Password",
forgotPassword: "Forgot your password?",
login: "Login",
loginWithGoogle: "Login with Google",
},
},
ar: {
dir: "rtl",
values: {
title: "تسجيل الدخول إلى حسابك",
description: "أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك",
signUp: "إنشاء حساب",
email: "البريد الإلكتروني",
emailPlaceholder: "m@example.com",
password: "كلمة المرور",
forgotPassword: "نسيت كلمة المرور؟",
login: "تسجيل الدخول",
loginWithGoogle: "تسجيل الدخول باستخدام Google",
},
},
he: {
dir: "rtl",
values: {
title: "התחבר לחשבון שלך",
description: "הזן את האימייל שלך למטה כדי להתחבר לחשבון שלך",
signUp: "הירשם",
email: "אימייל",
emailPlaceholder: "m@example.com",
password: "סיסמה",
forgotPassword: "שכחת את הסיסמה?",
login: "התחבר",
loginWithGoogle: "התחבר עם Google",
},
},
}
export function CardRtl() {
const { dir, t } = useTranslation(translations, "ar")
return (
<Card className="w-full max-w-sm" dir={dir}>
<CardHeader>
<CardTitle>{t.title}</CardTitle>
<CardDescription>{t.description}</CardDescription>
<CardAction>
<Button variant="link">{t.signUp}</Button>
</CardAction>
</CardHeader>
<CardContent>
<form>
<div className="flex flex-col gap-6">
<div className="grid gap-2">
<Label htmlFor="email-rtl">{t.email}</Label>
<Input
id="email-rtl"
type="email"
placeholder={t.emailPlaceholder}
required
/>
</div>
<div className="grid gap-2">
<div className="flex items-center">
<Label htmlFor="password-rtl">{t.password}</Label>
<a
href="#"
className="ms-auto inline-block text-sm underline-offset-4 hover:underline"
>
{t.forgotPassword}
</a>
</div>
<Input id="password-rtl" type="password" required />
</div>
</div>
</form>
</CardContent>
<CardFooter className="flex-col gap-2">
<Button type="submit" className="w-full">
{t.login}
</Button>
<Button variant="outline" className="w-full">
{t.loginWithGoogle}
</Button>
</CardFooter>
</Card>
)
}