Spin
Spin shows local loading state for a pending operation.
@duskmoon-dev/components/spin 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.
Spin is most often configured through `spinning`, `size`, `tip`, `indicator`.
Renders a spinning indicator by default
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 Spin from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function Example() {
return (<Spin>DuskMoon Spin</Spin>);
} Renders a spinning indicator by default
test-backedSpin scenario from the component test coverage: renders a spinning indicator by default.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinRendersASpinningIndicatorDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Supports spinning false
test-backedSpin scenario from the component test coverage: supports spinning false.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinSupportsSpinningFalseDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Renders tip and nested children
test-backedSpin scenario from the component test coverage: renders tip and nested children.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinRendersTipAndNestedDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Applies size and custom className
test-backedSpin scenario from the component test coverage: applies size and custom classname.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinAppliesSizeAndCustomDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Supports default indicator static method
test-backedSpin scenario from the component test coverage: supports default indicator static method.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinSupportsDefaultIndicatorStaticDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Forwards indicator ref
test-backedSpin scenario from the component test coverage: forwards indicator ref.
import "@duskmoon-dev/components/styles.css";
import { Spin } from "@duskmoon-dev/components/spin";
export function SpinForwardsIndicatorRefDemo() {
return (<Spin>DuskMoon Spin</Spin>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Spin>DuskMoon Spin</Spin>
</div>
<div data-theme="moonlight">
<Spin>DuskMoon Spin</Spin>
</div> API
The API reference below lists every parsed exported type or interface for Spin. Start with `spinning`, `size`, `tip`, `indicator` for common usage.
packages/components/src/components/spin/Spin.types.ts
Scenarios: packages/components/src/components/spin/Spin.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
spinning | boolean | No | spinning configures Spin. |
size | SpinSize | No | size configures Spin. |
tip | ReactNode | No | tip configures Spin. |
indicator | ReactNode | No | indicator configures Spin. |
delay | number | No | delay configures Spin. |
fullscreen | boolean | No | fullscreen configures Spin. |
wrapperClassName | string | No | wrapperClassName configures Spin. |
children | ReactNode | No | children configures Spin. |
| Prop | Type | Required | Description |
|---|---|---|---|
setDefaultIndicator | (indicator?: ReactNode) => void | Yes | setDefaultIndicator configures Spin. |
"small" | "default" | "large"