Skip to content

FileInput

A file-input component.

Importing

ts
import "@tapsioss/web-components/file-input";
ts
import { FileInput } from "@tapsioss/react-components/FileInput";

Component Usage

html
<tapsi-file-input></tapsi-file-input>
tsx
<FileInput />

Properties

NameDescriptionTypeDefault Value
disabledIndicates whether the file-input is disabled.booleanfalse
acceptSpecifying what file format does the file input accepts. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#acceptstring""
placeholderA placeholder text for the input component when no file has been selected.string"انتخاب فایل"
valueThe value of the file-input. When the user selected multiple files, the value represents the first file in the list of files they selected.
The other files can be identified using files property.
string""
filesThe value of the file-input. When the user selected multiple files, the value represents the first file in the list of files they selected.
The other files can be identified using files property. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#value
FileList | nullnull
errorWhether the file-input has error.booleanfalse
captureUsed for showing camera for mobile devices. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#capturestring""
supporting-textConveys additional information below the file input, such as how it should be used.string""
loading-textThe text showing in file input when it is in loading state.string"در حال بارگذاری..."
error-textThe error message that replaces supporting text when error is true. If errorText is an empty string, then the supporting text will continue to show. This error message overrides the error message displayed by reportValidity().string""
loadingIndicates the loading state of the component. If false, the component is not in a loading state. If true, a spinner will appear indicating the component is loading. If a number between 0 and 100, it shows the percentage of the loading state.boolean | numberfalse
labelThe label of the input. If the hideLabel property is true, the label will be hidden visually but still accessible to screen readers. Otherwise, a visible label element will be rendered. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelstring""
labelledbyIdentifies the element (or elements) that labels the input. https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledbystring""
hide-labelWhether to hide the label or not.booleanfalse
retryable-errorWhether the file input has retry button in error state.booleanfalse
multipleWhether the file input allows the user to select more than one file.booleanfalse
requiredIndicates that the user must specify a value for the input before the owning form can be submitted and will render an error state when reportValidity() is invoked when value is empty. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/requiredbooleanfalse
readOnlyIndicates whether or not a user should be able to edit the input's value. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonlybooleanfalse
autofocusIndicates that the element should be focused on page load. https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocusbooleanfalse

Slots

NameDescription
placeholder-iconThe icon placeholder that will override the default icon

TIP

You can use slot names as variables:

ts
import { Slots } from "@tapsioss/web-components/file-input";

console.log(Slots.PLACEHOLDER_ICON); // "placeholder-icon"
ts
import { FileInputSlots } from "@tapsioss/react-components";

console.log(FileInputSlots.PLACEHOLDER_ICON); // "placeholder-icon"

Events

NameDescriptionType
retryFires when the retry button is clicked.RetryEvent

TIP

You can import custom event names:

ts
import { 
  RetryEvent
} from "@tapsioss/web-components/file-input";

element.addEventListener(RetryEvent.type, handleTapsiFileInputRetry);
tsx
import { 
  FileInputRetryEvent
} from "@tapsioss/react-components";


// ...

<FileInput
  onRetryEvent={(e: FileInputRetryEvent) => {...}}
/>