yarn add @fluentui-contrib/react-themeless-provider
# or
npm install @fluentui-contrib/react-themeless-provider
使用量
import * as React from 'react';
import { root } from '@fluentui-contrib/react-shadow';
import { ThemelessFluentProvider } from '@fluentui-contrib/react-themeless-provider';
import { createCSSRuleFromTheme, webLightTheme, Button } from '@fluentui/react-components';
export function App() {
React.useEffect(() => {
// Example of how to create a style that will piece the shadow DOM.
// This does not need to be created by React and can be created
// by a host Web Component application for example.
const cssRule = createCSSRuleFromTheme(':root', webLightTheme);
const style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule(cssRule);
return () => {
document.head.removeChild(style);
}
}, []);
return (
{/* renders a shadow root */}
<root.div>
<ThemelessFluentProvider>
<Button>A themed Fluent React Button in shadow DOM</Button>
</ThemelessFluentProvider>
</root.div>
);
}