# DotCount

Dots are component adornments, typically used to communicate a numerical value or indicate the status or identity of a component to the end-user.

## Import

```tsx
import { DotCount } from '@coinbase/cds-web/dots/DotCount'
```

## Examples

### Basic DotCount

```jsx live
function DotCountBasic() {
  const counts = [1, 100, 30, 2, 0, 99];
  return (
    <VStack gap={2}>
      {counts.map((count) => (
        <Box padding={1} key={`DotCount-${count}`}>
          <DotCount count={count} />
        </Box>
      ))}
      With max prop
      <VStack alignItems="flex-start" padding={1}>
        <DotCount count={11} max={9} />
      </VStack>
    </VStack>
  );
}
```

### Variants

```jsx live
function Variants() {
  return <DotCount count={30} variant="negative" />;
}
```

### Placements

```jsx live
function Placements() {
  return (
    <DotCount count={30} pin="top-end">
      <VStack bordered padding={2}>
        Child
      </VStack>
    </DotCount>
  );
}
```

### Dotting Relative to Shape of Child

You can use the overlap prop to place the dot relative to the corner of the wrapped element.

```jsx live
function DottingRelativeToShapeOfChild() {
  return (
    <Box gap={2} flexWrap="wrap">
      <DotCount count={30} pin="top-end">
        <VStack bordered padding={2}>
          Child
        </VStack>
      </DotCount>
      <DotCount count={120} pin="top-end">
        <VStack bordered padding={2}>
          Child
        </VStack>
      </DotCount>
      <DotCount count={30} pin="top-end" overlap="circular">
        <VStack bordered padding={2} borderRadius="800">
          Child
        </VStack>
      </DotCount>
      <DotCount count={120} pin="top-end" overlap="circular">
        <VStack bordered padding={2} borderRadius="800">
          Child
        </VStack>
      </DotCount>
    </Box>
  );
}
```

### Customize Style

You can use the styles or classNames prop to customize appearance.

```jsx live
function CustomizeStyle() {
  const theme = useTheme();
  return (
    <HStack gap={2}>
      <DotCount
        count={5}
        styles={{
          container: {
            backgroundColor: theme.color.bgPositive,
            borderColor: theme.color.fgPositive,
          },
        }}
      />
      <DotCount
        count={10}
        styles={{
          container: {
            borderRadius: '4px',
            padding: '2px 6px',
          },
        }}
      />
      <DotCount
        count={42}
        styles={{
          container: {
            backgroundColor: theme.color.bgNegative,
            minWidth: '24px',
          },
          text: {
            fontWeight: 'normal',
          },
        }}
      />
    </HStack>
  );
}
```

## Props

| Prop | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `count` | `number` | Yes | `-` | The number value to be shown in the dot. If count is <= 0, dot will not show up. |
| `children` | `null \| string \| number \| false \| true \| ReactElement<any, string \| JSXElementConstructor<any>> \| Iterable<ReactNode> \| ReactPortal` | No | `-` | Children of where the dot will anchor to |
| `className` | `string` | No | `-` | Custom class name for the root element. |
| `classNames` | `{ root?: string; container?: string \| undefined; text?: string \| undefined; } \| undefined` | No | `-` | Custom class names for the component. |
| `max` | `number` | No | `99` | If a badge count is greater than max, it will truncate the numbers so its max+ |
| `overlap` | `circular` | No | `-` | Indicates what shape Dot is overlapping |
| `pin` | `top-end` | No | `-` | Position of dot relative to its parent |
| `style` | `CSSProperties` | No | `-` | Custom styles for the root element. |
| `styles` | `{ root?: CSSProperties; container?: CSSProperties \| undefined; text?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the component. |
| `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 |
| `variant` | `negative` | No | `negative` | Background color of dot |


