Docs
File Preview

A component for previewing image and text files.

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

Installation

pnpm dlx shadcn@latest add https://devkit.kiron.dev/k/file-preview

Usage

import { FilePreview } from "@/components/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