# NaiveUI trap: a theme override is parsed before CSS sees it
<!--
ref: @protocol/naiveui-theme-override-parsing-trap
tags: [naive-ui, vue, css, tailwind, trap, theme, design-system]
triggers: [setting NaiveUI themeOverrides, a NaiveUI padding or margin override does nothing, card padding renders as 0, a NaiveUI button keeps its default colour, mapping design tokens into NaiveUI, a Tailwind class on a NaiveUI component does nothing]
trigger_prompt: When an agent maps design tokens into NaiveUI's themeOverrides, or is debugging a NaiveUI component that ignores an override or a utility class that looks correct.
category: reference
audience: [agent, agent-author]
version: 1
updated_at: 2026-10-10T23:54:00.651Z
-->

NaiveUI's `themeOverrides` are **not** CSS. Each value is parsed by NaiveUI first, and three different parsers mean three ways a correct-looking value is silently discarded. All three survive typecheck, build, lint and unit tests, because the value we hand over is valid — what happens to it afterwards is not visible from our side.

## 1. Every padding and margin prop is a SHORTHAND, split on whitespace

`seemly`'s `getMargin` (aliased as `getPadding`) runs `value.trim().split(/\s+/g)` and switches on the part count. So a single length containing spaces is read as a multi-value shorthand:

```ts
paddingMedium: `calc(0.25rem * 6)`   // 3 parts: "calc(0.25rem" / "*" / "6)"
// --n-padding-top: calc(0.25rem   --n-padding-bottom: 6)   --n-padding-left: *
// every side resolves to 0
```

`*` and `/` need no surrounding whitespace inside `calc()` — only `+` and `-` do. So write it space-free and it is the same length to CSS and one token to the splitter:

```ts
paddingMedium: `calc(0.25rem*6)`     // 1 part, all four sides, 24px
```

A value that genuinely needs `+` or `-` cannot be expressed this way at all; compute it in JS, or wrap it in a CSS custom property and pass `var(--x)`.

## 2. Every `border*` prop is a shorthand too

Hand one a bare colour and the declaration is invalid, so the component keeps **its own** border — which, on a button whose fill you just changed, is the old colour outlining the new one. It reads as deliberate.

```ts
borderPrimary: '#111111'              // ignored; NaiveUI's violet border stays
borderPrimary: '1px solid #111111'    // correct
```

## 3. Every STATE resolves independently

`color`, `colorHover`, `colorPressed`, `colorFocus`, `colorDisabled` — and the `textColor*` and `border*` families beside them — each fall back to NaiveUI's own default when unset. Setting the resting state only means the component changes colour mid-interaction, and the state people forget is `disabled`: the one control that cannot be used ends up the only one still in the library's accent, at full strength, louder than every usable control beside it.

Enumerate the states in a test rather than trusting a reading of the code.

## And once it is rendered: NaiveUI's CSS is UNLAYERED

NaiveUI injects component CSS as a plain `<style>`. Tailwind v4 puts utilities in `@layer utilities`. **An unlayered rule beats any layered rule regardless of specificity**, so `.n-card { width: 100% }` defeats `w-[calc(50%_-_0.5rem)]` on that same element, with no error. Any Tailwind utility aimed at a NaiveUI root element loses for every property the library sets itself. Size a wrapper instead, or wrap the library's styles in a layer; reaching for `!` on each utility teaches everyone that overriding this library always needs `!`.

## Testing it

A unit test that asserts your arithmetic proves nothing — the arithmetic was never wrong. Assert the **handoff**: that no padding value contains whitespace, that every border value starts `1px solid `, that every state in the list is defined. Then confirm the test fails against the unfixed code. The browser is the only other witness: read the computed `--n-padding-*` off a rendered component, because that is where the split becomes visible.

---

*Related: `@protocol/vue-facing-decorator-traps` · `@protocol/tailwind-v4-silent-utility-trap`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*