Progress - Circular
An element that shows either determinate or indeterminate progress.
Anatomy
To set up the progress correctly, you'll need to understand its anatomy and how we name its parts.
Each part includes a
data-partattribute to help identify them in the DOM.
Examples
Learn how to use the Progress component in your project. Let's take a look at the most basic example:
import { Progress } from '@ark-ui/react/progress'
export const Basic = () => (
<Progress.Root defaultValue={42}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
import { Progress } from '@ark-ui/solid/progress'
export const Basic = () => (
<Progress.Root defaultValue={42}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
<script setup lang="ts">
import { Progress } from '@ark-ui/vue/progress'
</script>
<template>
<Progress.Root :defaultValue="42">
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
</template>
<script lang="ts">
import { Progress } from '@ark-ui/svelte/progress'
</script>
<Progress.Root defaultValue={42}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
Set a min and max value
By default, the maximum is 100. If that's not what you want, you can easily specify a different bound by changing the
value of the max prop. You can do the same with the minimum value by setting the min prop.
For example, to show the user a progress from 10 to 30, you can use:
import { Progress } from '@ark-ui/react/progress'
export const MinMax = () => (
<Progress.Root defaultValue={20} min={10} max={30}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
import { Progress } from '@ark-ui/solid/progress'
export const MinMax = () => (
<Progress.Root defaultValue={20} min={10} max={30}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
<script setup lang="ts">
import { Progress } from '@ark-ui/vue/progress'
</script>
<template>
<Progress.Root :defaultValue="20" :min="10" :max="30">
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
</template>
<script lang="ts">
import { Progress } from '@ark-ui/svelte/progress'
</script>
<Progress.Root defaultValue={20} min={10} max={30}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
Indeterminate value
The progress component is determinate by default, with the value and max set to 50 and 100 respectively. To render an
indeterminate progress, you will have to set the value to null.
import { Progress } from '@ark-ui/react/progress'
export const Indeterminate = () => (
<Progress.Root defaultValue={null}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
import { Progress } from '@ark-ui/solid/progress'
export const Indeterminate = () => (
<Progress.Root defaultValue={null}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
<script setup lang="ts">
import { Progress } from '@ark-ui/vue/progress'
</script>
<template>
<Progress.Root :defaultValue="null">
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
</template>
<script lang="ts">
import { Progress } from '@ark-ui/svelte/progress'
</script>
<Progress.Root value={null}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
Showing a value text
Progress bars can only be interpreted by sighted users. To include a text description to support assistive technologies
like screen readers, use the value part in translations.
import { Progress } from '@ark-ui/react/progress'
export const ValueText = () => (
<Progress.Root
translations={{
value({ value, max }) {
if (value === null) return 'Loading...'
return `${value} of ${max} items loaded`
},
}}
>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
import { Progress } from '@ark-ui/solid/progress'
export const ValueText = () => (
<Progress.Root
translations={{
value({ value, max }) {
if (value === null) return 'Loading...'
return `${value} of ${max} items loaded`
},
}}
>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
)
<script setup lang="ts">
import { Progress } from '@ark-ui/vue/progress'
</script>
<template>
<Progress.Root
:translations="{
value: ({ value, max }) => (value == null ? 'Loading...' : `${value} of ${max} items loaded`),
}"
>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
</template>
<script lang="ts">
import { Progress } from '@ark-ui/svelte/progress'
</script>
<Progress.Root
translations={{
value: ({ value, max }) => (value == null ? 'Loading...' : `${value} of ${max} items loaded`),
}}
>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
Using the Root Provider
The RootProvider component provides a context for the progress. It accepts the value of the useProgress hook. You
can leverage it to access the component state and methods from outside the progress.
import { Progress, useProgress } from '@ark-ui/react/progress'
export const RootProvider = () => {
const progress = useProgress()
return (
<>
<button onClick={() => progress.setToMax()}>Set to MAX</button>
<Progress.RootProvider value={progress}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.RootProvider>
</>
)
}
import { Progress, useProgress } from '@ark-ui/solid/progress'
export const RootProvider = () => {
const progress = useProgress()
return (
<>
<button onClick={() => progress().setToMax()}>Set to MAX</button>
<Progress.RootProvider value={progress}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.RootProvider>
</>
)
}
<script setup lang="ts">
import { Progress, useProgress } from '@ark-ui/vue/progress'
const progress = useProgress()
</script>
<template>
<button @click="progress.setToMax()">Set to MAX</button>
<Progress.Root>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.Root>
</template>
<script lang="ts">
import { Progress, useProgress } from '@ark-ui/svelte/progress'
const id = $props.id()
const progress = useProgress({ id })
</script>
<button onclick={() => progress().setToMax()}>Set to MAX</button>
<Progress.RootProvider value={progress}>
<Progress.Label>Label</Progress.Label>
<Progress.ValueText />
<Progress.Circle>
<Progress.CircleTrack />
<Progress.CircleRange />
</Progress.Circle>
</Progress.RootProvider>
If you're using the
RootProvidercomponent, you don't need to use theRootcomponent.
API Reference
Root
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
defaultValue | 50 | numberThe initial value of the progress bar when rendered. Use when you don't need to control the value of the progress bar. |
formatOptions | { style: 'percent' } | NumberFormatOptionsThe options to use for formatting the value. |
id | stringThe unique identifier of the machine. | |
ids | Partial<{ root: string; track: string; label: string; circle: string }>The ids of the elements in the progress bar. Useful for composition. | |
locale | 'en-US' | stringThe locale to use for formatting the value. |
max | 100 | numberThe maximum allowed value of the progress bar. |
min | 0 | numberThe minimum allowed value of the progress bar. |
onValueChange | (details: ValueChangeDetails) => voidCallback fired when the value changes. | |
orientation | 'horizontal' | 'horizontal' | 'vertical'The orientation of the element. |
translations | IntlTranslationsThe localized messages to use. | |
value | numberThe controlled value of the progress bar. |
| CSS Variable | Description |
|---|---|
--percent | The percent value for the root |
--radius | The border radius value |
--circumference | The circumference value for the root |
--offset | The offset position of the element |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | root |
[data-max] | |
[data-value] | The value of the item |
[data-state] | |
[data-orientation] | The orientation of the progress |
Circle
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
CircleRange
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | circle-range |
[data-state] |
CircleTrack
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | circle-track |
[data-orientation] | The orientation of the circletrack |
Label
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | label |
[data-orientation] | The orientation of the label |
Range
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | range |
[data-orientation] | The orientation of the range |
[data-state] |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UseProgressReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Track
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
ValueText
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
View
| Prop | Default | Type |
|---|---|---|
state | ProgressState | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | progress |
[data-part] | view |
[data-state] |
Accessibility
Complies with the the progressbar role requirements..