Multiple files
Choose a batch; local images, video, and audio receive previews. No files are uploaded.
multiple
WelkUI!REACT EDITIONExplore live variants, compare states, and learn every prop. Pick a component to start.
A native file picker with a selected-file list and small local image, video, and audio previews. Documents remain filename/size entries. Each selection replaces the previous batch. Invalid count, size, or type rejects the entire batch, clears the selection, and displays an error. Files are not uploaded automatically; object URLs are released when previews are removed.
import { WelkAttachment } from "@welkui/react";
<WelkAttachment label="Mission files" maxFiles={3}
maxFileSize={5242880} accept="image/*,.pdf"
onFilesChange={(files) => console.log(files)} />Import @welkui/react/styles.css once in your app. Stateful snippets belong inside a React component.
These are real components, not screenshots. Compare their appearance and try the controls. Key props below each preview show what changes; use the usage example above for imports and component setup.
Choose a batch; local images, video, and audio receive previews. No files are uploaded.
multipleOnly one image is allowed. Selecting a new image replaces the previous selection.
multiple={false} accept="image/*"At most two images/PDFs, each up to 1 MiB. An invalid batch is cleared and an error explains why.
maxFiles={2} maxFileSize={1048576} accept="image/*,.pdf"The native file picker cannot be opened.
disabledRequired props are marked in the default column. Other props are optional. ReactNode accepts text or JSX.
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | Required | Visible, accessible control label. |
maxFiles | number | Unlimited | Positive whole-number limit on the number of selected files. |
maxFileSize | number | Unlimited | Positive maximum size per file in bytes; 5242880 equals 5 MiB. |
onFilesChange | (files: File[]) => void | Unset | Receives accepted files, or [] after clearing/rejection. |
multiple | boolean | true | Allows multiple file selection. |
accept | string | Any file type | Comma-separated extensions or MIME types, such as image/*,.pdf. |
onChange | ChangeEventHandler<HTMLInputElement> | Unset | Native picker change event. |
Inherits native input props except the fields replaced by this component's API: name, id, disabled, required, form, onBlur, onFocus, className, style, aria-* and data-* are supported. Forwards an input ref. type is fixed to file; value, defaultValue and children are not supported. Form reset clears files and previews without calling onFilesChange.
Import @welkui/react/styles.css once in your app entry or Next.js root layout. The previews use the default theme; override --welk-* CSS tokens in your app to customize it.
For Next.js, put hooks and event handlers in a component beginning with "use client". Keep state local to the component using the control. The library preserves its client boundaries and uses your installed React version.
Use defaultValue or defaultChecked for uncontrolled fields, or a state value and its change callback for controlled fields. Do not switch between these modes during the lifetime of a field.
Modal and notification examples start closed: use their Try buttons to see them. Disabled examples are deliberately non-interactive. Validate forms, uploads, authentication, and server responses in your application; these components only provide UI.