# 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-mobile/dots/DotCount'
```

## Examples

### Basic DotCount

```jsx
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
function Variants() {
  return <DotCount count={30} variant="negative" />;
}
```

### Placements

```jsx
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
function DottingRelativeToShapeOfChild() {
  return (
    <HStack gap={2}>
      <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>
    </HStack>
  );
}
```

### Customize Style

You can use the styles prop to customize appearance.

```jsx
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: 4,
            padding: 2,
            paddingHorizontal: 6,
          },
        }}
      />
      <DotCount
        count={42}
        styles={{
          container: {
            backgroundColor: theme.color.bgNegative,
            minWidth: 24,
          },
        }}
      />
    </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 |
| `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` | `null \| false \| ViewStyle \| RegisteredStyle<ViewStyle> \| RecursiveArray<ViewStyle \| Falsy \| RegisteredStyle<ViewStyle>>` | No | `-` | Custom styles for the root element. |
| `styles` | `{ root?: StyleProp<ViewStyle>; container?: StyleProp<ViewStyle>; text?: StyleProp<TextStyle>; }` | 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 |


