Button
A native <button> with Glaceon’s control tokens applied. No state machine: a button’s behaviour is the browser’s, so this is a CSS-only primitive with full attribute passthrough.
Interactive Preview
Section titled “Interactive Preview”import { Button } from "@/components/ui/button";
export function Actions() { return ( <div className="flex gap-2"> <Button>Save Changes</Button> <Button variant="ghost">Cancel</Button> <Button variant="warn" size="sm">Delete</Button> </div> );}<script lang="ts"> import Button from "@/components/ui/button.svelte";</script>
<div class="flex gap-2"> <Button>Save Changes</Button> <Button variant="ghost">Cancel</Button> <Button variant="warn" size="sm">Delete</Button></div>import { Button } from "@/components/ui/button";
export function Actions() { return ( <div class="flex gap-2"> <Button>Save Changes</Button> <Button variant="ghost">Cancel</Button> <Button variant="warn" size="sm">Delete</Button> </div> );}Installation
Section titled “Installation”Run the Glaceon CLI in your project root to copy the styled wrapper into your components directory:
npx @glaceon/cli add button --framework react # or svelte, solidInstall class merging utilities:
bun add clsx tailwind-mergeCopy the implementation directly into your project:
import type { ButtonHTMLAttributes } from "react";import { cn } from "./cn";
export type ButtonVariant = "primary" | "ghost" | "warn";export type ButtonSize = "md" | "sm";
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> { variant?: ButtonVariant; size?: ButtonSize;}
const base = "inline-flex items-center justify-center gap-2 rounded-md border font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50";
const variants: Record<ButtonVariant, string> = { primary: "border-green bg-green text-on-green hover:border-green-deep hover:bg-green-deep", ghost: "border-green bg-transparent text-green-deep hover:bg-green-soft", warn: "border-danger bg-transparent text-danger hover:bg-danger-bg",};
const sizes: Record<ButtonSize, string> = { md: "h-11 px-4 text-sm", sm: "h-9 px-3 text-xs",};
export function Button({ variant = "primary", size = "md", className, type = "button", ...props}: ButtonProps) { return ( <button type={type} {...props} className={cn(base, variants[variant], sizes[size], className)} /> );}<script lang="ts"> import type { Snippet } from "svelte"; import { cn } from "./cn";
type Variant = "primary" | "ghost" | "warn"; type Size = "md" | "sm";
interface Props { variant?: Variant; size?: Size; type?: "button" | "submit" | "reset"; class?: string; disabled?: boolean; children?: Snippet; }
const { variant = "primary", size = "md", type = "button", class: className, disabled = false, children, ...rest }: Props = $props();
const base = "inline-flex items-center justify-center gap-2 rounded-md border font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50";
const variants: Record<Variant, string> = { primary: "border-green bg-green text-on-green hover:border-green-deep hover:bg-green-deep", ghost: "border-green bg-transparent text-green-deep hover:bg-green-soft", warn: "border-danger bg-transparent text-danger hover:bg-danger-bg", };
const sizes: Record<Size, string> = { md: "h-11 px-4 text-sm", sm: "h-9 px-3 text-xs", };</script>
<button {type} {disabled} {...rest} class={cn(base, variants[variant], sizes[size], className)}> {@render children?.()}</button>import type { JSX } from "solid-js";import { splitProps } from "solid-js";import { cn } from "./cn";
export type ButtonVariant = "primary" | "ghost" | "warn";export type ButtonSize = "md" | "sm";
export interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> { variant?: ButtonVariant; size?: ButtonSize;}
const base = "inline-flex items-center justify-center gap-2 rounded-md border font-bold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-action focus-visible:ring-offset-2 ring-offset-surface disabled:cursor-not-allowed disabled:opacity-50";
const variants: Record<ButtonVariant, string> = { primary: "border-green bg-green text-on-green hover:border-green-deep hover:bg-green-deep", ghost: "border-green bg-transparent text-green-deep hover:bg-green-soft", warn: "border-danger bg-transparent text-danger hover:bg-danger-bg",};
const sizes: Record<ButtonSize, string> = { md: "h-11 px-4 text-sm", sm: "h-9 px-3 text-xs",};
export function Button(props: ButtonProps) { const [local, rest] = splitProps(props, ["variant", "size", "class", "type"]); const variant = () => local.variant ?? "primary"; const size = () => local.size ?? "md";
return ( <button type={local.type ?? "button"} {...rest} class={cn(base, variants[variant()], sizes[size()], local.class)} /> );}States
Section titled “States”CSS-only primitives expose no data-* attributes; their states are the browser’s own pseudo-classes.
| State | Selector | Applied styling |
|---|---|---|
| Hover | :hover |
Variant background deepens (hover:bg-green-deep, hover:bg-green-soft, hover:bg-danger-bg). |
| Focus | :focus-visible |
2px --action ring with offset. Never removed (outline: none is not used). |
| Disabled | [disabled] |
cursor-not-allowed and 50% opacity. |
| Active / loading | none | Not implemented. A loading state belongs to the consuming feature. |
API Reference (Props)
Section titled “API Reference (Props)”| Prop | Type | Default | Description |
|---|---|---|---|
variant |
"primary" | "ghost" | "warn" |
"primary" |
Solid green fill, green outline only, or destructive red outline. |
size |
"md" | "sm" |
"md" |
md is 44px tall (the minimum tap target), sm is 36px for dense desktop toolbars. |
type |
"button" | "submit" | "reset" |
"button" |
Native button type. Defaults to button so it never submits a form by accident. |
disabled |
boolean |
false |
Native disabled state. |
class / className |
string |
undefined |
Extra classes, appended last. |
All other native <button> attributes pass through unchanged.
Accessibility
Section titled “Accessibility”Focus is never removed: every variant takes a 2px --action ring with an offset, so keyboard users always see where they are.
White text on --green (#0F844F) measures 4.74:1, clearing the 4.5:1 needed for 14px bold text. The brand token was darkened from the mockup’s #12925A, which measured 3.97:1 and failed. ghost and warn pass as-is.