# ProgressBarWithFixedLabels

A ProgressBar with fixed labels at defined positions.

## Import

```tsx
import { ProgressBarWithFixedLabels } from '@coinbase/cds-mobile/visualizations/ProgressBarWithFixedLabels'
```

## Examples

### Label Below

```jsx live
<VStack gap={2}>
  <ProgressBarWithFixedLabels startLabel={0} endLabel={20} labelPlacement="below">
    <ProgressBar progress={0.2} />
  </ProgressBarWithFixedLabels>
  <ProgressBarWithFixedLabels endLabel={20} labelPlacement="below">
    <ProgressBar progress={0.2} />
  </ProgressBarWithFixedLabels>
</VStack>
```

### Label Beside

```jsx live
<VStack gap={2}>
  <ProgressBarWithFixedLabels startLabel={0} endLabel={20} labelPlacement="beside">
    <ProgressBar progress={0.2} />
  </ProgressBarWithFixedLabels>
  <ProgressBarWithFixedLabels endLabel={20} labelPlacement="beside">
    <ProgressBar progress={0.2} />
  </ProgressBarWithFixedLabels>
</VStack>
```

### Disabled

```jsx live
<VStack gap={2}>
  <ProgressBarWithFixedLabels startLabel={0} endLabel={20} disabled labelPlacement="beside">
    <ProgressBar disabled progress={0.2} />
  </ProgressBarWithFixedLabels>
  <ProgressBarWithFixedLabels startLabel={0} endLabel={20} disabled labelPlacement="above">
    <ProgressBar disabled progress={0.2} />
  </ProgressBarWithFixedLabels>
</VStack>
```

### Custom Labels

```jsx live
function Example() {
  const renderStartLabelNumStr = useCallback((num) => {
    return `$${num.toLocaleString()}`;
  }, []);

  const renderEndLabelNumStr = useCallback((num) => {
    return `${num.toLocaleString()} left`;
  }, []);

  const renderStartLabelNum = useCallback((num, disabled) => {
    return (
      <TextTitle3 disabled={disabled} as="span">
        ${num.toLocaleString()}
      </TextTitle3>
    );
  }, []);

  const renderEndLabelNum = useCallback((num, disabled) => {
    return (
      <TextLabel2 disabled={disabled} as="span" align="end" noWrap>
        ${num.toLocaleString()} left
      </TextLabel2>
    );
  }, []);

  return (
    <VStack gap={2}>
      <ProgressBarWithFixedLabels
        startLabel={{ value: 12500, render: renderStartLabelNumStr }}
        endLabel={{ value: 35500, render: renderEndLabelNumStr }}
        labelPlacement="above"
      >
        <ProgressBar progress={0.6} />
      </ProgressBarWithFixedLabels>
      <ProgressBarWithFixedLabels
        startLabel={{ value: 12500, render: renderStartLabelNum }}
        endLabel={{ value: 35500, render: renderEndLabelNum }}
        labelPlacement="above"
      >
        <ProgressBar progress={0.6} />
      </ProgressBarWithFixedLabels>

      <ProgressBarWithFixedLabels
        startLabel={{ value: 12500, render: renderStartLabelNumStr }}
        endLabel={{ value: 35500, render: renderEndLabelNumStr }}
        labelPlacement="above"
        disabled
      >
        <ProgressBar disabled progress={0.6} />
      </ProgressBarWithFixedLabels>
      <ProgressBarWithFixedLabels
        startLabel={{ value: 12500, render: renderStartLabelNum }}
        endLabel={{ value: 35500, render: renderEndLabelNum }}
        labelPlacement="above"
        disabled
      >
        <ProgressBar disabled progress={0.6} />
      </ProgressBarWithFixedLabels>
    </VStack>
  );
}
```

### Custom Styles

You can customize the appearance of the progress bar and labels using the `styles` prop.

```tsx live
<ProgressContainerWithButtons>
  {({ calculateProgress }) => (
    <VStack gap={2}>
      <ProgressBarWithFixedLabels
        endLabel={Math.round(calculateProgress(0.7) * 100)}
        labelPlacement="above"
        startLabel={0}
        styles={{
          startLabel: { color: 'red' },
          endLabel: { color: 'green' },
        }}
      >
        <ProgressBar
          progress={calculateProgress(0.7)}
          styles={{
            root: { height: 24 },
            progress: { borderRadius: 12 },
          }}
        />
      </ProgressBarWithFixedLabels>
    </VStack>
  )}
</ProgressContainerWithButtons>
```

## Props

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `disabled` | `boolean` | No | `false` | Toggle used to show a disabled progress visualization |
| `endLabel` | `number \| { value: number; render: (num: number, disabled?: boolean \| undefined) => ReactNode; }` | No | `-` | Label that is pinned to the end of the container. If a number is used then it will format it as a percentage. |
| `labelPlacement` | `above \| below \| beside` | No | `beside` | Position of label relative to the bar |
| `startLabel` | `number \| { value: number; render: (num: number, disabled?: boolean \| undefined) => ReactNode; }` | No | `-` | Label that is pinned to the start of the container. If a number is used then it will format it as a percentage. |
| `style` | `null \| false \| ViewStyle \| RegisteredStyle<ViewStyle> \| RecursiveArray<ViewStyle \| Falsy \| RegisteredStyle<ViewStyle>>` | No | `-` | Custom styles for the progress bar with fixed labels root. |
| `styles` | `{ root?: StyleProp<ViewStyle>; labelContainer?: StyleProp<ViewStyle>; startLabel?: StyleProp<TextStyle>; endLabel?: StyleProp<TextStyle>; }` | No | `-` | Custom styles for the progress bar with fixed labels. |
| `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 |


