-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[v4] Styles are not applied to the "container" class #13129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am using SvelteKit and I can comfirm this. |
Using Vite with nuxt with same problem |
I guess it is not implemented yet, I don't see it in the packages/tailwindcss/src/utilities.ts. |
Has any decision been made regarding adding this class? I think it is a very useful and widely used class. |
What could we use to replace the container while you guys figure out how to tackle the inclusion of the container? |
up |
I made the below suggestion in closed PR #13395 (comment), but I think it's more relevant here:
|
Hey folks! We've decided to bring back the One change though is that we do want to make the configuration more CSS-y. In order to make it centered or padded, you can do this now by creating a custom @import "tailwindcss";
@utility container {
margin-inline: auto;
padding-inline: 1rem;
@media (width >= theme(--breakpoint-sm)) {
padding-inline: 2rem;
}
} We will be following-up with some work to make the change backward compatible with your existing v3 JS config, including a codemod that you can run to migrate the v3 JS config to CSS. |
Closes #13129 We're adding back the v3 `container` component, this time as a utility. The idea is that we support the default `container` behavior but we will not have an API to configure this similar to what v3 offered. Instead, the recommended approach is to configure it by creating a custom utility like so: ```css @import "tailwindcss"; @Utility container { margin-left: auto; margin-right: auto; padding-left: 2rem; padding-right: 2rem; } ``` We do have an idea of how to migrate existing JS configuration files to the new `@utility` as part of the interop layer and the codemod. This is going to be a follow-up PR though. ## Test Plan We added a unit test but we've also played around with it in the Vite playground. Yep, looks like a `container`: https://github.com/user-attachments/assets/ea7a5a4c-4cde-4ef5-9062-03e16239eb85 --------- Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
It still occurs on v4.0.0 for SvelteKit + Vite. It works for @import 'tailwindcss';
.container {
margin-inline: auto;
padding-inline: 1rem;
}
@theme {
// ...
} |
@gskierk I have the very same thing with astro, it works in dev mode and fails on prod. And same workaround. Interestingly, I have another astro project with very similar structure, almost same deps and same versions of libs. And there the container preserves the margins and paddings in prod mode. Cannot explain this |
I've noticed that the TW "--minify" option (often done on Production and not Dev - for speed reasons), can change the order of declarations within the CSS and therefore leads to changes in specificity (meaning that things are overridden or not) that can be different from when not minified. |
Same here. In Dev @utility container-size {
@apply container max-w-screen-xl mx-auto;
}
@utility container-wrap {
@apply container-size px-4 md:px-8;
}
|
Did you ever find a solution? |
@cp-bwg I ended using the important flag: @utility container-size {
@apply container max-w-screen-xl! mx-auto;
} |
What version of Tailwind CSS are you using?
v.next
What build tool (or framework if it abstracts the build tool) are you using?
vite (v5.1.5), @builder.io/qwik (v1.5.1), @builder.io/qwik-city (v1.5.1), @tailwindcss/vite (v.next)
What version of Node.js are you using?
v20.9.0
What browser are you using?
Chrome, Safari, Edge
What operating system are you using?
macOS
Reproduction URL
https://codesandbox.io/p/devbox/peaceful-hertz-jx9sd2?file=%2Fsrc%2Froutes%2Findex.tsx
Describe your issue
In TailwindCSS version 4, it seems that the styles of the "container" class are not loaded. In previous versions the "container" class works correctly.
The text was updated successfully, but these errors were encountered: