# P popover 4

> Split button with popover to confirm multiple occurrences

A shadcn/ui block from the [@coss](https://coss.com/ui) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/coss/p-popover-4).

- Page, with a live preview: https://shadcn.exchange/r/coss/p-popover-4
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/coss/p-popover-4-light-25809fc3e4bbac6b.png
- Registry item: https://coss.com/ui/r/p-popover-4.json
- Categories: button, checkbox, checkbox group, group, popover
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://coss.com/ui/r/p-popover-4.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `lucide-react`
- Registry items: `@coss/badge`, `@coss/button`, `@coss/checkbox`, `@coss/checkbox-group`, `@coss/group`, `@coss/label`, `@coss/popover`

## Files

### `registry/default/particles/p-popover-4.tsx`

```tsx
"use client";

import { ChevronDownIcon } from "lucide-react";
import { useState } from "react";
import { Badge } from "@/registry/default/ui/badge";
import { Button } from "@/registry/default/ui/button";
import { Checkbox } from "@/registry/default/ui/checkbox";
import { CheckboxGroup } from "@/registry/default/ui/checkbox-group";
import { Group, GroupSeparator } from "@/registry/default/ui/group";
import { Label } from "@/registry/default/ui/label";
import {
  Popover,
  PopoverClose,
  PopoverDescription,
  PopoverPopup,
  PopoverTitle,
  PopoverTrigger,
} from "@/registry/default/ui/popover";

const occurrences = [
  { date: "Wed, Jul 15", id: "occurrence-1", time: "9:00 – 9:30am" },
  { date: "Wed, Jul 15", id: "occurrence-2", time: "10:00 – 10:30am" },
  { date: "Wed, Jul 15", id: "occurrence-3", time: "11:00 – 11:30am" },
];

export default function Particle() {
  const [selected, setSelected] = useState(
    occurrences.map((occurrence) => occurrence.id),
  );

  return (
    <div className="flex gap-2">
      <Button size="xs" variant="outline">
        Reject
      </Button>
      <Group aria-label="Confirm booking">
        <Button size="xs">Confirm all</Button>
        <GroupSeparator className="bg-primary/72" />
        <Popover>
          <PopoverTrigger
            render={
              <Button
                aria-label="Choose occurrences to confirm"
                size="icon-xs"
              />
            }
          >
            <ChevronDownIcon aria-hidden="true" />
          </PopoverTrigger>
          <PopoverPopup align="end" className="w-84">
            <div className="mb-3">
              <PopoverTitle className="text-sm">
                Confirm occurrences
              </PopoverTitle>
              <PopoverDescription className="text-xs">
                {occurrences.length} pending for this booking
              </PopoverDescription>
            </div>
            <CheckboxGroup
              aria-label="Occurrences to confirm"
              className="gap-0 self-stretch"
              onValueChange={setSelected}
              value={selected}
            >
              {occurrences.map((occurrence) => (
                <Label className="flex w-full gap-2 py-1.5" key={occurrence.id}>
                  <Checkbox value={occurrence.id} />
                  <span className="tabular-nums">{occurrence.time}</span>
                  <span className="ms-auto font-normal text-muted-foreground">
                    {occurrence.date}
                  </span>
                </Label>
              ))}
            </CheckboxGroup>
            <div className="mt-3 flex justify-end gap-2">
              <PopoverClose
                disabled={selected.length === 0}
                render={<Button size="xs" variant="ghost" />}
              >
                Reject selected
              </PopoverClose>
              <PopoverClose
                disabled={selected.length === 0}
                render={<Button size="xs" />}
              >
                Confirm selected
                <Badge className="-me-1 text-primary-foreground/60">
                  {selected.length}
                </Badge>
              </PopoverClose>
            </div>
          </PopoverPopup>
        </Popover>
      </Group>
    </div>
  );
}
```
