Skip to content

File Trigger

The FileTrigger component provides a way to trigger file selection dialogs, allowing users to upload files or select directories.

Import

import { FileTrigger } from "@cfa/react-core";

Live Editor

Examples

Basic Usage

Simply wrap a Button component with FileTrigger to create a file upload button.

Multiple File Selection

Enable users to select multiple files by setting the allowsMultiple prop to true.

Accepted File Types

Restrict the types of files that can be selected by specifying the acceptedFileTypes prop.

Directory Selection

Allow users to select directories instead of files by setting the acceptDirectory prop to true.

Handling Selected Files

Use the onSelect callback to process files after they’ve been selected.

Props

Visit the Documentation Site for the full list of props.

NameTypeDefaultDescription
acceptDirectoryboolean-Enables the selection of directories instead of individual files.
acceptedFileTypesreadonly string[]-Specifies what mime type of files are allowed.
allowsMultipleboolean-Whether multiple files can be selected.
childrenReactNode-The children of the component.
defaultCamera"user" | "environment"-Specifies the use of a media capture mechanism to capture the media on the spot.
dirstring--
hiddenboolean--
inertboolean--
langstring--
onAnimationEndAnimationEventHandler<HTMLInputElement>--
onAnimationEndCaptureAnimationEventHandler<HTMLInputElement>--
onAnimationIterationAnimationEventHandler<HTMLInputElement>--
onAnimationIterationCaptureAnimationEventHandler<HTMLInputElement>--
onAnimationStartAnimationEventHandler<HTMLInputElement>--
onAnimationStartCaptureAnimationEventHandler<HTMLInputElement>--
onAuxClickMouseEventHandler<HTMLInputElement>--
onAuxClickCaptureMouseEventHandler<HTMLInputElement>--
onClickMouseEventHandler<HTMLInputElement>--
onClickCaptureMouseEventHandler<HTMLInputElement>--
onContextMenuMouseEventHandler<HTMLInputElement>--
onContextMenuCaptureMouseEventHandler<HTMLInputElement>--
onDoubleClickMouseEventHandler<HTMLInputElement>--
onDoubleClickCaptureMouseEventHandler<HTMLInputElement>--
onGotPointerCapturePointerEventHandler<HTMLInputElement>--
onGotPointerCaptureCapturePointerEventHandler<HTMLInputElement>--
onLostPointerCapturePointerEventHandler<HTMLInputElement>--
onLostPointerCaptureCapturePointerEventHandler<HTMLInputElement>--
onMouseDownMouseEventHandler<HTMLInputElement>--
onMouseDownCaptureMouseEventHandler<HTMLInputElement>--
onMouseEnterMouseEventHandler<HTMLInputElement>--
onMouseLeaveMouseEventHandler<HTMLInputElement>--
onMouseMoveMouseEventHandler<HTMLInputElement>--
onMouseMoveCaptureMouseEventHandler<HTMLInputElement>--
onMouseOutMouseEventHandler<HTMLInputElement>--
onMouseOutCaptureMouseEventHandler<HTMLInputElement>--
onMouseOverMouseEventHandler<HTMLInputElement>--
onMouseOverCaptureMouseEventHandler<HTMLInputElement>--
onMouseUpMouseEventHandler<HTMLInputElement>--
onMouseUpCaptureMouseEventHandler<HTMLInputElement>--
onPointerCancelPointerEventHandler<HTMLInputElement>--
onPointerCancelCapturePointerEventHandler<HTMLInputElement>--
onPointerDownPointerEventHandler<HTMLInputElement>--
onPointerDownCapturePointerEventHandler<HTMLInputElement>--
onPointerEnterPointerEventHandler<HTMLInputElement>--
onPointerLeavePointerEventHandler<HTMLInputElement>--
onPointerMovePointerEventHandler<HTMLInputElement>--
onPointerMoveCapturePointerEventHandler<HTMLInputElement>--
onPointerOutPointerEventHandler<HTMLInputElement>--
onPointerOutCapturePointerEventHandler<HTMLInputElement>--
onPointerOverPointerEventHandler<HTMLInputElement>--
onPointerOverCapturePointerEventHandler<HTMLInputElement>--
onPointerUpPointerEventHandler<HTMLInputElement>--
onPointerUpCapturePointerEventHandler<HTMLInputElement>--
onScrollUIEventHandler<HTMLInputElement>--
onScrollCaptureUIEventHandler<HTMLInputElement>--
onSelect(files: FileList) => void-Handler when a user selects a file.
onTouchCancelTouchEventHandler<HTMLInputElement>--
onTouchCancelCaptureTouchEventHandler<HTMLInputElement>--
onTouchEndTouchEventHandler<HTMLInputElement>--
onTouchEndCaptureTouchEventHandler<HTMLInputElement>--
onTouchMoveTouchEventHandler<HTMLInputElement>--
onTouchMoveCaptureTouchEventHandler<HTMLInputElement>--
onTouchStartTouchEventHandler<HTMLInputElement>--
onTouchStartCaptureTouchEventHandler<HTMLInputElement>--
onTransitionCancelTransitionEventHandler<HTMLInputElement>--
onTransitionCancelCaptureTransitionEventHandler<HTMLInputElement>--
onTransitionEndTransitionEventHandler<HTMLInputElement>--
onTransitionEndCaptureTransitionEventHandler<HTMLInputElement>--
onTransitionRunTransitionEventHandler<HTMLInputElement>--
onTransitionRunCaptureTransitionEventHandler<HTMLInputElement>--
onTransitionStartTransitionEventHandler<HTMLInputElement>--
onTransitionStartCaptureTransitionEventHandler<HTMLInputElement>--
onWheelWheelEventHandler<HTMLInputElement>--
onWheelCaptureWheelEventHandler<HTMLInputElement>--
translate"yes" | "no"--