# V toast 11

> Anchored clipboard copy with tooltip-style toast

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

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

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-toast-11.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/toast`

## Files

### `registry/default/variants/v-toast-11.tsx`

```tsx
"use client";

import { CopyIcon } from "lucide-react";
import { useRef } from "react";
import { Button } from "@/registry/default/ui/button";
import { anchoredToastManager } from "@/registry/default/ui/toast";

const SNIPPET = "npx shadcn@latest add @cnippet/ui";

export function Pattern() {
  const btnRef = useRef<HTMLButtonElement>(null);

  const copy = () => {
    void navigator.clipboard.writeText(SNIPPET);
    anchoredToastManager.add({
      data: { tooltipStyle: true },
      positionerProps: { anchor: btnRef.current },
      title: "Copied!",
    });
  };

  return (
    <div className="flex items-center gap-0 overflow-hidden rounded-lg border border-input bg-muted/40 py-1 pr-1 pl-3">
      <code className="flex-1 font-mono text-foreground/80 text-sm">
        {SNIPPET}
      </code>
      <Button
        className="ml-2 shrink-0"
        onClick={copy}
        ref={btnRef}
        size="sm"
        variant="ghost"
      >
        <CopyIcon className="size-3.5" />
        Copy
      </Button>
    </div>
  );
}
```
