File Selector & Drop Area
Description
The File Selector and File Drop Area components allow users to select files from their device. The File Selector is typically used for selecting a single file via a standard file dialog, often styled as an input field. The File Drop Area provides a drag-and-drop zone where users can drop one or multiple files.
Usage
File Selector
Use FileSelector() to create a file input. You can set a placeholder, restrict accepted file types, and handle the selection event.
File Drop Area
Use FileDropArea() to create a drop zone. You can enable multiple file selection and handle the drop event.
Methods (FileSelector)
- SetPlaceholder(string text)
- Sets the placeholder text displayed when no file is selected.
- SetAccepts(string accept)
- Sets the
acceptattribute (e.g., ".png, image/*") to filter allowed file types.
- Sets the
- Required()
- Marks the input as required.
- OnFileSelected(FileSelectedHandler handler)
- Registers a callback invoked when a file is selected. The handler receives the
FileSelectorinstance and the event. - Handler signature:
void Handler(FileSelector sender, Event e)
- Registers a callback invoked when a file is selected. The handler receives the
Properties (FileSelector)
- SelectedFile
- Gets the currently selected
Fileobject (fromH5.Core.dom).
- Gets the currently selected
Methods (FileDropArea)
- Multiple()
- Allows multiple files to be dropped or selected.
- OnFilesDropped(FilesDroppedHandler handler)
- Registers a callback invoked when files are dropped.
- Handler signature:
void Handler(IList<File> files, Event e)
Samples
File Selector and Drop Area Sample
This sample demonstrates both components.