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.
API reference
public sealed class FileSelector : IComponent, ICanValidate<FileSelector>A form control that lets the user pick one or more files from disk, with optional drag-and-drop support.
- Namespace
- Tesserae
- Implements
- IComponent, ICanValidate<FileSelector>
Constructors
| Name | Description |
|---|---|
| FileSelector | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| SelectedFile | Gets or sets the selected file. |
| Placeholder | Gets or sets the placeholder text shown when the component is empty. |
| Error | Gets or sets the validation error message displayed beneath the component. |
| IsInvalid | Gets or sets a value indicating whether the component is currently in an invalid state. |
| IsRequired | Gets or sets a value indicating whether the component is required for form submission. |
| Accepts | Gets or sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both |
public File SelectedFile { get ; private set ; }Gets or sets the selected file.
public string Placeholder { get ; set ; }Gets or sets the placeholder text shown when the component is empty.
public string Error { get ; set ; }Gets or sets the validation error message displayed beneath the component.
public bool IsInvalid { get ; set ; }Gets or sets a value indicating whether the component is currently in an invalid state.
public bool IsRequired { get ; set ; }Gets or sets a value indicating whether the component is required for form submission.
public string Accepts { get ; set ; }Gets or sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both
Methods
| Name | Description |
|---|---|
| NoTextBox | Removes / disables the text box on the component. |
| OnFileSelected | Registers a callback invoked when the file selected event fires. |
| SetPlaceholder | Sets the placeholder of the component. |
| SetAccepts | Sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both |
| Required | Marks the component as required. |
| Reset | Resets the component to its initial state. |
| Attach | Attaches a handler to the component's value-changed event. |
| Render | Renders the component's root HTML element. |
public FileSelector NoTextBox()Removes / disables the text box on the component.
public FileSelector OnFileSelected(FileSelectedHandler handler)Registers a callback invoked when the file selected event fires.
public FileSelector SetPlaceholder(string placeholder)Sets the placeholder of the component.
public FileSelector SetAccepts(string accepts)Sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both
Parameters
- accepts
public void Attach(ComponentEventHandler<FileSelector> handler)Attaches a handler to the component's value-changed event.
public sealed class FileDropArea : IComponentA drop target that accepts files dragged from the operating system, with hover and validation feedback.
- Namespace
- Tesserae
- Implements
- IComponent
Constructors
| Name | Description |
|---|---|
| FileDropArea | Initializes a new instance of this class. |
| Overload | |
|---|---|
| FileDropArea() | Initializes a new instance of this class. |
| FileDropArea(IComponent) | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Content | Sets the content rendered inside the surface. |
| Accepts | Gets or sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both |
| IsMultiple | Returns a value indicating whether the component is multiple. |
public IComponent Content { set ; }Sets the content rendered inside the surface.
public string Accepts { get ; set ; }Gets or sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both
Methods
| Name | Description |
|---|---|
| FilesDroppedHandler | To accept multiple files, mark the FileDropArea as multiple. |
| OpenFileSelection | Opens the file selection. |
| OnFilesDropped | Registers a callback invoked when the files dropped event fires. |
| SetContent | Sets the content of the component. |
| SetAccepts | Sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both |
| Multiple | Configures the component to multiple. |
| Reset | Resets the component to its initial state. |
| Render | Renders the component's root HTML element. |
public delegate void FilesDroppedHandler(FileDropArea sender, File[] files)To accept multiple files, mark the FileDropArea as multiple.
public FileDropArea OnFilesDropped(FilesDroppedHandler handler)Registers a callback invoked when the files dropped event fires.
public FileDropArea SetContent(IComponent content)Sets the content of the component.
public FileDropArea SetAccepts(string accepts)Sets the type of files accepted by this selector. See https://www.w3schools.com/tags/att_input_accept.asp for more information. Valid values are a list of extensions, like ".txt|.doc|.docx", of media type, such as "audio/*|video/*|image/*", or a combination of both
Parameters
- accepts
Samples
File Selector and Drop Area Sample
This sample demonstrates both components.