prongs
GitHub

field.file

Files picked to upload: a document, an avatar, a CSV to import. Pass accept and multiple as on <input type="file">

Component

Renders

<input type="file">

Profile

Comes from

starter
Read https://www.prongs.dev/docs/intents/field/file.md and tell me whether field.file fits what I am building.

Example

Preview

PDF or image, up to 10 MB.

<Field intent="field.file" label="Attachment" accept=".pdf,image/*" hint="PDF or image, up to 10 MB." />

Code that says upload, file, attach, import points here. prongs check warns when an element with this intent has a handler or label that points somewhere else.

Connections

Choosing between neighbours

  • If it is

    Use

  • Files picked to upload: a document, an avatar, a CSV to import. Pass accept and multiple as on <input type="file">

    field.file
  • A link to a file somewhere else

    field.url

For registry authors

Starter intents. These are the intents prongs add puts in your registry, shown in this site’s theme. Yours are your own registry.ts: rename, restyle and add to them, and see them with prongs add gallery.

What this intent is built from and its entry in components/prongs/registry.ts. You only need this to change how it looks or to add an intent like it.

How field.file resolves, and its definition

Each layer adds to the one before it; a later class wins over an earlier one that sets the same thing.

  • input.default

    Bordered input box

    w-full min-w-0 rounded-md border border-input bg-background pl-3
    pr-3 py-2 text-base text-foreground
    placeholder:text-surface-muted focus-visible:outline-none
    focus-visible:ring-2 focus-visible:ring-ring
    disabled:cursor-not-allowed disabled:opacity-50
    aria-invalid:border-destructive
  • field.file

    Files picked to upload: a document, an avatar, a CSV to import. Pass accept and multiple as on <input type="file">

Final classes
w-full min-w-0 rounded-md border border-input bg-background pl-3
pr-3 py-2 text-base text-foreground
placeholder:text-surface-muted focus-visible:outline-none
focus-visible:ring-2 focus-visible:ring-ring
disabled:cursor-not-allowed disabled:opacity-50
aria-invalid:border-destructive
Element behaviour
{ type: 'file' }
Definition
TS
'field.file': {
kind: 'semantic',
description: 'Files picked to upload: a document, an avatar, a CSV to import. Pass accept and multiple as on <input type="file">',
refs: ['input.default'],
keywords: ['upload', 'file', 'attach', 'import'],
binding: { behavior: { type: 'file' } },
notFor: [{ context: 'a link to a file somewhere else', instead: 'field.url' }],
},