Skip to content
Snippets Groups Projects
InputFile.tsx 701 B
Newer Older
import { ChangeEvent, ReactNode } from "react";
import { Button } from "./Button";

interface InputFileProps {
  onChange: (e: ChangeEvent<HTMLInputElement>) => void;
export const InputFile = ({ onChange, icon }: InputFileProps) => {

  const openFileSelector = () => {
    const fileSelector = document.getElementById("fileSelector");
    if (fileSelector) {
      fileSelector.click();
    }
  }

  return (
    <div className="">
      <input
        onChange={onChange}
        type="file"
        id="fileSelector"
      />
      <Button
        title="Upload File"
        icon={icon}
        onClick={openFileSelector}