Skip to content

File Input

EFileInput is a commonly used feature in web development allowing users to select and attach one or multiple files in a web application. Demo Here

Import

jsx
import EFileInput from "@components/Form/EFileInput";

Usage

jsx
const FileInputExample = () => {
    const [value, setValue] = useState("");

    const changeHandler = (data) => {
        setValue(data);
    };

    return (
        <EFileInput
            onChange={changeHandler}
            label="Upload your file"
            value={value}
        />
    );
};

export default FileInputExample;

Props

For EFileInput component, the following props are available:

PropTypeDefaultNote
labelnode-Component's label
idString-HTML id attribute.
valueArray-Value of input element.
disabledBooleanfalseDisables the EFileInput.
messageStringZ-Adds a message below the file input.
chipsBooleanfalseDisplays selected file(s) as chips.
heightString-Sets the component's height.
variantString"fill"The EFileInput element can be represented in four ways: fill and border.
showSizeBooleanfalseDisplays the size of selected file(s).
validateOnString"input"Triggers validation on @values: submit, input.
nameString-HTML name attribute.
acceptArray-Specifies the file types that the input field can accept.
requiredBooleanfalseIndicates that the user must specify a value for the input.
rulesArray-Validation rules. For more info refer to Form Validation.
sizeString"md"The EFileInput element has three predefined sizes: sm, md, lg.
multipleBooleanfalseThe multiple property allows more than one item to be selected at the same time.
colorString"primary"The given color is applied to the element - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.
stateString-Validates the user-provided data against established criteria and performs display validation. States can be none if no validation is necessary, danger if the selected file is valid, or success if it is acceptable.
appendIconObject-Inserts a custom EIcon element to the file input that is located after the input value. More Info here.
prependIconObject-Inserts a custom EIcon element to the file input that is located before the input value. More Info here.
squareBooleanfalseSquares the corners of the file input.
classNameString-Overrides or extends the component's styles.
squareBooleanfalseRemoves rounded corners of the element.

Callback Functions

The EFileInput component contains following callback functions.

FunctionDescription
onChangeControls the selected file(s). function(event: React.SyntheticEvent, value: Array) => void 👇

event: The event source of the callback.
value: selected file(s).
onAppendIconClickFires a function when the append icon is clicked.
onPrependIconClickFires a function when the prepend icon is clicked.

COPYRIGHT