Mfa portal css isolation
Skill kjuhwa/skills-hub/skills/design/mfa-portal-css-isolation
Self-correcting knowledge corpus for Claude Code — 9 stable shape clusters, bias-correction pipeline baked into contribution flow. 47 papers, 45 techniques, 1.1k skills.
npx -y skills add kjuhwa/skills-hub --skill mfa-portal-css-isolationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Isolate Tailwind CSS in Module Federation portals using lazyStyleTag injection, postcss-prefix-selector with :where() specificity control, scoped root elements, and Headless UI PortalGroup
SKILL.md
3.1 KB, 636 tokens by cl100k_base, as published. Nobody here has run it
MFA Portal CSS Isolation
Problem
Tailwind's preflight resets (*, html, body) and global styles leak across Module Federation boundaries, breaking sibling remotes. Portal-based overlays (Dialog, Tooltip) render outside the scoped container, losing Tailwind styles entirely.
Steps
-
Separate webpack CSS rule for the Tailwind module:
includetargets only the Tailwind module path- Main CSS rule must
excludethe same path to avoid double-processing - Use
style-loaderwithinjectType: 'lazyStyleTag'(on-demand injection) css-loaderwithimportLoaders: 1, import: false(let PostCSS handle @import)
-
postcss-prefix-selector with
:where()wrapper:- Prefix:
:where(.nds-root)— zero specificity, overridable by host :root/:host→:where(.nds-theme)(token scoping)[data-theme="dark"]→:where(.nds-theme)[data-nds-theme="dark"](namespaced theme attributes)- Class selectors: generate both descendant and self forms (
.btn→:where(.nds-root) .btn, :where(.nds-root).btn) - Exclude
@keyframes,@property,@font-faceinternals from prefixing
- Prefix:
-
lazyStyleTag lifecycle:
portalStyles.use()on mount,portalStyles.unuse()on unmount- CSS only active while the remote is rendered
-
NdsPortalProvider — body-level portal root:
useLayoutEffectcreates<div id="nds-portal-root" class="nds-root nds-theme">on<body>- Headless UI
<PortalGroup target={portalRef}>redirects all portals useEffectsyncsdata-nds-themeattribute when theme changes- Singleton: checks for existing
#nds-portal-root(supports HMR) - React context exposes portal root for custom consumers
-
Wrap all overlay consumers:
- Every Dialog, Tooltip, Menu, Popover renders inside the PortalGroup target
- Never nest PortalProviders — one per remote boundary
Pitfalls
@keyframesmust be excluded from prefixing — scoped keyframe names break animations@property(CSS Houdini) declarations must also be excludeduseLayoutEffectnotuseEffectfor portal root — must exist before first child renderoverflow: hiddenon main container clips portals rendered as children — body-level root avoids this- Portal.Group typing: not publicly exported in Headless UI types, requires cast
- Multiple MFA remotes: each should check for existing portal root element before creating
See also
content.mdfor full webpack config, selector transform function, and provider implementation