Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import * as React from 'react';
|
|
import { prefixer } from 'stylis';
|
|
import rtlPlugin from '@mui/stylis-plugin-rtl';
|
|
import { CacheProvider } from '@emotion/react';
|
|
import createCache from '@emotion/cache';
|
|
import { styled } from '@mui/joy/styles';
|
|
import Box from '@mui/joy/Box';
|
|
import Switch from '@mui/joy/Switch';
|
|
|
|
const Normal = styled('div')`
|
|
text-align: left;
|
|
`;
|
|
|
|
const Noflip = styled('div')`
|
|
/* @noflip */
|
|
text-align: left;
|
|
`;
|
|
|
|
const rtlCache = createCache({
|
|
key: 'muirtl',
|
|
stylisPlugins: [prefixer, rtlPlugin],
|
|
});
|
|
|
|
const ltrCache = createCache({
|
|
key: 'mui',
|
|
});
|
|
|
|
export default function RtlOptOut() {
|
|
const [rtl, setRtl] = React.useState(false);
|
|
|
|
const handleChange = () => {
|
|
setRtl(!rtl);
|
|
};
|
|
|
|
return (
|
|
<Box sx={{ width: '100%', display: 'flex' }}>
|
|
<Switch onChange={handleChange} endDecorator="Toggle RTL" />
|
|
<CacheProvider value={rtl ? rtlCache : ltrCache}>
|
|
<Box sx={{ flexGrow: 1, mx: 2 }} dir={rtl ? 'rtl' : ''}>
|
|
<Normal>RTL normal behavior</Normal>
|
|
<Noflip>RTL noflip</Noflip>
|
|
</Box>
|
|
</CacheProvider>
|
|
</Box>
|
|
);
|
|
}
|