Git Product home page Git Product logo

chakra-ui-file-picker's Introduction

Components test

Chakra UI File Picker

Since there is no default file picker for Chakra-UI, I've developed my own for usage in one of my personal projects.

Allows to:

  • Retrieve the files from a callback
  • Filter the files by file type/extension
  • Reset programmatically by using a ref
  • Provide styling to the Input and InputGroup

Usage

Demonstration

<FilePicker
    onFileChange={(fileList) => { // do stuff here }}
    placeholder="placeholder"
    clearButtonLabel="label"
    multipleFiles={true}
    accept="application/json"
    hideClearButton={false}
    ref={myRef}
/>
Prop name Type Optional Description Default
placeholder string No Sets the placeholder on the input field N/A
onFileChange (fileList: Array<File>) => void No Is triggered every time that the file list changes N/A
clearButtonLabel string Yes Sets the label that will be shown on the clear button. 'Clear'
multipleFiles boolean Yes Sets if the input can allow for one of many files at a time False
accept string Yes Allows to filter the files by type/extension. undefined
hideClearButton boolean Yes Hides or shows the clear button. False
ref React.RefObject Yes Provides a reference to the FilePicker undefined

TODO

  • Maybe have a FormControl base with this component?

Contributions

Are of course accepted, but please try to follow this rules:

  • Write some description around your idea so I can follow your train of thought.
  • Please do write accompanying unit tests for the functionality (unless it's really impossible to do so). This will allow us to improve and deploy this component with more confidence that it does what it's supposed to. I chose to use React Testing Library, you can find additional info here on how to write tests in this fashion.

chakra-ui-file-picker's People

Contributors

pedrodbflores avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.