icon

Morainev0.5.0

Progress
elementsprogress

Progress

Determinate or indeterminate progress indicator with optional step labels.

Import#

import { Progress } from 'moraine'

Slot Structure#

Track with a fill indicator, optional status text, and step labels.

root
├── status (optional, determinate only)
├── track
│ └── indicator
└── steps (optional, step mode)
└── step (×n)

Examples#

Sizes#

Size scale from xs to xl.

function Sizes() {
const SIZES: ProgressSize[] = ['xs', 'sm', 'md', 'lg', 'xl']
return (
<div class="w-xl space-y-3">
<For each={SIZES}>
{(size) => (
<div class="flex gap-3 items-center">
<span class="text-xs text-muted-foreground font-mono w-8">{size}</span>
<div class="flex-1">
<Progress value={56} size={size} />
</div>
</div>
)}
</For>
</div>
)
}

Orientations#

Horizontal and vertical layouts with consistent value rendering.

function Orientations() {
return (
<div class="flex gap-6 w-xl items-end">
<div class="flex-1 space-y-2">
<p class="text-xs text-muted-foreground font-mono">horizontal</p>
<Progress value={32} status />
</div>
<div class="space-y-2">
<p class="text-xs text-muted-foreground font-mono">vertical</p>
<div class="h-44">
<Progress value={32} status orientation="vertical" />
</div>
</div>
</div>
)
}

Determinate#

Standard progress bar with status text and custom status renderer.

function Determinate() {
const [value, setValue] = createSignal(35)
const increment = () => {
setValue((current) => Math.min(current + 10, 100))
}
const reset = () => {
setValue(0)
}
return (
<div class="w-xl space-y-3">
<Progress value={value()} status statusRender={(props) => <>Completed {props.percent}%</>} />
<div class="flex gap-2">
<Button size="sm" variant="outline" onClick={increment}>
+10%
</Button>
<Button size="sm" variant="ghost" onClick={reset}>
Reset
</Button>
</div>
</div>
)
}

Animations#

Indeterminate animation variants: carousel, reverse, swing, and elastic.

function Animations() {
const ANIMATIONS: ProgressAnimation[] = ['carousel', 'reverse', 'swing', 'elastic']
return (
<div class="w-xl space-y-3">
<For each={ANIMATIONS}>
{(animation) => (
<div class="flex gap-3 items-center">
<span class="text-xs text-muted-foreground font-mono w-16">{animation}</span>
<div class="flex-1">
<Progress value={null} animation={animation} />
</div>
</div>
)}
</For>
</div>
)
}

Step Mode#

String-array max renders named steps.

function StepMode() {
const STEPS = ['Queued', 'Building', 'Deploying', 'Done']
const [value, setValue] = createSignal(0)
const next = () => {
setValue((current) => Math.min(current + 1, STEPS.length - 1))
}
const previous = () => {
setValue((current) => Math.max(current - 1, 0))
}
const reset = () => {
setValue(0)
}
return (
<div class="w-xl space-y-3">
<Progress value={value()} max={STEPS} status />
<div class="text-xs text-muted-foreground">
Current: {STEPS[value()]} ({value() + 1}/{STEPS.length})
</div>
<div class="flex gap-2">
<Button size="sm" variant="outline" onClick={previous}>
Back
</Button>
<Button size="sm" variant="outline" onClick={next}>
Next
</Button>
<Button size="sm" variant="ghost" onClick={reset}>
Reset
</Button>
</div>
</div>
)
}

API Reference#

Attributes#

Slotroot6 attributes
Progress container that owns track, indicator, labels, and step markers.

Data Attributes

1
Data AttributeDescription
data-orientation
Stores the rendered orientation.

ARIA Attributes

5
ARIA AttributeDescription
aria-valuemax
Defines the maximum value for range-like controls.
aria-valuemin
Defines the minimum value for range-like controls.
aria-valuenow
Defines the current numeric value for range-like controls.
aria-valuetext
Provides human-readable text for the current value.
role
Defines the semantic role exposed to assistive technology.

Props#

PropTypeDefaultDescription
animation"carousel" | "reverse" | "swing" | "elastic" | undefined
classClassValue
Class applied to the component root or trigger element.
classesProgressT.Classes | undefined
getValueLabel((params: { value: number; min: number; max: number; }) => string) | undefined
Callback to get a localized label for the current value.
maxnumber | string[] | undefined100
The maximum value of the progress bar, or an array of step labels.
orientation"horizontal" | "vertical" | undefined
refJSX.HTMLElementTags["div"] extends { ref?: infer Ref; } ? Ref : never | undefined
size"xs" | "sm" | "md" | "lg" | "xl" | undefined
statusboolean | undefinedfalse
Whether to show the status label.
statusRenderComponentOrElement<ProgressT.StatusRenderProps> | undefined
Custom render function for the status label.
stepRenderComponentOrElement<ProgressT.StepRenderProps> | undefined
Custom render function for each step when `max` is an array.
styleJSX.CSSProperties | undefined
stylesProgressT.Styles | undefined
valuenumber | null | undefinednull
The current value of the progress bar. If null/undefined, it is indeterminate.