Progress
A progress bar for displaying task completion.
Export data
20%
View source
import { createSignal, onCleanup, onMount } from "solid-js"
import * as Progress from "@danielfrg/solid-ui/progress"
import styles from "./index.module.css"
export function DemoProgressHero() {
const [value, setValue] = createSignal(20)
onMount(() => {
const interval = setInterval(() => {
setValue((current) => Math.min(100, Math.round(current + Math.random() * 25)))
}, 1000)
onCleanup(() => clearInterval(interval))
})
return (
<Progress.Root class={styles.progress} value={value()}>
<Progress.Label class={styles.label}>Export data</Progress.Label>
<Progress.ValueLabel class={styles.value} />
<Progress.Track class={styles.track}>
<Progress.Fill class={styles.fill} />
</Progress.Track>
</Progress.Root>
)
}.progress {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0.25rem;
grid-row-gap: 0.5rem;
width: 12rem;
}
.label {
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 500;
color: var(--color-gray-900);
}
.value {
grid-column-start: 2;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--color-gray-900);
text-align: right;
}
.track {
grid-column: 1 / 3;
overflow: hidden;
background-color: var(--color-gray-200);
box-shadow: inset 0 0 0 1px var(--color-gray-200);
height: 0.25rem;
border-radius: 0.25rem;
}
.fill {
height: 100%;
width: var(--kb-progress-fill-width);
background-color: var(--color-gray-500);
transition: width 500ms;
}:root {
--color-blue: oklch(45% 50% 264deg);
--color-red: oklch(50% 55% 31deg);
--color-gray-50: oklch(98% 0.25% 264deg);
--color-gray-100: oklch(12% 9.5% 264deg / 5%);
--color-gray-200: oklch(12% 9% 264deg / 7%);
--color-gray-300: oklch(12% 8.5% 264deg / 17%);
--color-gray-400: oklch(12% 8% 264deg / 38%);
--color-gray-500: oklch(12% 7.5% 264deg / 50%);
--color-gray-600: oklch(12% 7% 264deg / 67%);
--color-gray-700: oklch(12% 6% 264deg / 77%);
--color-gray-800: oklch(12% 5% 264deg / 85%);
--color-gray-900: oklch(12% 5% 264deg / 90%);
--color-gray-950: oklch(12% 5% 264deg / 95%);
}
@media (prefers-color-scheme: dark) {
:root {
--color-blue: oklch(69% 50% 264deg);
--color-red: oklch(80% 55% 31deg);
--color-gray-50: oklch(17% 0.25% 264deg);
--color-gray-100: oklch(28% 0.75% 264deg / 65%);
--color-gray-200: oklch(29% 0.75% 264deg / 80%);
--color-gray-300: oklch(35% 0.75% 264deg / 80%);
--color-gray-400: oklch(47% 0.875% 264deg / 80%);
--color-gray-500: oklch(64% 1% 264deg / 80%);
--color-gray-600: oklch(82% 1% 264deg / 80%);
--color-gray-700: oklch(92% 1.125% 264deg / 80%);
--color-gray-800: oklch(93% 0.875% 264deg / 85%);
--color-gray-900: oklch(95% 0.5% 264deg / 90%);
--color-gray-950: oklch(94% 0.375% 264deg / 95%);
}
}Examples
Custom value scale
Use minValue and maxValue to define a custom range.
Temperature
50%
View source
import * as Progress from "@danielfrg/solid-ui/progress"
import styles from "./index.module.css"
export function DemoProgressCustomValueScale() {
return (
<Progress.Root class={styles.progress} value={100} minValue={50} maxValue={150}>
<Progress.Label class={styles.label}>Temperature</Progress.Label>
<Progress.ValueLabel class={styles.value} />
<Progress.Track class={styles.track}>
<Progress.Fill class={styles.fill} />
</Progress.Track>
</Progress.Root>
)
}.progress {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0.25rem;
grid-row-gap: 0.5rem;
width: 12rem;
}
.label {
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 500;
color: var(--color-gray-900);
}
.value {
grid-column-start: 2;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--color-gray-900);
text-align: right;
}
.track {
grid-column: 1 / 3;
overflow: hidden;
background-color: var(--color-gray-200);
box-shadow: inset 0 0 0 1px var(--color-gray-200);
height: 0.25rem;
border-radius: 0.25rem;
}
.fill {
height: 100%;
width: var(--kb-progress-fill-width);
background-color: var(--color-gray-500);
transition: width 500ms;
}:root {
--color-blue: oklch(45% 50% 264deg);
--color-red: oklch(50% 55% 31deg);
--color-gray-50: oklch(98% 0.25% 264deg);
--color-gray-100: oklch(12% 9.5% 264deg / 5%);
--color-gray-200: oklch(12% 9% 264deg / 7%);
--color-gray-300: oklch(12% 8.5% 264deg / 17%);
--color-gray-400: oklch(12% 8% 264deg / 38%);
--color-gray-500: oklch(12% 7.5% 264deg / 50%);
--color-gray-600: oklch(12% 7% 264deg / 67%);
--color-gray-700: oklch(12% 6% 264deg / 77%);
--color-gray-800: oklch(12% 5% 264deg / 85%);
--color-gray-900: oklch(12% 5% 264deg / 90%);
--color-gray-950: oklch(12% 5% 264deg / 95%);
}
@media (prefers-color-scheme: dark) {
:root {
--color-blue: oklch(69% 50% 264deg);
--color-red: oklch(80% 55% 31deg);
--color-gray-50: oklch(17% 0.25% 264deg);
--color-gray-100: oklch(28% 0.75% 264deg / 65%);
--color-gray-200: oklch(29% 0.75% 264deg / 80%);
--color-gray-300: oklch(35% 0.75% 264deg / 80%);
--color-gray-400: oklch(47% 0.875% 264deg / 80%);
--color-gray-500: oklch(64% 1% 264deg / 80%);
--color-gray-600: oklch(82% 1% 264deg / 80%);
--color-gray-700: oklch(92% 1.125% 264deg / 80%);
--color-gray-800: oklch(93% 0.875% 264deg / 85%);
--color-gray-900: oklch(95% 0.5% 264deg / 90%);
--color-gray-950: oklch(94% 0.375% 264deg / 95%);
}
}Custom value label
Use getValueLabel to format the displayed value text.
Tasks
3 of 10 tasks completed
View source
import * as Progress from "@danielfrg/solid-ui/progress"
import styles from "./index.module.css"
export function DemoProgressCustomValueLabel() {
return (
<Progress.Root
class={styles.progress}
value={3}
minValue={0}
maxValue={10}
getValueLabel={({ value, max }) => `${value} of ${max} tasks completed`}
>
<Progress.Label class={styles.label}>Tasks</Progress.Label>
<Progress.ValueLabel class={styles.value} />
<Progress.Track class={styles.track}>
<Progress.Fill class={styles.fill} />
</Progress.Track>
</Progress.Root>
)
}.progress {
display: grid;
grid-template-columns: 1fr 1fr;
grid-gap: 0.25rem;
grid-row-gap: 0.5rem;
width: 12rem;
}
.label {
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 500;
color: var(--color-gray-900);
}
.value {
grid-column-start: 2;
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--color-gray-900);
text-align: right;
}
.track {
grid-column: 1 / 3;
overflow: hidden;
background-color: var(--color-gray-200);
box-shadow: inset 0 0 0 1px var(--color-gray-200);
height: 0.25rem;
border-radius: 0.25rem;
}
.fill {
height: 100%;
width: var(--kb-progress-fill-width);
background-color: var(--color-gray-500);
transition: width 500ms;
}:root {
--color-blue: oklch(45% 50% 264deg);
--color-red: oklch(50% 55% 31deg);
--color-gray-50: oklch(98% 0.25% 264deg);
--color-gray-100: oklch(12% 9.5% 264deg / 5%);
--color-gray-200: oklch(12% 9% 264deg / 7%);
--color-gray-300: oklch(12% 8.5% 264deg / 17%);
--color-gray-400: oklch(12% 8% 264deg / 38%);
--color-gray-500: oklch(12% 7.5% 264deg / 50%);
--color-gray-600: oklch(12% 7% 264deg / 67%);
--color-gray-700: oklch(12% 6% 264deg / 77%);
--color-gray-800: oklch(12% 5% 264deg / 85%);
--color-gray-900: oklch(12% 5% 264deg / 90%);
--color-gray-950: oklch(12% 5% 264deg / 95%);
}
@media (prefers-color-scheme: dark) {
:root {
--color-blue: oklch(69% 50% 264deg);
--color-red: oklch(80% 55% 31deg);
--color-gray-50: oklch(17% 0.25% 264deg);
--color-gray-100: oklch(28% 0.75% 264deg / 65%);
--color-gray-200: oklch(29% 0.75% 264deg / 80%);
--color-gray-300: oklch(35% 0.75% 264deg / 80%);
--color-gray-400: oklch(47% 0.875% 264deg / 80%);
--color-gray-500: oklch(64% 1% 264deg / 80%);
--color-gray-600: oklch(82% 1% 264deg / 80%);
--color-gray-700: oklch(92% 1.125% 264deg / 80%);
--color-gray-800: oklch(93% 0.875% 264deg / 85%);
--color-gray-900: oklch(95% 0.5% 264deg / 90%);
--color-gray-950: oklch(94% 0.375% 264deg / 95%);
}
}