Skip to main content

FileTrigger

Opens the file picker from any button — a small alternative to DropZone.

Signature
Density
Viewport
Theme and light/dark are set in the top bar
Live demo
Open ↗

When to use​

Opens the file picker from any button — a small alternative to DropZone.

Accessibility​

Always render a visible <label> (the label prop wires htmlFor/id for you). Errors set aria-invalid and are announced via aria-describedby. Required fields expose aria-required.

Install and import​

npx shadcn@latest add @prism/file-trigger
import { FileTrigger } from '@/components/prism/FileTrigger';

In a no-build prototype, read it from the bundle instead: const { FileTrigger } = window.PrismDesignSystem_39d121;

Props​

PropTypeRequiredDescription
acceptstring | string[]—Allowed types: "image/*", ".pdf", or a list of them.
allowsMultipleboolean—Let the user pick more than one file.
acceptDirectoryboolean—Pick a whole folder instead of files.
defaultCamera"user" | "environment"—On phones, open the camera: "user" (front) or "environment" (back).
namestring—Form field name: the chosen files submit with the form (multipart).
formstring—Id of the form to submit with, when the trigger sits outside it.
isRequiredboolean—Blocks form submit until a file is chosen; focus moves to the trigger. A required trigger keeps its files.
showFileNameboolean—Show the chosen file name(s) beside the trigger (announced politely).
onSelect(files: File[]) =&gt; void—Fired with the chosen files as a plain array (a copy that stays valid after the picker resets).
childrenReact.ReactNodeYesA button-like element (Button, IconButton…); pressing it opens the picker. It isn't cloned, so it can come from a Server Component. A click the child cancels (preventDefault) doesn't open the picker.