# useLayeredStyles

Rule `biome/useLayeredStyles`. Enforce style rules to be defined within a cascade layer.

- Source: biome
- Technologies: CSS
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1959 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `nursery/useLayeredStyles` | no | no | group nursery, since 2.5.13 | [docs](https://biomejs.dev/linter/rules/use-layered-styles/) |

## Code examples

### Incorrect: the rule reports this

```css
.my-style {
  color: red;
}
```

```css
@media (min-width: 600px) {
  .my-style {
    color: red;
  }
}
```

```css
@import "foo.css";
```

### Correct: the rule accepts this

```css
@layer {
  .my-style {
    color: red;
  }
}
```

```css
@layer base {
  .my-style {
    color: red;
  }
}
```

```css
@layer base {
  @media (min-width: 600px) {
    .my-style {
      color: red;
    }
  }
}
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useLayeredStyles": "error"
      }
    }
  }
}
```

## Related rules

- [biome/useJsonImportAttributes](https://lintradar.dev/rules/biome/useJsonImportAttributes.md): Enforces the use of `with { type: "json" }` for JSON module imports.
- [biome/useLogicalProperties](https://lintradar.dev/rules/biome/useLogicalProperties.md): Prefer logical CSS properties over physical properties.
- [biome/useDisposables](https://lintradar.dev/rules/biome/useDisposables.md): Detects a disposable object assigned to a variable without using or await using syntax.
- [biome/useNamedLayer](https://lintradar.dev/rules/biome/useNamedLayer.md): Disallow anonymous cascade layers.
- [biome/useDeprecatedDate](https://lintradar.dev/rules/biome/useDeprecatedDate.md): Require a valid deletion date on the `@deprecated` directive.
- [biome/usePackageJsonCpu](https://lintradar.dev/rules/biome/usePackageJsonCpu.md): Require the `cpu` field in `package.json`.

---

Web page: https://lintradar.dev/rules/biome/useLayeredStyles. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
