Docs
File Preview

File Preview

A component for previewing image and text files.

Component file-preview-demo not found in registry.

The FilePreview component provides a consistent way to display file previews with support for both image and text files.

Installation

npx shadcn@latest add https://shadcn-chatbot-kit.vercel.app/r/file-preview.json

Usage

import { FilePreview } from "@/registry/default/ui/file-preview"
 
export function FilePreviewDemo() {
  const [file, setFile] = useState<File | null>(null)
 
  return (
    <div>
      {file && <FilePreview file={file} onRemove={() => setFile(null)} />}
    </div>
  )
}

Props

FilePreview

PropTypeDescription
fileFileThe file object to preview
onRemoveFunctionCallback function when remove is clicked