Forms & Input
Dropzone
Dropzone enables drag-and-drop file upload interactions. Make the expected input clear before someone interacts, and keep the current value, help text and validation feedback connected. Import it from @/components/kamod-ui/dropzone.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Dropzone and optional indicators from @/components/kamod-ui/dropzone.
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Handle onFilesChange to process selected or dropped files.
import { Dropzone } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Dropzone in Different Contexts, from the starting pattern to the compositions below. Begin with Basic Dropzone, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Basic Dropzone
Keep File Selection Available without Dragging. Use Dropzone to offer both drag-and-drop and a click-to-select file picker. The selected files are inputs to your application; accepting a file into the control is separate from validating or uploading it.
Explain accepted types and size limits, validate files in your application, and distinguish selecting a local file from actually uploading it to a server.
import { Dropzone } from "@kamod-ch/ui";
export const Example = () => (
<Dropzone class="w-full max-w-xl">
<p class="text-sm">Drop files here or click to upload.</p>
</Dropzone>
);Dropzone Indicators
Communicate Each Stage of the Upload. Place helper indicators near the dropzone to explain whether files are waiting, uploading or complete. Derive those messages from the actual operation, keeping selection feedback distinct from a confirmed upload result.
Keep retry and removal actions clear, and clean up application-owned object URLs or requests when previews are replaced or the upload is cancelled.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Dropzone using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Dropzone
DropzoneProps
| Prop / type | Description |
|---|---|
accept | Configure
|
children | Configure
|
class | Configure
|
multiple | Configure
|
onFilesChange | Configure
|
DropzoneFilesList
DropzoneFilesListProps
| Prop / type | Description |
|---|---|
class | Configure
|
files | Configure
|
DropzoneLoadingIndicator
DropzoneLoadingIndicatorProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
DropzoneUploadIndicator
DropzoneUploadIndicatorProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
Dropzone Props
4 declared fieldsDropzonePropsDropzone.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropzoneProps before adapting it.DropzoneFilesList Props
1 declared fieldDropzoneFilesListPropsDropzoneFilesList.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropzoneFilesListProps before adapting it.filesDropzoneLoadingIndicator Props
1 declared fieldDropzoneLoadingIndicatorPropsDropzoneLoadingIndicator.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropzoneLoadingIndicatorProps before adapting it.DropzoneUploadIndicator Props
1 declared fieldDropzoneUploadIndicatorPropsDropzoneUploadIndicator.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of DropzoneUploadIndicatorProps before adapting it.Accessibility
Build the Complete Interaction, Including the Parts Outside Dropzone. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
Dropzone overlays a native file input on the drop area, so file selection can use the browser picker as well as drag and drop. The current API forwards accept and multiple to that input; general root attributes stay on the outer div.
Labels and Relationships
State file types, size limits and the intended upload destination visibly. Verify that the actual file input has an accessible name: setting aria-label on Dropzone's outer div does not label its nested input. Use an explicitly labeled native file input or extend the component where necessary.
Keyboard and Focus
Provide a keyboard-visible focus treatment for the real picker control and confirm Enter/Space opens the file dialog. Dragging is an optional path. Give uploaded files identifiable remove/retry controls and keep successful, pending and rejected files distinguishable.
States and Integration Details
The accept hint is not validation of dropped files, and the dropzone does not upload or announce results itself. Validate files in your application, explain rejection in text and keep upload status available outside the transparent input overlay.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Reach and open the native picker without a pointer; inspect its name and visible focus.
- Select and drop disallowed, oversized and duplicate files and compare the resulting messages.
- Retry a failed upload and remove a queued file without losing the user's location in the file list.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.