ShadowDOM
caution
- vite css https://github.com/vitejs/vite/issues/11855
- HeadlessUI Portal
- AntD style & portal
- react-hot-toast inject style
AntD
import React from 'react';
import { ConfigProvider as AntdConfigProvider } from 'antd';
import { StyleProvider as AntdStyleProvider } from '@ant-design/cssinjs';
import enUS from 'antd/es/locale/en_US';
const container = myShadowRootHere;
const App = () => {
return (
<AntdStyleProvider container={container}>
<AntdConfigProvider
locale={enUS}
theme={{
token: {
colorPrimary: '#000',
},
}}
>
{/* Rest of the code */}
</AntdConfigProvider>
</AntdStyleProvider>
);
};
function patchHeadlessUiPortalRoot(host) {
const portal = document.getElementById('headlessui-portal-root');
const _shadow = host.shadowRoot?.children[0];
if (_shadow && portal) {
_shadow.appendChild(portal);
return true;
}
return false;
}