Skip to main content
DotCount
@coinbase/cds-web@8.13.6
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
import { DotCount } from '@coinbase/cds-web/dots/DotCount'
SourceView source codeStorybookView StorybookFigmaView Figma
Peer dependencies
  • framer-motion: ^10.18.0
Related components

Basic DotCount

Loading...
Live Code
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

Loading...
Live Code
function Variants() {
  return <DotCount count={30} variant="negative" />;
}

Placements

Loading...
Live Code
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.

Loading...
Live Code
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 or classNames prop to customize appearance.

Loading...
Live Code
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>
  );
}

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.