You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/collections/pages/vite-tooling.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,14 +134,27 @@ If you want to use [Tailwind CSS](https://tailwindcss.com) in your addon's compo
134
134
135
135
You don't need to `@import "tailwindcss"`, as it'll be imported by Statamic's `tailwind.css` file.
136
136
137
-
#### Overriding Control Panel CSS
137
+
### Overriding Control Panel CSS
138
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.
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;`.
140
+
141
+
#### Overriding Control Panel CSS using Tailwind
142
+
143
+
If you use Tailwind, any CSS you add to your addon will automatically go into the `addon-utilities` layer.
140
144
141
145
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
146
143
147
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
148
149
+
#### Overriding Control Panel CSS using plain CSS
150
+
151
+
If you don't use Tailwind, you should still use the `addon-utilities` layer by default, to avoid conflicts with Statamic's core styles.
152
+
153
+
If you want to override something specific in the CP CSS and your rule is clashing with a core style, there are a couple of different approaches you can take.
154
+
155
+
1. You can simply write CSS outside cascade layers, which will have higher specificity than Statamic's styles.
156
+
2. You can also use the `!important` flag inside `@layer addon-utilities { ... }` to override Statamic's styles.
157
+
145
158
### Service Provider
146
159
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.
0 commit comments