Button·Free
Button set (HTML + CSS)
Primary, secondary, danger and quiet buttons in plain CSS, plus disabled and loading states. Each is at least 44 by 44 px with a focus ring for keyboard users. Dark mode swaps the colours and keeps the contrast.
Free to install.
If PocketCode is installed on your Android device, this opens the page in the app.
Preview
buttons.html · 77 lines
<!--
Button set in plain HTML and CSS: primary, secondary, danger and quiet, plus a loading state.
Every button is at least 44 x 44 px and shows a focus ring when reached with the keyboard.
While a request runs, set aria-busy="true" and aria-disabled="true" on the button: the label is hidden
behind a spinner but screen readers still read it. aria-disabled does not block clicks, so your click
handler should return early while aria-busy is set. Remove both attributes when it finishes.
Colours live in the CSS variables; dark mode follows the system setting.
-->
<style>
.btn {
--btn-bg: #1f5fd1;
--btn-fg: #ffffff;
--btn-border: transparent;
--btn-ring: #1f5fd1;
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 44px;
min-height: 44px;
padding: 10px 18px;
border: 1px solid var(--btn-border);
border-radius: 10px;
background: var(--btn-bg);
color: var(--btn-fg);
font: 600 15px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
text-decoration: none;
cursor: pointer;
transition: filter 0.15s ease;
}
.btn-secondary { --btn-bg: transparent; --btn-fg: #1f5fd1; --btn-border: #7c7c88; }
.btn-danger { --btn-bg: #b3261e; --btn-fg: #ffffff; --btn-ring: #b3261e; }
.btn-quiet { --btn-bg: transparent; --btn-fg: #1b1b1f; --btn-ring: #1b1b1f; }
@media (prefers-color-scheme: dark) {
.btn { --btn-bg: #8ab4ff; --btn-fg: #0b1a33; --btn-ring: #8ab4ff; }
.btn-secondary { --btn-bg: transparent; --btn-fg: #8ab4ff; --btn-border: #7c7c88; }
.btn-danger { --btn-bg: #ffb4ab; --btn-fg: #5c0f0a; --btn-ring: #ffb4ab; }
.btn-quiet { --btn-bg: transparent; --btn-fg: #ececf1; --btn-ring: #ececf1; }
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(0.92); }
.btn:focus-visible { outline: 2px solid var(--btn-ring); outline-offset: 2px; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn[aria-busy="true"] { opacity: 1; color: transparent; cursor: progress; }
.btn[aria-busy="true"]::after {
content: "";
position: absolute;
width: 18px;
height: 18px;
border: 2px solid var(--btn-fg);
border-right-color: transparent;
border-radius: 50%;
animation: btn-spin 0.8s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
.btn { transition: none; }
.btn[aria-busy="true"]::after { animation-duration: 2.4s; }
}
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
</style>
<div class="btn-row">
<button class="btn" type="button">Save changes</button>
<button class="btn btn-secondary" type="button">Cancel</button>
<button class="btn btn-danger" type="button">Delete</button>
<button class="btn btn-quiet" type="button">Skip for now</button>
<button class="btn" type="button" aria-busy="true" aria-disabled="true">Saving</button>
<button class="btn" type="button" disabled>Not available</button>
<a class="btn btn-secondary" href="#pricing">See pricing</a>
</div>Changes in 1.0.0
First version.