How can I set direction for a single component? #6334
Answered
by
atareversei
mohammad-reza-rahbar
asked this question in
Q&A
-
Hello. I could change the direction globally to RTL using DirectionProvider. But there are situations where a component or a part of it must be LTR. For example username and password fields and numbers are almost always LTR. Now how can I change a TextInput direction (not its label or errors, although it would be nice to change them too) to LTR when the global direction is RTL? |
Beta Was this translation helpful? Give feedback.
Answered by
atareversei
Jun 4, 2024
Replies: 1 comment
-
Hi. I do it by defining a global CSS class like: /* you can target label and error text by using the classNames provided at each component's styles API.
For instance, input style props: https://mantine.dev/core/input/?t=styles-api
Here I am just targeting the input field itself */
.ltr-input .mantine-TextInput-input {
direction: ltr;
text-align: left;
} Then, when I need the input to be ltr I just use the className: <TextInput
className="ltr-input"
label={l.dash.cust.createCustomerEmailLabel}
{...form.getInputProps('email')}
/> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mohammad-reza-rahbar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi. I do it by defining a global CSS class like:
Then, when I need the input to be ltr I just use the className:
And the result looks like this: