Every state a button has in CSS
Hover is the easy one. The other five are what makes it feel finished.
.button {
padding: 0.5rem 1rem;
border: 1px solid transparent;
border-radius: 0.375rem;
background: #2b6cb0;
color: white;
transition: background 120ms ease;
}
.button:hover { background: #24578f; }
.button:active { background: #1d456f; transition: none; }
.button:focus-visible {
outline: 2px solid #1d4ed8;
outline-offset: 2px;
}
.button:disabled { background: #cbd5e1; color: #64748b; cursor: not-allowed; }
How it works
:focus-visibleshows a ring for the keyboard and not for the mouse.:activeshould be instant; a transition on it feels laggy.:disabledmust look unavailable without becoming unreadable.
Keywords and builtins used here
backgroundborderbuttoncolorcursormsoutlinepaddingpxremtransition
The run, in numbers
- Lines
- 18
- Characters to type
- 413
- Tokens
- 98
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 69 seconds.
Step 1 of 2 in Controls, step 1 of 13 in Styling components.