Radix homepage
Components

Progress

Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.

import React from 'react';
import { styled } from '@stitches/react';
import { blackA } from '@radix-ui/colors';
import * as ProgressPrimitive from '@radix-ui/react-progress';
const StyledProgress = styled(ProgressPrimitive.Root, {
position: 'relative',
overflow: 'hidden',
background: blackA.blackA9,
borderRadius: '99999px',
width: 300,
height: 25,
// Fix overflow clipping in Safari
// https://gist.github.com/domske/b66047671c780a238b51c51ffde8d3a0
transform: 'translateZ(0)',
});
const StyledIndicator = styled(ProgressPrimitive.Indicator, {
backgroundColor: 'white',
width: '100%',
height: '100%',
transition: 'transform 660ms cubic-bezier(0.65, 0, 0.35, 1)',
});
// Exports
export const Progress = StyledProgress;
export const ProgressIndicator = StyledIndicator;
// Your app...
const ProgressDemo = () => {
const [progress, setProgress] = React.useState(13);
React.useEffect(() => {
const timer = setTimeout(() => setProgress(66), 500);
return () => clearTimeout(timer);
}, []);
return (
<Progress value={66}>
<ProgressIndicator style={{ transform: `translateX(-${100 - progress}%)` }} />
</Progress>
);
};
export default ProgressDemo;

Features

  • Provides context for assistive technology to read the progress of a task.

Install the component from your command line.

npm install @radix-ui/react-progress

Import all parts and piece them together.

import * as Progress from '@radix-ui/react-progress';
export default () => (
<Progress.Root>
<Progress.Indicator />
</Progress.Root>
);

Adheres to the progressbar role requirements.

Contains all of the progress parts.

PropTypeDefault
asChildbooleanfalse
valuenumber | nullNo default value
maxnumberNo default value
getValueLabelfunctionNo default value
Data AttributeValues
[data-state]"complete" | "indeterminate" | "loading"
[data-value]The current value
[data-max]The max value

Used to show the progress visually. It also makes progress accessible to assistive technologies.

PropTypeDefault
asChildbooleanfalse
Data AttributeValues
[data-state]"complete" | "indeterminate" | "loading"
[data-value]The current value
[data-max]The max value