# Export format picker

> Radio cards for choosing an export format, each with its file type icon.

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-file-type-12).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-file-type-12
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-file-type-12-light-c3d53d54925fc98b.png
- Registry item: https://reui.io/r/new-york-v4/c-file-type-12.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-file-type-12.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: `button`, `field`, `@reui/file-type`, `radio-group`

## Files

### `c-file-type-12.tsx`

```tsx
"use client"

import { useId, useState } from "react"
import { FileType } from "@/components/reui/file-type"

import { Button } from "@/components/ui/button"
import {
  Field,
  FieldContent,
  FieldDescription,
  FieldLabel,
  FieldLegend,
  FieldSet,
  FieldTitle,
} from "@/components/ui/field"
import {
  RadioGroup,
  RadioGroupItem,
} from "@/components/ui/radio-group"

type ExportFormat = "pdf" | "docx" | "xlsx" | "csv" | "png"

const FORMATS: Array<{
  value: ExportFormat
  title: string
  description: string
}> = [
  {
    value: "pdf",
    title: "PDF document",
    description: "Fixed layout, ready to share or print",
  },
  {
    value: "docx",
    title: "Word document",
    description: "Editable in Word or Google Docs",
  },
  {
    value: "xlsx",
    title: "Excel workbook",
    description: "Every table on its own sheet",
  },
  {
    value: "csv",
    title: "CSV table",
    description: "Plain rows for any data tool",
  },
  {
    value: "png",
    title: "PNG images",
    description: "One image per page, for slides",
  },
]

export function Pattern() {
  // A prefix from useId keeps every label paired with its own radio when the
  // picker renders more than once on a page.
  const id = useId()
  // Preselected on purpose: an export always needs a format, so there is no
  // empty state worth showing.
  const [format, setFormat] = useState<ExportFormat>("pdf")
  const [exported, setExported] = useState<ExportFormat | null>(null)

  return (
    <FieldSet className="mx-auto w-full max-w-sm">
      <FieldLegend>Export format</FieldLegend>
      <FieldDescription>Q3 revenue report, 24 pages.</FieldDescription>
      {/* The group reports a plain value, narrowed back to the union here. */}
      <RadioGroup
        value={format}
        onValueChange={(value) => setFormat(value as ExportFormat)}
      >
        {FORMATS.map((option) => (
          <FieldLabel key={option.value} htmlFor={`${id}-${option.value}`}>
            <Field orientation="horizontal">
              {/*
               * The icon keeps its own accessible name ("DOCX file"): the
               * title beside it is a plain name, not the extension.
               */}
              <FileType type={option.value} />
              <FieldContent>
                <FieldTitle>{option.title}</FieldTitle>
                <FieldDescription>{option.description}</FieldDescription>
              </FieldContent>
              <RadioGroupItem
                value={option.value}
                id={`${id}-${option.value}`}
              />
            </Field>
          </FieldLabel>
        ))}
      </RadioGroup>
      <div className="flex items-center justify-between gap-3">
        {/* Exporting changes nothing on screen, so the result is announced here. */}
        <p role="status" className="text-muted-foreground min-w-0 text-xs">
          {exported ? `Exported q3-revenue-report.${exported}` : null}
        </p>
        <Button type="button" onClick={() => setExported(format)}>
          Export {format.toUpperCase()}
        </Button>
      </div>
    </FieldSet>
  )
}
```
