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 barWhen 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
| Prop | Type | Required | Description |
|---|---|---|---|
accept | string | string[] | — | Allowed types: "image/*", ".pdf", or a list of them. |
allowsMultiple | boolean | — | Let the user pick more than one file. |
acceptDirectory | boolean | — | Pick a whole folder instead of files. |
defaultCamera | "user" | "environment" | — | On phones, open the camera: "user" (front) or "environment" (back). |
name | string | — | Form field name: the chosen files submit with the form (multipart). |
form | string | — | Id of the form to submit with, when the trigger sits outside it. |
isRequired | boolean | — | Blocks form submit until a file is chosen; focus moves to the trigger. A required trigger keeps its files. |
showFileName | boolean | — | Show the chosen file name(s) beside the trigger (announced politely). |
onSelect | (files: File[]) => void | — | Fired with the chosen files as a plain array (a copy that stays valid after the picker resets). |
children | React.ReactNode | Yes | A 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. |