Giter VIP home page Giter VIP logo

react-bootstrap-time-picker's Introduction

react-bootstrap-time-picker

Time Picker with bootstrap flavor

react-bootstrap-time-picker

npm version Downloads Build Status Coverage Status

Versions

  • v2 supports React Bootstrap v1.0.0+
  • v1 supports React Bootstrap v0.x.x

Demo

Demo and playground are available here

Install

npm i react-bootstrap-time-picker --save

Usage Example

import TimePicker from 'react-bootstrap-time-picker';

<TimePicker start="10:00" end="21:00" step={30} />

Configurable Props

Note: All props are optional.

end: string, default "23:59"

Time Picker renders options with range between start and end time values with step (inclusive).

Should be provided in the following format: "HH?(:mm?(:ss?))".

Valid examples

"4", "04", "4:0", "04:00", "4:0:0", "04:00:00". All these are equal to "4 hours".

Invalid example

"11:00 PM". Should be provided in 24-hour format only

format: number, default "23:59"

Time Format of rendered options. Supported values: 12 or 24.

initialValue: any, default: "00:00"

Initial selected option. Used if value prop is either undefined or null. Can be provided either in "HH?(:mm?(:ss?))" format or as int (hours * 3600 + minutes * 60 + seconds). If initialValue is less than start property value, then start value is used instead.

Valid examples

"1:00", "01:00", "3600", 3600

Invalid examples

"11:00 PM"

onChange: func, default: () => {}

Function, which is triggered after one of options is selected. Return selected time in int format: (hours * 3600 + minutes * 60 + seconds).

Example

class Parent extends React.Component {
  constructor() {
    super();

    this.handleTimeChange = this.handleTimeChange.bind(this);

    this.state = { time: 0 };
  }

  handleTimeChange(time) {
    console.log(time);     // <- prints "3600" if "01:00" is picked
    this.setState({ time });
  }

  render() {
    return <TimePicker onChange={this.handleTimeChange} value={this.state.time} />;
  }
}

start: string, default: "00:00"

See end property description.

step: number, default: 30

Step between time options in minutes. See end property description.

value

Current value. See initialValue description.

Validations

Library doesn't validate provided props much. If you are doing something strange like setting start="10:00", end="05:00", then behavior is undefined, which means that it might render component differently in the future versions. Also underlying library time-number throws exceptions if provided time is not in a proper format, i.e. adl is considered invalid.

License

MIT (c) Yury Dymov

react-bootstrap-time-picker's People

Contributors

dependabot[bot] avatar marcuxyz avatar yury-dymov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-bootstrap-time-picker's Issues

time picker not working on my side

Hi,
I am trying to use react-bootstrap-time-picker and what i get after installing the package
is

Failed to compile.
./node_modules/react-bootstrap-time-picker/dist/bundle.js
Module not found: Error: Can't resolve 'react-bootstrap/lib/FormControl' in 'E:\Zindex\NodeJS\inmc\node_modules\react-bootstrap-time-picker\dist'

Can you please let me know what i am missing?

I got it thanks, i was missing react-bootstrap package. :)

typo in readme

render() {
    return <TimePicker onChange={this.handleTimeChange} value={this.state.time};
  }

ReferenceError: require is not defined

ReferenceError: require is not defined

ReferenceError: require is not defined eval webpack-internal:///3:1:18 push../node_modules/react-bootstrap-time-picker/dist/bundle.js node_modules/react-bootstrap-time-picker/dist/bundle.js:40

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.