State modifiers
Style hover, focus, disabled and other states, plus pseudo-elements like ::before and ::placeholder.
A modifier scopes a rule to a state or a part of the element. It is written before the name and ends with :.
Interaction states#
<a href="#" nib="d=inline-block; p=10px 16px; bdrd=8px; bgc=#f1f5f9; cl=#0f172a; txd=none; ftw=600; ts=all .15s;
hover:bgc=#4F52D9; hover:cl=#fff;
active:tf=scale(.97);
focus-visible:otl=3px solid #A8ABF4; focus-visible:otlo=2px">Hover, click, or Tab to me</a>Pseudo-classes#
Group | Modifiers |
|---|---|
Interaction |
|
Forms |
|
Structure |
|
Media & UI |
|
Pseudo-elements#
Modifier | Selects |
|---|---|
| generated content — set |
| input placeholder text |
| highlighted text |
| list bullets and numbers |
| typographic details |
| the button of |
| the backdrop of |
| custom scrollbars |
Select this text — and notice the arrow is generated.
<p nib="pos=relative; pl=22px; m=0; before:cnt='→'; before:pos=absolute; before:l=0; before:cl=#4F52D9; before:ftw=700; selection:bgc=#fde68a">
Select this text — and notice the arrow is generated.
</p>Forms example#
<input placeholder="you@example.com" required nib="p=10px 12px; w=260px; bdrd=8px; bd=1px solid #cbd5e1; otl=none;
placeholder:cl=#94a3b8;
focus:bdc=#4F52D9; focus:bxsh=0 0 0 3px rgba(79,82,217,.2);
user-invalid:bdc=#dc2626">Chaining#
Combine a breakpoint, dark: and any number of pseudos:
<button nib="md:dark:hover:bgc=#1e293b">@media (min-width: 768px) {
.dark .nib-x:hover { background-color: #1e293b }
}Structural styling without extra classes#
- Inbox
- Drafts
- Archive
<ul nib="lst=none; p=0; m=0; w=240px; bd=1px solid #e2e8f0; bdrd=10px">
<li nib="p=10px 14px; bdb=1px solid #e2e8f0; last-child:bdb=none">Inbox</li>
<li nib="p=10px 14px; bdb=1px solid #e2e8f0; last-child:bdb=none">Drafts</li>
<li nib="p=10px 14px; bdb=1px solid #e2e8f0; last-child:bdb=none">Archive</li>
</ul>