AppButton
A versatile button component with multiple variants, sizes, and states.
Install: pnpm add-component AppButton
Variants
Different styles for different contexts.
Sizes
From extra small to large.
States
Loading and disabled states.
Saving, then saved
loading, then success: the label, the spinner and the check cross-fade through AppSwap instead of snapping. The check and successLabel show for 1.2s and are announced, then the label comes back.
Hold to confirm
For a destructive action: a click does nothing, holding the button (pointer, Space or Enter) fills it, and @click fires when it is full. Let go early and it drains. Screen readers hear "Press and hold for 1.5 seconds to confirm"; with reduced motion the seconds are counted instead of the fill.
Icons & tooltips
Enhanced buttons with visual cues and hover information.
On glass
The glass prop sits the button on a refracting pane, and the variant drives it: its colour moves down into the glass, where one value tints the fill, the lit rim and the glow beneath. A danger button reads as danger from the edge in. All the variant gives up is its opaque background, which would bury the backdrop the effect is made of; ghost, outline and surface stay plain glass. Sizes, icons, loading, disabled, tooltips and the focus ring are untouched. glassTone turns the colour off without flattening the weight, and glassBlur is independent of the refraction. Pulls in AppLiquidGlass.
API
variant('primary' | 'secondary' | 'ghost' | 'muted' | 'danger' | 'success' | 'surface' | 'outline'): The visual style of the button.size('xs' | 'sm' | 'md' | 'lg'): The size of the button.icon(string): Iconify icon name to display.label(string): The text label to display.loading(boolean): The request is running: aria-busy and disabled follow it at once. The spinner (and loadingLabel) waits 150ms, then stays at least 400ms, so a fast request never flashes.hold(boolean | number): Hold to confirm: @click (and a submit) fires only after a held press of this many ms (true is 1500). Pointer, Space and Enter hold; letting go early drains the fill and emits hold-cancel; Escape resets. Under reduced motion a count replaces the fill.holdHint(string): The instruction screen readers hear through aria-describedby.disabled(boolean): Whether the button is disabled.iconOnly(boolean): Show only the icon.tooltip(string): Helpful text to show on hover.fullWidth(boolean): Stretch the button to full container width.loadingLabel(string): Accessible label shown while loading.success(boolean): Turning it on flashes the success face for 1.2s: a check and successLabel, announced politely, then back to the label. Set it when the request behind loading succeeds.successLabel(string): Label while the success face shows ("Saved"). Defaults to label.tooltipPlacement(string): Tooltip position relative to the button.glass(boolean): Sits the button on a refracting AppLiquidGlass pane. The variant drives the pane rather than being discarded — see On glass below.glassTone(boolean): Whether the variant's colour reaches the pane. Off leaves plain glass at the same weight — ghost still lighter than surface — and turns the label white, since a variant foreground has nothing left to sit against.glassBlur(number): Blur behind the glass, in px. 0 keeps the backdrop sharp and only bent, which is what separates refraction from a frosted panel. Raising it also raises the floor of the non-Chromium fallback.