Files
vf_react/src/components/RTLProvider/RTLProvider.js
2025-10-11 16:16:02 +08:00

31 lines
1.0 KiB
JavaScript
Executable File

/*!
=========================================================
* Argon Dashboard Chakra PRO - v1.0.0
=========================================================
* Product Page: https://www.creative-tim.com/product/argon-dashboard-chakra-pro
* Copyright 2022 Creative Tim (https://www.creative-tim.com/)
* Designed and Coded by Simmmple & Creative Tim
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
import { CacheProvider } from "@emotion/react";
import createCache from "@emotion/cache";
import rtl from "stylis-plugin-rtl";
// NB: A unique `key` is important for it to work!
const options = {
rtl: { key: "css-ar", stylisPlugins: [rtl] },
ltr: { key: "css-en" },
};
export function RtlProvider({ children }) {
const dir = document.documentElement.dir == "ar" ? "rtl" : "ltr";
const cache = createCache(options[dir]);
return <CacheProvider value={cache} children={children} />;
}