# V input 22

> Readonly with copy-to-clipboard button

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

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

## Install

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

## Files

### `registry/default/variants/v-input-22.tsx`

```tsx
"use client";

import { CheckIcon, CopyIcon } from "lucide-react";
import { useRef } from "react";
import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";
import { Button } from "@/registry/default/ui/button";
import {
  Field,
  FieldDescription,
  FieldLabel,
} from "@/registry/default/ui/field";
import { Input } from "@/registry/default/ui/input";

export function Pattern() {
  const { copyToClipboard, isCopied } = useCopyToClipboard();
  const inputRef = useRef<HTMLInputElement>(null);

  return (
    <Field className="w-full max-w-xs">
      <FieldLabel htmlFor="referral-link">Referral link</FieldLabel>
      <div className="flex gap-2">
        <Input
          defaultValue="https://app.example.com/ref/abc123"
          id="referral-link"
          readOnly
          ref={inputRef}
          type="text"
        />
        <Button
          aria-label="Copy referral link"
          onClick={() =>
            inputRef.current && copyToClipboard(inputRef.current.value)
          }
          size="icon"
          variant="outline"
        >
          {isCopied ? (
            <CheckIcon aria-hidden="true" />
          ) : (
            <CopyIcon aria-hidden="true" />
          )}
        </Button>
      </div>
      <FieldDescription>Share this link to invite friends.</FieldDescription>
    </Field>
  );
}
```
