Skip to main content
ProgressBar
@coinbase/cds-web@8.13.6
A visual indicator of completion progress.
Import
import { ProgressBar } from '@coinbase/cds-web/visualizations/ProgressBar'
SourceView source code
Peer dependencies
  • framer-motion: ^10.18.0

Default

Loading...
Live Code
<VStack gap={2}>
  <ProgressBar progress={0} />
  <ProgressBar progress={0.5} />
  <ProgressBar progress={1} />
</VStack>

Weights

Loading...
Live Code
<VStack gap={2}>
  <ProgressBar weight="thin" progress={0.3} />
  <ProgressBar weight="normal" progress={0.5} />
  <ProgressBar weight="semiheavy" progress={0.7} />
  <ProgressBar weight="heavy" progress={0.9} />
</VStack>

Disabled

Loading...
Live Code
<VStack gap={2}>
  <ProgressBar disabled progress={0} />
  <ProgressBar disabled progress={0.5} />
  <ProgressBar disabled progress={1} />
</VStack>

Colors

Loading...
Live Code
<VStack gap={2}>
  <ProgressBar color="bgPositive" progress={0.5} />
  <ProgressBar color="bgNegative" progress={0.5} />
  <ProgressBar color="bgPrimary" progress={0.5} />
  <ProgressBar color="bgWarning" progress={0.5} />
  <ProgressBar color="fg" progress={0.5} />
  <ProgressBar disabled color="fg" progress={0.5} />
</VStack>

Custom Styles

You can customize the appearance of the progress bar using the styles prop. The root style controls the container, and progress controls the fill bar.

Loading...
Live Code
<VStack gap={2}>
  <ProgressBar
    progress={1}
    styles={{
      root: {
        background: 'transparent',
      },
      progress: {
        background: 'linear-gradient(to right, var(--color-bgPrimaryWash), var(--color-bgPrimary))',
      },
    }}
  />
  <ProgressBar
    progress={0.5}
    styles={{
      root: { height: 'var(--space-4)' },
    }}
  />
  <ProgressBar
    progress={0.3}
    styles={{
      root: {
        height: 'var(--space-8)',
        borderRadius: 'var(--borderRadius-1000)',
      },
      progress: {
        borderRadius: 'var(--borderRadius-1000)',
        background: 'linear-gradient(to right, rgb(var(--teal40)), rgb(var(--green40)))',
      },
    }}
  />
</VStack>

Interactive Demo

This is for demo purposes. ProgressContainerWithButtons isn't designed for production usage.

Loading...
Live Code
<ProgressContainerWithButtons>
  {({ calculateProgress }) => (
    <VStack gap={2}>
      <ProgressBar progress={calculateProgress(0)} />
      <ProgressBar progress={calculateProgress(0.2)} />
    </VStack>
  )}
</ProgressContainerWithButtons>

Animation Callbacks

You can use the onAnimationStart and onAnimationEnd callbacks to track the progress of the animation.

Loading...
Live Code
function Example() {
  const [animationStatus, setAnimationStatus] = React.useState('Ready');

  const handleAnimationStart = useCallback(() => {
    setAnimationStatus('Animating...');
  }, []);

  const handleAnimationEnd = useCallback(() => {
    setAnimationStatus('Animation Ended');
  }, []);

  return (
    <ProgressContainerWithButtons>
      {({ calculateProgress }) => (
        <VStack gap={2}>
          <Text>Animation Status: {animationStatus}</Text>
          <ProgressBar
            onAnimationEnd={handleAnimationEnd}
            onAnimationStart={handleAnimationStart}
            progress={calculateProgress(0.2)}
          />
        </VStack>
      )}
    </ProgressContainerWithButtons>
  );
}

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.