Syntax
The complete grammar of a nib attribute: rules, separators, values, modifiers, recipes and !important.
An attribute is a list of rules separated by ;. Every rule has the same shape:
[breakpoint:][dark:][pseudo:]… name [=value] [!important]Part | Required | Examples |
|---|---|---|
Modifiers | no |
|
Name | yes | a shorthand ( |
| for properties | any valid CSS value; omitted for recipes |
| no | appended to the value |
Rules and separators#
You write | Meaning |
|---|---|
| two rules |
| the same — whitespace around |
| a trailing |
|
|
Line breaks count as whitespace, so long attributes can be wrapped:
<div nib="d=grid; g=16px;
md:gtc=1fr 1fr;
lg:gtc=repeat(3, 1fr)">Values#
The value is everything after the first =, so it may contain :, = and spaces:
<div nib="bgi=url(https://cdn.example.com/bg.png?w=1200&q=80)">
<div nib="ts=opacity .2s ease, transform .2s ease">
<div nib="gtc=repeat(auto-fit, minmax(200px, 1fr))">Values are passed to CSS unchanged — except $tokens, which are resolved first:
bd=1px solid $color.border → border: 1px solid #e2e8f0.
Names#
A name is resolved in this order:
- Your
shortcutsfrom the config. - Built-in shorthands (~290):
bgc→background-color. - Real CSS properties, passed through:
caret-color,scroll-snap-type,--my-var. - Otherwise: an unknown utility warning with suggestions, and no CSS.
A name without = is a recipe reference instead (step 4 then reports an unknown utility or component).
Modifiers#
Everything before the last : of the name part is a modifier:
- a breakpoint —
md:,lg:, or your own dark:- a pseudo-class —
hover:,focus-visible:,disabled:,first-child:, … - a pseudo-element —
before:,after:,placeholder:,selection:, …
They chain: md:dark:hover:bgc=#111. Order does not matter. See Modifiers.
!important#
<p nib="cl=#dc2626!important">.nib-1l671gr { color: #dc2626 !important }Where attributes are read#
Syntax | Where |
|---|---|
| any element, any template language |
| when a tool strips unknown attributes (some CMSs, HTML sanitisers) |
| dynamic values in frameworks |