-
|
When building RTL applications (Arabic, etc.), there's a common UX pattern where technical input fields should remain left-to-right even in RTL mode:
According to RTL Styling:
// In an RTL context (Arabic)
<TextField>
<Label>البريد الإلكتروني</Label> {/* Right-aligned */}
<Input
type="email"
placeholder="أدخل البريد الإلكتروني" {/* Right-aligned */}
value="user@example.com" {/* Should stay left-aligned */}
/>
</TextField>Does React Spectrum or React Aria Components have built-in support for this pattern? If not:
Currently, we're manually doing: const { i18n } = useTranslation();
const isRTL = i18n.dir() === 'rtl';
<Input
type="email"
dir={isRTL ? 'ltr' : undefined}
style={isRTL ? { textAlign: 'left' } : undefined}
/>Would appreciate any guidance on the best practice here!
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Thanks for the very interesting discussion and link. I'm following up with our globalisation team because I do not know enough about the topic to make a recommendation yet. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @snowystinger maybe your link https://codesandbox.io/p/sandbox/react-aria-components-4clgcv?file=%2Fsrc%2FApp.js%3A12%2C27 is out of date, Can you help me double check again for i can fork your example to see it |
Beta Was this translation helpful? Give feedback.
Hi @snowystinger, I can workaround with this way before (from your CodeSandbox). Thanks for support!