-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
@material-ui/styles RTL support #14283
Comments
@mbrevda Yes, it does: import React from "react";
import ReactDOM from "react-dom";
import { createMuiTheme } from "@material-ui/core/styles";
import { StylesProvider, ThemeProvider, jssPreset } from "@material-ui/styles";
import { create } from "jss";
import rtl from "jss-rtl";
import Demo from "./demo";
const jss = create({ plugins: [...jssPreset().plugins, rtl()] });
const theme = createMuiTheme({
direction: "rtl"
});
ReactDOM.render(
<StylesProvider jss={jss}>
<ThemeProvider theme={theme}>
<Demo />
</ThemeProvider>
</StylesProvider>,
document.querySelector("#root")
); https://codesandbox.io/s/material-demo-3uhoj
|
Brilliant, thanks so much! |
As I understand the commonet of @mbrevda this issue can be closed. |
I thought this was staying open as a to-do for updating the docs? Otherwise, my issue is resolved, thanks. |
Yes, we will need to update the documentation. |
I think https://material-ui.com/css-in-js/advanced/#jss-plugins is already covering this. |
@eps1lon Yes, for @material-ui/core/styles, but not for @material-ui/styes. |
The linked section is about I think we can add a link to that section to https://material-ui.com/customization/css-in-js/#jss to improve discoverability. |
So we have one for |
From my perspective, we only have a single true RTL documentation page, it's the guide, that is using the legacy styles module. The other references are incomplet, following them won't be enough. |
I don't understand why not. Since our components are listening to the a custom theme then obviously people need to change the direction in that theme too. How to enable rtl with the |
No, I don't. It was a reminder to update the guide documentation once we release v4. Also, people often have a hard time to put all the pieces together. We often have to give them something working outside of the box. However, we might not need it after all. We have another problem to solve, how do we handle the default theme? |
Hi @oliviertassinari, can you test this example again? It seems not working now. |
@TrueMoein I have updated my original comment to reflect how it should be done with v4, latest. |
Hi @oliviertassinari did you test your solution with typescript cause i get this error: Argument of type '{ plugins: (Plugin | { onProcessStyle(style: any, rule: any, sheet: any): any; })[]; }' is not assignable to parameter of type 'Partial'. when i try to declare jss const. thanks |
You saved my life!!!! |
if you don't want to make the whole project right to left and you want to be able to change the direction dynamically, I have made a component to wrap your elements with it and make them direction sensitive, you can find it here: |
Does the new
ThemeProvider
have full RTL support?Expected Behavior 馃
With RTL enabled TextFileds, including labels and placeholders, should be right aligned.
Current Behavior 馃槸
TextFileds seem left aligned
Steps to Reproduce 馃暪
https://codesandbox.io/s/wq787oxnml
Your Environment 馃寧
The text was updated successfully, but these errors were encountered: