# ProgressBarWithFloatLabel A ProgressBar with a floating label that moves with progress. ## Import ```tsx import { ProgressBarWithFloatLabel } from '@coinbase/cds-web/visualizations/ProgressBarWithFloatLabel' ``` ## Examples ### Label Above ```jsx live ``` ### Label Below ```jsx live ``` ### Disabled ```jsx live ``` ### Custom Labels ```jsx live function Example() { const renderLabelNumStr = useCallback((num) => { return `$${num.toLocaleString()}`; }, []); const renderLabelNum = useCallback((num, disabled) => { return ( ${num.toLocaleString()} ); }, []); return ( ); } ``` ### Custom Styles You can customize the appearance of the progress bar and float label using the `styles` prop. ```tsx live {({ calculateProgress }) => ( )} ``` ### Interactive Demo This is for demo purposes. ProgressContainerWithButtons isn't designed for production usage. ```jsx live {({ calculateProgress }) => ( )} ``` ### Animation By default, ProgressBar animates progress changes. Use `disableAnimateOnMount` to skip the initial animation while still animating subsequent changes. ```tsx live {({ calculateProgress }) => ( Normal animation Disable animation on mount )} ``` #### Callbacks You can use the `onAnimationStart` and `onAnimationEnd` callbacks to track the progress of the animation. ```jsx live function Example() { const [animationStatus, setAnimationStatus] = React.useState('Ready'); const handleAnimationStart = useCallback(() => { setAnimationStatus('Animating...'); }, []); const handleAnimationEnd = useCallback(() => { setAnimationStatus('Animation Ended'); }, []); return ( {({ calculateProgress }) => ( Animation Status: {animationStatus} )} ); } ``` ## Props | Prop | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `label` | `number \| { value: number; render: (num: number, disabled?: boolean \| undefined) => ReactNode; }` | Yes | `-` | Label that is floated at the end of the filled in bar. If a number is used then it will format it as a percentage. | | `progress` | `number` | Yes | `-` | Number between 0-1 representing the progress percentage | | `className` | `string` | No | `-` | Custom class name for the progress bar with float label root. | | `classNames` | `{ root?: string; labelContainer?: string \| undefined; label?: string \| undefined; } \| undefined` | No | `-` | Custom class names for the progress bar with float label. | | `disableAnimateOnMount` | `boolean` | No | `false` | Disable animation on component mount | | `disabled` | `boolean` | No | `-` | Toggle used to show a disabled progress visualization | | `labelPlacement` | `above \| below` | No | `above` | Position of label relative to the bar | | `style` | `CSSProperties` | No | `-` | Custom styles for the progress bar with float label root. | | `styles` | `{ root?: CSSProperties; labelContainer?: CSSProperties \| undefined; label?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the progress bar with float label. | | `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |