Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL support while using MUI and PigmentCSS instead of emotion #339

Open
Hadi-bakhshi opened this issue Dec 4, 2024 · 0 comments
Open

RTL support while using MUI and PigmentCSS instead of emotion #339

Hadi-bakhshi opened this issue Dec 4, 2024 · 0 comments
Assignees
Labels
package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Hadi-bakhshi
Copy link

Hadi-bakhshi commented Dec 4, 2024

Issue description

I’m trying to use MUI with PigmentCSS. As you mentioned that RTL support is available, we followed your guide. Our configuration is provided below. However, we were unable to fully enable RTL. What should we do?

next.config.ts:

import { composePlugins, withNx } from "@nx/next";
import { withPigment } from "@pigment-css/nextjs-plugin";
import { pigmentConfig } from "./src/theme/theme";
/**
 * @type {import('@nx/next/plugins/with-nx').WithNxOptions}
 **/
const nextConfig = {
  nx: {
    // Set this to true if you would like to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: false,
  },
};

const plugins = [
  // Add more Next.js plugins to this list if needed.
  withNx,
];

export default composePlugins(...plugins)(withPigment(nextConfig, pigmentConfig));

pigment config:

export const pigmentConfig: PigmentOptions = {
  transformLibraries: ["@mui/material"],
  theme: createTheme({
    direction: "rtl",
    cssVariables: {
      colorSchemeSelector: "class",
      cssVarPrefix: "nyx",
    },
  }),
  css: {
    defaultDirection: "rtl",
    generateForBothDir: false,
  },
};

layout.tsx

import "./global.scss";
import "@mui/material-pigment-css/styles.css";
import InitColorSchemeScript from "@mui/material/InitColorSchemeScript";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="fa" dir="rtl" className="light">
      <body>
        <InitColorSchemeScript attribute="class" defaultMode="light" />
        {children}
      </body>
    </html>
  );
}

component I'm using material components:

import { TextField, Typography } from "@mui/material";
import Box from "@mui/material-pigment-css/Box";
import React from "react";

const TestCompo = () => {
  return (
    <Box sx={{ display: "flex", flexDirection: "column", height: "100%", gap: "10px", marginTop: "1rem" }}>
      <TextField label="عنوان به صورت تستی" />
      <TextField label="شماره دو" />
      <TextField label="شماره 3" />
      <Typography>درود بر همگی</Typography>
    </Box>
  );
};

export default TestCompo;

Current behavior

Problem screenshot:

image

Expected behavior

image

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: rtl in mui with pigmentcss

@Hadi-bakhshi Hadi-bakhshi added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 4, 2024
@zannager zannager added the package: system Specific to @mui/system label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants