Skip to content

Variables not being read after loading tailwind inside a container #17742

Discussion options

You must be logged in to vote

but can you point me towards the correct way of scoping tailwind to a container so that it does not affect anything outside it?

Ah, yep, you can do this by ejecting from the default imports and scoping the utility layer relying on CSS nesting, so instead of:

@import "tailwindcss";

You'd do:

@layer theme, base, components, utilities;

@import "tailwindcss/theme.css" layer(theme);
@import "tailwindcss/preflight.css" layer(base);

@layer utilities {
  .plugin-container { 
    @tailwind utilities;
  }
}

This will insert all utilities in the place where @tailwind utilities; is located which will be inside the utilities layer but also require a .plugin-container class in the parent tree!

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@shivankacker
Comment options

@philipp-spiess
Comment options

Answer selected by shivankacker
@shivankacker
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #17741 on April 22, 2025 10:11.