Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495---// Every button on this site.//// Three kinds, by how loudly it asks:// primary the one thing this screen wants you to do// secondary the ordinary things — the default, and most of them//// One shape, and no size prop: a button takes the font of whatever it sits among, so a// button in a hint is set in the hint's type. Its padding is a fixed number of pixels, like// every other gap on this site — the box stays one size while the text inside it changes.// Chips and the (?) beside a label are buttons like any other — the only thing that makes a// chip a chip is `aria-pressed`.//// Renders an <a> when given an href and a <button> otherwise, so "go to the studio" and// "save this" can look alike without pretending to be the same kind of thing.
import type { HTMLAttributes } from "astro/types";
interface Props extends HTMLAttributes<"button"> { variant?: "primary" | "secondary"; /** Makes it a link. `type` is ignored. */ href?: string;}
const { variant = "secondary", href, type = "button", class: className, ...rest } = Astro.props;const classes = ["button", `button-${variant}`, className];---
{ href ? ( <a href={href} class:list={classes} {...rest}> <slot /> </a> ) : ( <button type={type} class:list={classes} {...rest}> <slot /> </button> )}
{/* Global rather than scoped, and it has to be: the studio's theme list and the home page's handle lookup both build buttons at runtime with `className = "button button-secondary"`. An element created by script never carries the scope attribute Astro stamps on this template, so scoped rules would miss every one of them — which is a silent failure, not a loud one. Global keeps the rules working wherever a button comes from, and keeping them in this file keeps them next to the markup they describe.
The box a pressed button draws is *not* here. It's shared with Checkbox — one mark meaning one thing — so it lives with the other shared primitives in styles/ui.css.*/}<style is:global>
.button { padding: .5em 1em; border: 1px solid; border-radius: 4px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; text-align: center; justify-content: center; text-decoration: none; background: var(--color-action-auxiliary-background); border-color: var(--color-action-auxiliary-border); color: var(--color-action-auxiliary-foreground); line-height: 1; }
.button-primary { background: var(--color-action-primary-background); border-color: var(--color-action-primary-border); color: var(--color-action-primary-foreground); }
.button-secondary { background: var(--color-action-secondary-background); border-color: var(--color-action-secondary-border); color: var(--color-action-secondary-foreground); }
.button[disabled] { opacity: 0.4; cursor: not-allowed; }
.button[style*="anchor-name"] { padding: 0; border-color: currentcolor; aspect-ratio: 1; width: 1.5em; }</style>