Skip to content

Commit b5be040

Browse files
committed
Add a note about Overriding Control Panel CSS
1 parent 04309cd commit b5be040

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

content/collections/pages/vite-tooling.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ If you want to use [Tailwind CSS](https://tailwindcss.com) in your addon's compo
134134
135135
You don't need to `@import "tailwindcss"`, as it'll be imported by Statamic's `tailwind.css` file.
136136
137+
#### Overriding Control Panel CSS
138+
139+
We organize our CSS using [cascade layers](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers#issues_cascade_layers_can_solve) to help manage styling priorities and avoid conflicts. Internally, we define layers in this order: `@layer base, addon-theme, addon-utilities, components, utilities, ui, ui-states;`. Any CSS you add to your addon will automatically go into the `addon-utilities` layer.
140+
141+
We intentionally place addon layers below Statamic’s core layers. This prevents addon styles from unintentionally overriding Statamic's core styles—for instance, an addon's `bg-something` class won’t interfere with Statamic's `dark:bg-something`, which could otherwise cause visual issues like incorrect background colors.
142+
143+
If you do need to explicitly override Statamic’s styles, you can use the Tailwind `!` prefix (e.g., `!lg:grid-cols-3`) to force your class to take priority, which is `!important` under the hood. However, use this technique sparingly, as it will override Statamic’s intended default styling and could introduce unintended side effects.
144+
137145
### Service Provider
138146
Here's `ServiceProvider.php`, which is the PHP entry point to your addon. You should add a `$vite` property which mirrors the paths in your `vite.config.js` file.
139147

0 commit comments

Comments
 (0)