---
title: "cyclic-style-order"
description: "Reports files that import values from each other, so their CSS order cannot follow both."
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.

# cyclic-style-order

This rule reports a file whose CSS must come after another file's CSS, while
that file's CSS must also come after this file, directly or through other
files, and both files set the same property. A file must come after another
file when it imports and uses a value, such as a component or a base style,
that the other file declares. See
[CSS ordering](https://stillwind.dev/docs/concepts/css-ordering#files-that-pass-styles-to-components).

When the order forms a cycle, Stillwind keeps one of the orders, and the build
continues. The utilities that a caller passes to a component, or that a style
adds to its base, can then lose to the utilities of the other file.

The rule does not report a cycle between files that set different properties,
such as mutually recursive `Tree` and `TreeItem` components that set different
properties. The order between such files does not change any value.

## Reported

```tsx title="card.tsx"
import { style } from "stillwind/react";
import { Button } from "./button";

export function Card(props: CardProps) {
  return (
    <div {...style("rounded p-4", style.forward(props))}>
      <Button {...style("w-full")} />
    </div>
  );
}
```

```tsx title="button.tsx"
import { style } from "stillwind/react";
import { Card } from "./card";

export function Button(props: ButtonProps) {
  return <Card {...style("p-2", style.forward(props))} />;
}
```

`card.tsx` imports `Button`, and `button.tsx` imports `Card`. Both files set
`padding`.

## How to fix

- Move the shared parts to a file that neither file imports from, so that the
  imports go in one direction.
- Or remove the property from the styles of one file.
- Or remove the import in one direction, for example by passing the component
  as a prop or a slot.

## Rule settings

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

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

The CLI and the editor report this rule only when they analyze the whole project.

Source: https://stillwind.dev/docs/lints/cyclic-style-order/index.mdx
