# Button Group Patterns 3 - Loading States

> Loading States pattern with grouped toolbar actions.

A shadcn/ui block from the [@shadcnblocks](https://shadcnblocks.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/shadcnblocks/button-group-button-group-patterns-3).

- Page, with a live preview: https://shadcn.exchange/r/shadcnblocks/button-group-button-group-patterns-3
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/shadcnblocks/button-group-button-group-patterns-3-light-7a768f143702e075.png
- Registry item: https://shadcnblocks.com/r/button-group-button-group-patterns-3.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://shadcnblocks.com/r/button-group-button-group-patterns-3.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: `button`, `button-group`

## Files

### `example/button-group/button-group-patterns-3.tsx`

```tsx
"use client";

import { CopyIcon, DownloadIcon, Share2Icon } from "lucide-react";
import { useState } from "react";

import { Button } from "@/components/ui/button";
import { ButtonGroup } from "@/components/ui/button-group";

export const title = "Loading States";

const Example = () => {
  const [loading, setLoading] = useState<string | null>(null);

  const handleAction = (action: string) => {
    setLoading(action);
    setTimeout(() => setLoading(null), 2000);
  };

  return (
    <div className="flex flex-col gap-4">
      <ButtonGroup>
        <Button
          disabled={loading === "copy"}
          onClick={() => handleAction("copy")}
          size="sm"
          variant="outline"
        >
          <CopyIcon />
          {loading === "copy" ? "Copying..." : "Copy"}
        </Button>
        <Button
          disabled={loading === "download"}
          onClick={() => handleAction("download")}
          size="sm"
          variant="outline"
        >
          <DownloadIcon />
          {loading === "download" ? "Downloading..." : "Download"}
        </Button>
        <Button
          disabled={loading === "share"}
          onClick={() => handleAction("share")}
          size="sm"
          variant="outline"
        >
          <Share2Icon />
          {loading === "share" ? "Sharing..." : "Share"}
        </Button>
      </ButtonGroup>
      <ButtonGroup>
        <Button
          disabled={loading !== null}
          onClick={() => handleAction("action1")}
          size="sm"
          variant="outline"
        >
          Action 1
        </Button>
        <Button
          disabled={loading !== null}
          onClick={() => handleAction("action2")}
          size="sm"
          variant="outline"
        >
          Action 2
        </Button>
        <Button
          disabled={loading !== null}
          onClick={() => handleAction("action3")}
          size="sm"
          variant="outline"
        >
          Action 3
        </Button>
      </ButtonGroup>
    </div>
  );
};

export default Example;
```
