Material-UI V5 RTL with stylis-plugin-rtl

标签 material-ui next.js

我将 Material UI 5 与 next.js 一起使用,并使用 emotion 和 stylis-plugin-rtl v2 实现了与此处文档完全相同的每个步骤: https://next.material-ui.com/guides/right-to-left/#heading-jss 但是在刷新页面后,我在输入中的标签跳到左边并通过单击向右移动并且在轮廓模式下边框中的标签放置是 ltr 谁能帮忙?

import rtlPlugin from 'stylis-plugin-rtl';
import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';

// Create rtl cache
const cacheRtl = createCache({
  key: 'muirtl',
  stylisPlugins: [rtlPlugin],
});

function RTL(props) {
  return <CacheProvider value={cacheRtl}>{props.children}</CacheProvider>;
}

最佳答案

我认为您应该检测您的应用何时处于 RTL 模式,然后像这样处理 createCache 选项:

const cacheRtl = createCache({
  key: isRTL ? 'muirtl' : 'muiltr',
  stylisPlugins: isRTL ? [rtlPlugin] : [],
});

关于Material-UI V5 RTL with stylis-plugin-rtl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68515939/

相关文章:

javascript - 在不滚动的情况下 react 填充剩余高度

html - 在 nextjs 中将背景图像设置为 div 不起作用

javascript - 出现错误无法解构 'protocol' 的属性 'window.location',因为它在构建时在 nextjs 应用程序中未定义

javascript - 来自 "pages/[...slug].js"的 Next.js 路由不起作用

javascript - 在 nextjs 的非 react 组件中获取状态和更新状态

javascript - 在生产中刷新页面后 Tailwind 类不起作用

html - Material UI Drawer 不会在 Appbar 下移动

reactjs - 如何将 Material UI 文本字段聚焦在按钮单击上?

javascript - 使用两个键执行自动完成 - Material UI with React

css - react JS : Apply Material-UI CssBaseline