Button
Button triggers primary, secondary, destructive, or icon-only actions.
@duskmoon-dev/components/button Usage
When to use
- Use it inside forms, filters, settings, and any workflow that captures user input.
- Prefer controlled props when the value must stay synchronized with application state.
Implementation notes
Features
Documents default values, value props, and change callbacks for form integration.
Surfaces status, size, disabled, and option data patterns where the component supports them.
Button is most often configured through `color`, `appearance`, `shape`, `size`.
Renders children correctly
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Colors
Button supports the full semantic color palette: primary, secondary, tertiary, accent, neutral, base, info, success, warning, error.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
const colors = [
"primary",
"secondary",
"tertiary",
"accent",
"neutral",
"base",
"info",
"success",
"warning",
"error"
] as const;
export function ButtonColorsDemo() {
return (<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
{colors.map((color) => (
<Button key={color} color={color}>
{color}
</Button>
))}
</div>);
} Basic usage
Import the component stylesheet and Button from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function Example() {
return (<Button color="primary">Save changes</Button>);
} Renders children correctly
test-backedButton scenario from the component test coverage: renders children correctly.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function ButtonRendersChildrenCorrectlyDemo() {
return (<Button color="primary">Save changes</Button>);
} Is disabled when loading
test-backedButton scenario from the component test coverage: is disabled when loading.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function ButtonIsDisabledWhenLoadingDemo() {
return (<Button color="primary">Save changes</Button>);
} Applies color and appearance classes
test-backedButton scenario from the component test coverage: applies color and appearance classes.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function ButtonAppliesColorAndAppearanceDemo() {
return (<Button color="primary">Save changes</Button>);
} Applies shape and size classes
test-backedButton scenario from the component test coverage: applies shape and size classes.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function ButtonAppliesShapeAndSizeDemo() {
return (<Button color="primary">Save changes</Button>);
} Applies block class
test-backedButton scenario from the component test coverage: applies block class.
import "@duskmoon-dev/components/styles.css";
import { Button } from "@duskmoon-dev/components/button";
export function ButtonAppliesBlockClassDemo() {
return (<Button color="primary">Save changes</Button>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Button color="primary">Save changes</Button>
</div>
<div data-theme="moonlight">
<Button color="primary">Save changes</Button>
</div> API
The API reference below lists every parsed exported type or interface for Button. Start with `color`, `appearance`, `shape`, `size` for common usage.
packages/components/src/components/button/Button.types.ts
Scenarios: packages/components/src/components/button/Button.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
color | ButtonColor | No | color configures Button. |
appearance | ButtonAppearance | No | appearance configures Button. |
shape | ButtonShape | No | shape configures Button. |
size | ButtonSize | No | size configures Button. |
block | boolean | No | block configures Button. |
isLoading | boolean | No | isLoading configures Button. |
leftIcon | React.ReactNode | No | leftIcon configures Button. |
rightIcon | React.ReactNode | No | rightIcon configures Button. |
| "primary" | "secondary" | "tertiary" | "accent" | "neutral" | "base" | "info" | "success" | "warning" | "error" | "filled" | "outline" | "tonal" | "ghost" | "text" "rect" | "circle" | "square" "xs" | "sm" | "md" | "lg"