Card
Card groups related content and actions into a small self-contained surface.
@duskmoon-dev/components/card Usage
When to use
- Use it to clarify state, metadata, content hierarchy, or loading without creating a new workflow.
- Pair it with semantic content so visual treatment never becomes the only source of meaning.
Implementation notes
Features
Focuses on status, metadata, empty/loading states, or content grouping without owning application state.
Uses DuskMoon tokens so the component follows the active docs theme.
Card is most often configured through `appearance`, `padding`.
Renders children correctly
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and Card from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Card } from "@duskmoon-dev/components/card";
export function Example() {
return (<Card
appearance="elevated"
>
DuskMoon Card
</Card>);
} Renders children correctly
test-backedCard scenario from the component test coverage: renders children correctly.
import "@duskmoon-dev/components/styles.css";
import { Card } from "@duskmoon-dev/components/card";
export function CardRendersChildrenCorrectlyDemo() {
return (<Card
// Renders children correctly
appearance="elevated"
>
DuskMoon Card
</Card>);
} Applies default classes
test-backedCard scenario from the component test coverage: applies default classes.
import "@duskmoon-dev/components/styles.css";
import { Card } from "@duskmoon-dev/components/card";
export function CardAppliesDefaultClassesDemo() {
return (<Card
// Applies default classes
appearance="elevated"
>
DuskMoon Card
</Card>);
} Applies appearance and padding classes
test-backedCard scenario from the component test coverage: applies appearance and padding classes.
import "@duskmoon-dev/components/styles.css";
import { Card } from "@duskmoon-dev/components/card";
export function CardAppliesAppearanceAndPaddingDemo() {
return (<Card
// Applies appearance and padding classes
appearance="elevated"
>
DuskMoon Card
</Card>);
} Applies custom className
test-backedCard scenario from the component test coverage: applies custom classname.
import "@duskmoon-dev/components/styles.css";
import { Card } from "@duskmoon-dev/components/card";
export function CardAppliesCustomClassNameDemo() {
return (<Card
// Applies custom className
appearance="elevated"
>
DuskMoon Card
</Card>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Card
appearance="elevated"
>
DuskMoon Card
</Card>
</div>
<div data-theme="moonlight">
<Card
appearance="elevated"
>
DuskMoon Card
</Card>
</div> API
The API reference below lists every parsed exported type or interface for Card. Start with `appearance`, `padding` for common usage.
packages/components/src/components/card/Card.types.ts
Scenarios: packages/components/src/components/card/Card.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
appearance | CardAppearance | No | appearance configures Card. |
padding | CardPadding | No | padding configures Card. |
"elevated" | "outline" | "filled" "none" | "sm" | "md" | "lg"