Frameworks and libraries
Code components work with popular CSS frameworks and component libraries, though some require specific configuration for Shadow DOM compatibility. Below are setup patterns for common frameworks and libraries.
Tailwind CSS
To use Tailwind CSS with your code components, configure PostCSS to process Tailwind classes:
Shadcn/UI
Shadcn/UI is a component library built on Tailwind CSS that provides pre-built, accessible React components. It works with code components but requires path alias configuration. Follow these steps after setting up Tailwind CSS:
Configure path aliases
Shadcn/UI uses path aliases that need to be configured in your webpack setup. Add this to your webpack configuration:
For detailed webpack configuration options, see the bundling and deployment guide.
Style injection libraries
Libraries that inject styles into document.head
(like Emotion, styled-components, or other CSS-in-JS solutions) won’t work inside Shadow DOM by default. Use the Shadow DOM provider pattern below to configure these libraries.
Material UI with Emotion
Material UI uses Emotion for CSS-in-JS styling. To use Material UI or similar libraries with code components, wrap your components in a Shadow DOM provider that allows Emotion to inject styles correctly.
Shadow DOM provider
Using the Shadow DOM provider
Related resources
Learn about additional configuration options in the bundling and deployment guide.