简体   繁体   中英

Can I change the position of label in MUI?

I'm using Material UI for react,I want to change the place of label in text fields and bring it to the right, but because it has motion it doesn't look good how can I change that? 在此处输入图片说明 I want it to be like this but the white part doesn't move.

Solution for MUI v5

  1. Add dir attribute to your body tag or any container where you want to apply rtl direction styles.
  2. Set the direction
const theme = createTheme({
  direction: 'rtl',
});
  1. Install stylis-plugin-rtl
  2. Load the rtl plugin and wrap it around your components
const cacheRtl = createCache({
  key: 'muirtl',
  stylisPlugins: [rtlPlugin],
});

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

Working demo

Source MUI v5

Source MaterialUI v4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM