Knit UI
GitHub

Playground

Loading playground…

false
false
Playground
<FileButton
  onChange={() => {}}
  disabled={false}
  multiple={false}
>
  {({ onClick }: { onClick: () => void }) => (
    <Button onClick={onClick}>Select file</Button>
  )}
</FileButton>

Examples

Shadows

The shadow elevation ladder applied to the render-prop Button trigger, from xs to xl.

Loading example…

ShadowsSourceStorybook

Disabled

Disabled state — the trigger is rendered but clicking it does nothing.

Loading example…

DisabledSourceStorybook

Multiple

Multiple selection — onChange receives a File[] instead of a single File | null.

Loading example…

MultipleSourceStorybook

Accept Images

Accept filter — restricts the picker to image files only via the accept prop.

Loading example…

Accept ImagesSourceStorybook

With Reset

Controlled with reset — shows the selected filename and lets the user clear the input via resetRef.

Loading example…

With ResetSourceStorybook

Custom Trigger

Custom trigger — any element can act as the trigger, not just a Button.

Loading example…

Custom TriggerSourceStorybook

Capture

Capture — requests a direct camera or microphone capture on supported devices.

Loading example…

CaptureSourceStorybook

Props

PropTypeDefaultDescription
onChange required(payload: FileButtonValue<Multiple, TFile>) => voidCalled with the picked file(s). Shape depends on `multiple`.
acceptstring | undefinedMIME type filter, e.g. `"image/png,image/jpeg"`.
captureboolean | "user" | "environment" | undefined
unset · true · user · environment
Request a fresh capture from a device camera or microphone.
childrenReactNode | ((props: { onClick: () => void; }) => ReactNode)Trigger content. A node (or nothing) renders the built-in `Button` with this as its label; a `({ onClick }) => ReactNode` function renders your own trigger instead.
disabled systemboolean | undefinedfalseDisables the picker — the render-prop onClick becomes a no-op.
formstring | undefined`form` attribute of the input (web only).
fullWidth systemboolean | undefined
gradient systemGradientValue | undefinedGradient fill for `variant="gradient"` (ignored otherwise). Two-color shorthand `{ from, to, deg }` or multi-step `{ stops, deg }`; colors accept `$colorN` ramp tokens or any CSS color. Defaults to the active theme ramp.
inputPropsFileButtonInputProps | undefinedProps spread onto the hidden input element (web only).
leftSectionReactNode
loaderPropsPartial<LoaderProps> | undefined
loadingboolean | undefined
multipleMultiple | undefinedfalseAllow selecting more than one file at once.
namestring | undefined`name` attribute of the input (web only).
pickFilesFileButtonPicker<TFile> | undefinedNative-only resolver that opens a platform file/image picker and returns the picked files. Required for picking on native; ignored on web.
radius systemstring | number | undefined
refRef<HTMLInputElement> | undefinedRef forwarded to the underlying hidden `<input type="file">` (web only).
resetRefRef<() => void> | undefinedRef to a function that clears the selection (`() => void`).
rightSectionReactNode
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
size system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
styles systemSlotStyles<ButtonStyles> | undefinedPer-slot style sugar — props spread onto the matching styled part.
theme systemThemeName | null | undefinedApplies a theme to this element
variant system"light" | "outline" | "white" | "transparent" | "default" | "filled" | "subtle" | "gradient" | undefined

Style slots

Every part of FileButton can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
labelstyles={{ label: { … } }}
leftstyles={{ left: { … } }}
loaderstyles={{ loader: { … } }}
rightstyles={{ right: { … } }}

Plus 496 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.