# V alert dialog 15

> Rate Limit Exceeded with live countdown timer

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/v-alert-dialog-15).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/v-alert-dialog-15
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/v-alert-dialog-15-light-97f22be3c92cc936.png
- Registry item: https://ui.cnippet.dev/r/v-alert-dialog-15.json
- Categories: alert dialog
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-alert-dialog-15.json
```

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

## Dependencies

- Registry items: `@cnippet/alert-dialog`

## Files

### `registry/default/variants/v-alert-dialog-15.tsx`

```tsx
"use client";

import { TimerIcon, ZapIcon } from "lucide-react";
import { useEffect, useState } from "react";
import {
  AlertDialog,
  AlertDialogClose,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/registry/default/ui/alert-dialog";
import { Button } from "@/registry/default/ui/button";

function Countdown({ seconds }: { seconds: number }) {
  const [left, setLeft] = useState(seconds);

  useEffect(() => {
    if (left <= 0) return;
    const t = setTimeout(() => setLeft((l) => l - 1), 1000);
    return () => clearTimeout(t);
  }, [left]);

  const m = Math.floor(left / 60)
    .toString()
    .padStart(2, "0");
  const s = (left % 60).toString().padStart(2, "0");

  return (
    <span className="font-mono font-semibold text-foreground">
      {m}:{s}
    </span>
  );
}

export function Pattern() {
  return (
    <AlertDialog>
      <AlertDialogTrigger render={<Button>Make API Request</Button>} />
      <AlertDialogContent className="sm:max-w-sm">
        <div className="flex flex-col items-center gap-3 p-6 pb-4">
          <div className="flex size-12 items-center justify-center rounded-full bg-amber-50 dark:bg-amber-950">
            <ZapIcon className="size-5 text-amber-600 dark:text-amber-400" />
          </div>
          <AlertDialogTitle className="text-center font-semibold text-base">
            Rate limit exceeded
          </AlertDialogTitle>
          <AlertDialogDescription className="text-center text-muted-foreground text-sm">
            You&apos;ve reached the limit of 100 requests per minute. Retry
            automatically in:
          </AlertDialogDescription>
          <div className="flex items-center gap-2 rounded-lg border bg-muted/60 px-4 py-2 text-sm">
            <TimerIcon className="size-4 text-muted-foreground" />
            <Countdown seconds={90} />
          </div>
          <p className="text-center text-muted-foreground text-xs">
            Upgrade to Pro for a 10× higher rate limit.
          </p>
        </div>
        <AlertDialogFooter className="px-6 pb-6">
          <AlertDialogClose
            render={<Button className="flex-1" variant="outline" />}
          >
            Dismiss
          </AlertDialogClose>
          <AlertDialogClose render={<Button className="flex-1" />}>
            Upgrade to Pro
          </AlertDialogClose>
        </AlertDialogFooter>
      </AlertDialogContent>
    </AlertDialog>
  );
}
```
