HextaUI

File input (UI SDK): Image previews

FileInputItemPreview shows an image from an object URL it revokes when the file goes away, and an icon for other types. With layout="grid", each file is a square tile.

Add photos

Up to 6 images, 10 MB each.

import {
  FileInput,
  FileInputDropzone,
  FileInputDropzoneDescription,
  FileInputDropzoneIcon,
  FileInputDropzoneTitle,
  FileInputItem,
  FileInputList,
  FileInputRejections,
  FileInputTrigger,
} from "@/components/ui/ui-sdk-file-input"

function UiSdkFileInputImages() {
  return (
    <FileInput
      multiple
      accept="image/*"
      maxFiles={6}
      maxSize={10_000_000}
      className="max-w-md"
    >
      <FileInputDropzone className="min-h-32">
        <FileInputDropzoneIcon />
        <FileInputDropzoneTitle>Add photos</FileInputDropzoneTitle>
        <FileInputDropzoneDescription>
          Up to 6 images, 10 MB each.
        </FileInputDropzoneDescription>
        <FileInputTrigger className="mt-3">Choose photos</FileInputTrigger>
      </FileInputDropzone>
      <FileInputRejections />
      <FileInputList aria-label="Photos" layout="grid">
        <FileInputItem />
      </FileInputList>
    </FileInput>
  )
}

export { UiSdkFileInputImages }

This adds the example as components/examples/ui-sdk-file-input/images.tsx, together with the File input component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-file-input-images.json

To add only the component, follow the File input installation.

Props in this example

The File input props this example sets, from the API reference.

PropTypeDefault
accept
string | string[]–
multiple
booleanfalse
maxFiles
number–
maxSizeIn bytes.
number–
PropTypeDefault
layoutRows, square image tiles, or compact chips. Items take their look from it.
"list" | "grid" | "chips""list"

Every prop is in the File input API reference.

See them all, with keyboard support and accessibility notes, on the File input page.