Skip to main content

ShadowDOM

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;
}

Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.