---
title: "invalid-stored-variant"
description: "Reports a style.when() argument that is not a sequence of variants, or a use that can refer to several stored variants."
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.

# invalid-stored-variant

This rule reports a [`style.when()`](https://stillwind.dev/docs/macros/when) call whose argument is
not one sequence of variants. It also reports a use of a stored variant that
can refer to more than one `style.when()` call. The compiler expands stored
variants at build time, so it must know the variants exactly.

A use of an invalid stored variant adds no CSS.

## Reported

```tsx
declare const name: string;
const selected = style.when(name);
style({ [selected]: "font-bold" });
```

> invalid-stored-variant: style.when() requires one static variant sequence: the argument is not a variant string, a ref variant, or a stored variant
> 
> Example:2:29

## Fixed

```tsx
const selected = style.when("aria-selected");
style({ [selected]: "font-bold" });
```

## How to fix

- Pass a string literal of variants, a ref condition, a container query, or a
  template literal whose interpolations are ref conditions or stored variants.
- Declare a stored variant before another `style.when()` call uses it.
- To choose between stored variants at runtime, write a key for each one and
  guard the values, such as `{ [a]: active && "p-4", [b]: !active && "p-4" }`.

See [`style.when()`](https://stillwind.dev/docs/macros/when#inputs).

## Rule settings

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

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

Source: https://stillwind.dev/docs/lints/invalid-stored-variant/index.mdx
