MVP / foundation
Button
One clear action, native semantics, and a visible loading state. The button is the first contract test for the entire library.
Specimen
One framed specimen with Preview, Code, and Install. Copy the active panel; raw files stay linked below.
Preview
Try the violet button. It enters
data-au-state="loading", then returns a local success state.Code
button.html
<style>
.au-btn {
--au-btn-bg: transparent;
--au-btn-fg: var(--au-fg);
--au-btn-border: transparent;
--au-btn-radius: var(--au-radius-md);
--au-btn-height: 40px;
--au-btn-padding-inline: 16px;
--au-btn-gap: 8px;
appearance: none;
align-items: center;
border: 1px solid var(--au-btn-border);
border-radius: var(--au-btn-radius);
cursor: pointer;
display: inline-flex;
font-family: var(--au-font-sans);
font-size: 13px;
font-weight: 600;
gap: var(--au-btn-gap);
justify-content: center;
letter-spacing: -0.01em;
line-height: 1;
min-height: var(--au-btn-height);
padding: 0 var(--au-btn-padding-inline);
position: relative;
text-decoration: none;
transition:
background-color var(--au-duration-fast) var(--au-ease),
border-color var(--au-duration-fast) var(--au-ease),
box-shadow var(--au-duration-fast) var(--au-ease),
color var(--au-duration-fast) var(--au-ease),
transform var(--au-duration-fast) var(--au-ease);
user-select: none;
-webkit-tap-highlight-color: transparent;
}
.au-btn:hover:not(:disabled) {
background: var(--au-btn-bg-hover, var(--au-btn-bg));
border-color: var(--au-btn-border-hover, var(--au-btn-border));
color: var(--au-btn-fg-hover, var(--au-btn-fg));
}
.au-btn:focus-visible {
box-shadow: var(--au-focus-ring);
outline: 2px solid var(--au-focus);
outline-offset: 2px;
}
.au-btn:active:not(:disabled) {
transform: translateY(1px);
}
.au-btn:disabled,
.au-btn[aria-disabled="true"] {
cursor: not-allowed;
opacity: 0.48;
}
.au-btn--primary {
--au-btn-bg: var(--au-action);
--au-btn-bg-hover: var(--au-action-hover);
--au-btn-fg: var(--au-action-fg);
--au-btn-border: var(--au-action);
}
.au-btn--secondary {
--au-btn-bg: var(--au-surface);
--au-btn-bg-hover: var(--au-surface-hover);
--au-btn-border: var(--au-border-emphasis);
}
.au-btn--ghost {
--au-btn-bg: transparent;
--au-btn-bg-hover: var(--au-surface-muted);
--au-btn-border: transparent;
}
.au-btn--danger {
--au-btn-bg: var(--au-danger);
--au-btn-bg-hover: color-mix(in srgb, var(--au-danger) 86%, var(--au-fg));
--au-btn-fg: #ffffff;
--au-btn-border: var(--au-danger);
}
.au-btn--link {
--au-btn-bg: transparent;
--au-btn-bg-hover: var(--au-action-soft);
--au-btn-fg: var(--au-action);
--au-btn-border: transparent;
min-height: auto;
padding-inline: 4px;
}
.au-btn--sm {
--au-btn-height: 32px;
--au-btn-padding-inline: 12px;
font-size: 12px;
}
.au-btn--lg {
--au-btn-height: 48px;
--au-btn-padding-inline: 20px;
font-size: 14px;
}
.au-btn--icon {
--au-btn-height: 40px;
--au-btn-padding-inline: 0;
aspect-ratio: 1;
width: var(--au-btn-height);
}
.au-btn[data-au-state="loading"] {
cursor: wait;
pointer-events: none;
}
.au-btn[data-au-state="loading"]::before {
border: 1.5px solid currentColor;
border-right-color: transparent;
border-radius: 50%;
content: "";
height: 13px;
width: 13px;
animation: au-button-spin 700ms linear infinite;
}
.au-btn[data-au-state="loading"] > * {
opacity: 0.68;
}
@keyframes au-button-spin {
to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
.au-btn,
.au-btn[data-au-state="loading"]::before {
animation: none;
transition-duration: 0.01ms;
}
}
</style>
<!-- agent-ui button: requires tokens.css and button.css. No JavaScript required. -->
<button class="au-btn au-btn--primary" type="button">Run component</button>Install
head.html
<link rel="stylesheet" href="tokens.css">
<link rel="stylesheet" href="components/button/button.css">Component contract
- Dependencies
tokens.cssandbutton.css. No runtime or icon library.- Variants
primary,secondary,ghost,danger,link,icon.- States
- Native hover, focus, active, disabled;
data-au-state="loading"for pending work. - Events
- Native
clickand form events. No custom event required. - No JavaScript
- Remains keyboard-accessible and submits normal forms without
agent-ui.js. - CSS variables
--au-btn-bg,--au-btn-fg,--au-btn-border,--au-btn-radius,--au-btn-height.
Accessibility and safety
Native first
Use a native <button> for actions and a native <a> for navigation. Icon-only buttons need an accessible label. Dynamic labels stay text, never HTML.