Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

691 B
Raw Blame
import { Box, ToggleGroup, ToggleGroupItem } from '@umami/react-zen';

export interface FilterButtonsProps {
  items: { id: string; label: string }[];
  value: string;
  onChange?: (value: string) => void;
}

export function FilterButtons({ items, value, onChange }: FilterButtonsProps) {
  return (
    <Box>
      <ToggleGroup
        value={[value]}
        onChange={e => {
          const nextValue = e[0];

          if (nextValue) {
            onChange?.(nextValue);
          }
        }}
      >
        {items.map(({ id, label }) => (
          <ToggleGroupItem key={id} id={id}>
            {label}
          </ToggleGroupItem>
        ))}
      </ToggleGroup>
    </Box>
  );
}