---
title: "no-restricted-length-units"
description: "Reports length units that your project forbids for some properties, such as px for width."
image: "https://stillwind.dev/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://stillwind.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# no-restricted-length-units

This rule reports a length with a unit that your project forbids for the
property, such as `px` for `width`. Zero lengths are not reported, because they
need no unit. The rule is off until you list properties and units.

## Configuration

```json
{
  "lint": {
    "rules": {
      "no-restricted-length-units": {
        "severity": "warn",
        "rules": [
          {
            "properties": ["width"],
            "disallow": ["px"]
          }
        ]
      }
    }
  }
}
```

## Reported

```tsx
style("w-[20px]");
```

> no-restricted-length-units: unit `px` is forbidden for `width`
> 
> Example:1:8

## Fixed

```tsx
style("w-5");
```

## How to fix

Write the same size with an allowed unit. With the default `--spacing` of
`0.25rem`, `w-5` is `1.25rem`, which is 20px at the default font size, as in the
example.

## Options

`rules` lists entries with `properties` patterns and the units to `disallow`.
When several entries match a property, the last one applies, so a later, more
specific entry can make an exception.

## Rule settings

| Preset | Severity |
| --- | --- |
| `recommended` | off |
| `strict` | off |
| `stylistic` | off |

| Option | Default |
| --- | --- |
| `checkImplementation` | `false` |
| `rules` | `[]` |

[Configure lint](/docs/configuration#lint) to change the severity or options.

Source: https://stillwind.dev/docs/lints/no-restricted-length-units/index.mdx
