1.0.8 • Published 4 years ago

react-duration v1.0.8

Weekly downloads
6
License
ISC
Repository
github
Last release
4 years ago

React-Duration

Easy-to-use duration input field for react.

Input Field Example Image

Getting Started

First, install react-duration using npm: npm i react-duration

Then import react-duration into your project: import DurationInput from 'react-duration'

Now you're ready to render you're first duration input field:

class MyApp extends React.Component{
    
    constructor(props){
       
       this.state = {
           duration: 125.4 // Duration values are given in seconds.
       }
    }
    
    render(){
        
        return (    
            <DurationInput
                value={ this.state.duration }
                onChange={ new_duration=> this.setState({duration: new_duration}) }
            />
        );
    }
}

Props

PropAcceptsDescription
buttonIncrementFloatThe amount, in seconds, to increment the duration by when the up or down butons are presssed.
maxValueFloatThe maximum value, in seconds, allowed.
minValueFloatThe minimum value, in seconds, allowed.
onChangeCallbackA function to be called whenever the duration is changed to and is in a valid format.
styleObjectA valid react style prop to be applied to the DurationInput wrapper.

Styling

In addition to the passing in a style object for the container using the style prop, react-duration has the following classes for easy styling:

ClassAssigned To
duration-input-wrapperWrapper around all internal elements
duration-inputInternal text input field
duration-input-button-wrapperWrapper around the up and down buttons
duration-input-buttonBoth the up and down buttons
duration-up-buttonUp Button
duration-down-buttonDown Button
1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago