1.2.11 • Published 11 months ago

react-wheel-time-picker v1.2.11

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

npm downloads

React wheel time picker

React-wheel-time-picker demo

A modern wheel time picker for your React app.

  • Full Typescript support
  • Dark & Light mode support
  • No moment.js needed
  • Zero dependencies and lightweight

Live demo

To see the live demo: Click here

install

npm install react-wheel-time-picker

or

yarn add react-wheel-time-picker

d.ts declaration

If you have a vite-env.d.ts or other d.ts file in your src folder you can put this

declare module 'react-wheel-time-picker'

It's for finding corresponding type of 'react-wheel-time-picker'.

Usage

24 hours format (light & dark)

24 hours format

import React, { useState } from 'react';
import { TimePicker } from 'react-wheel-time-picker';

export default const  App = () => {
    const [value, setValue] = useState('12:00');
    const [isDarkMode, setIsDarkMode] = useState(false);

    const onChange = (timeValue: string) => {
    setValue(timeValue);
    };

   return (
      <div>
        <TimePicker
            label="Start time"
            isDarkMode={isDarkMode}
            onChange={onChange}
            value={value}
        />
      </div>
   );
}

12 hours format (light & dark)

12 hours format

import React, { useState } from 'react';
import { TimePicker } from 'react-wheel-time-picker';

export default const  MyApp = () => {
    const [value, setValue] = useState('10:00 AM');
    const [isDarkMode, setIsDarkMode] = useState(false);

    const onChange = (timeValue) => {
        setValue(timeValue);
    }

   return (
      <div>
        <TimePicker
            use12Hours
            label="Start time"
            isDarkMode={isDarkMode}
            onChange={onChange}
            value={value}
        />
      </div>
   );
}

API

NameTypeDefaultDescription
labelString (optional)n/aName of the input.
isDarkModeBoolean (optional)n/afor dark mode support.
valueStringn/aCurrent value.
cellHeightNumber (optional)28The height of the cell number.
placeHolderString (optional)"Selet_time"Time input's placeholder.
pickerDefaultValueString (optional)"00:00"The initial value that the picker begin with in the first time.
disabledBoolean (optional)falseWhether picker is disabled.
isOpenBoolean (optional)falseWhether the time picker should be opened.
requiredBoolean (optional)falseWhether time input should be required.
cancelButtonTextString (optional)"Cancel"Cancel button text content
saveButtonTextString (optional)"Save"Save button text content
controllersBoolean (optional)trueWhether the buttons should be displayed
seperatorBoolean (optional)truewhether show the colon seperator
idString (optional)n/aInput time picker id
nameString (optional)n/aInput time picker name
use12HoursBoolean (optional)false12 hours display mode
inputClassNameString (optional)n/aInput time picker className
popupClassNameString (optional)n/atime picker popup className
onChange(value) => alert ('New time is: ', value)n/aCalled when select a different value
onSave(value) => alert ('Time saved is: ', value) (optional)n/aWhen the user clicks on save button
onClose() => alert('Clock closed') (optional)n/aWhen the user clicks on cancel button
onAmPmChange(value) => alert('Am/Pm changed : value') (optional)n/acalled when select an am/pm value
onOpen() => alert('time picker opened') (optional)n/acalled when time picker is opened

Contributions Welcome!

git clone https://github.com/rodolphe37/react-wheel-time-picker

License

The ISC License.

1.2.11

11 months ago

1.2.9

11 months ago

1.2.8

11 months ago

1.2.7

11 months ago

1.2.5

11 months ago

1.2.4

11 months ago

1.2.3

11 months ago

1.2.2

11 months ago

1.2.1

11 months ago

1.2.0

11 months ago

1.1.3

11 months ago

1.1.2

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.9

11 months ago

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago