FormFileUpload allows users to select files from their local device.
import { FormFileUpload } from '@wordpress/components';
LinksPermalink to this section
PropsPermalink to this section
| Name | Default | Description |
|---|---|---|
__next40pxDefaultSize |
Start opting into the larger default height that will become the default size in a future version. | |
accept |
A string passed to the | |
children |
Children are passed as children of | |
icon |
The icon to render in the default button. See the | |
multiple | false |
Whether to allow multiple selection of files or not. |
onChange Required |
Callback function passed directly to the Select files will be available in | |
onClick |
Callback function passed directly to the This can be useful when you want to force a | |
render |
Optional callback function used to render the UI. If passed, the component does not render the default UI (a button) and
calls this function to render it. The function receives an object with
property |
ExamplesPermalink to this section
DefaultPermalink to this section
const Default = ( props ) => {
return <FormFileUpload { ...props } />;
};
Restrict File TypesPermalink to this section
const RestrictFileTypes = ( props ) => {
return <FormFileUpload { ...props } />;
};
Allow Multiple FilesPermalink to this section
const AllowMultipleFiles = ( props ) => {
return <FormFileUpload { ...props } />;
};
With IconPermalink to this section
const WithIcon = ( props ) => {
return <FormFileUpload { ...props } />;
};
With Custom RenderPermalink to this section
Render a custom trigger button by passing a render function to the render prop.
( { openFileDialog } ) => <button onClick={ openFileDialog }>Custom Upload Button</button>const WithCustomRender = ( props ) => {
return <FormFileUpload { ...props } />;
};