# Cascade Layers (Experimental)
URL: /react/getting-started/styling/cascade-layers
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/getting-started/styling/cascade-layers.mdx
Learn how to control the priority of Crispy styles using CSS Cascade Layers.
When using Crispy components with CSS frameworks that use CSS Cascade Layers (like Tailwind CSS 4), the following configuration is required to override Crispy component styles with the framework's utility classes:
- Use the Crispy CSS version wrapped with `@layer` directive
- Set appropriate priority between layers
CSS Cascade Layers is supported in Chrome 99+, Safari 15.4+, Firefox 97+. ([Can I Use](https://caniuse.com/css-cascade-layers))
## Overview
By default, Crispy CSS is provided without `@layer`. Unlayered styles defined without the `@layer` directive always have higher priority than layered styles. ([MDN](https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Cascade_layers#cascade_layer_precedence_order))
```css
/* Crispy component (unlayered) */
/* Has higher priority than layered styles */
.seed-floating-action-button__root {
background: var(--seed-color-bg-brand-solid);
}
/* Tailwind utility (layered) */
/* When using class="seed-floating-action-button__root bg-red-100", Crispy style has priority */
@layer utilities {
.bg-red-100 {
background-color: var(--color-red-100);
}
}
```
To solve this problem, Crispy provides CSS files separately wrapped with `@layer`.
## Configuration
### Use base.layered.css instead of base.css
```css title="style.css"
@import "@seed-design/css/base.layered.css";
```
### Customize layer order
Adjust the declaration order of `seed-base` and `seed-components` layers with other layers appropriately.
#### Tailwind CSS
When using Tailwind CSS 4 to override Crispy component styles with utility classes, the Tailwind `utilities` layer must have higher priority than the `seed-components` layer in the `@layer` declaration.
```css
@layer theme, base, seed-base, components, seed-components, utilities;
```
### Bundler configuration
Add the `seed-layered` condition to your bundler's module resolution configuration. This ensures that Crispy React components automatically use the layered version when importing CSS internally.
```ts title="vite.config.ts"
import { defineConfig } from "vite";
export default defineConfig({
resolve: {
conditions: ["seed-layered"], // [!code highlight]
},
// ...
});
```
Learn about the Vite `conditions` option.
```ts title="rsbuild.config.ts"
import { defineConfig } from "@rsbuild/core";
export default defineConfig({
resolve: {
conditionNames: ["seed-layered", "..."], // [!code highlight]
},
// ...
});
```
Learn about the Rsbuild `conditionNames` option.
```js title="webpack.config.js"
module.exports = {
resolve: {
conditionNames: ["seed-layered", "..."], // [!code highlight]
},
// ...
};
```
Learn about the Webpack `conditionNames` option.
#### Layer order issues with Chunk Splitting
When a bundler splits CSS into multiple chunks, the chunk containing `@layer seed-components { ... }` may load before other `@layer` declarations, resulting in unintended layer priority.
You can **inline the `@layer` declaration in HTML** to ensure it loads before all `` tags.
Use the [`transformIndexHtml`](https://vite.dev/guide/api-plugin#transformindexhtml) plugin hook to inject a `
```
## Crispy layer structure
Crispy uses two layers.
| Name | Content | File | Notes |
| ----------------- | --------------------------------------- | ----------------------- | ------------------------------------------------- |
| `seed-base` | Design tokens, global styles, keyframes | `base.layered.css` | Requires manual import |
| `seed-components` | Component styles | `recipes/*.layered.css` | Automatically imported with Crispy React components |
## Related Documentation
Learn how to use Crispy tokens as utility classes in Tailwind CSS.