A flexible and customizable React TimePicker component with multiple format support
npm install react-timepicker-arcjsx
// This will NOT work in v2.0.0+
import TimePicker from "react-timepicker-arc";
import "react-timepicker-arc/dist/TimePicker.css";
`
$3
`jsx
// Use this new syntax for v2.0.0+
import { TimePicker, ClockPicker } from "react-timepicker-arc";
import "react-timepicker-arc/dist/index.css";
`
---
⨠Features
- š Multiple time formats (12/24 hour)
- ā±ļø Optional seconds display (TimePicker only)
- š
AM/PM toggle
- š Multiple return types (time-string, iso-string, datetime-string, unix-seconds, unix-milliseconds, date-object)
- šØ Customizable styling through classNames prop
- š Positioning options (top, bottom, left, right, center)
- ā
Built-in validation and error handling
- š¼ļø Custom icons support
- š Customizable buttons
- š¦ TypeScript support
- š³ Tree-shaking friendly
> Note: ClockPicker does not include a seconds selector. Seconds are supported only in TimePicker.
---
š¦ Installation
`bash
npm install react-timepicker-arc
`
š§ Usage
$3
`jsx
import { TimePicker } from "react-timepicker-arc";
import "react-timepicker-arc/dist/index.css";
import { useState } from "react";
export default function App() {
const [value, setValue] = useState("");
return (
value={value}
setValue={setValue}
onTimeChange={(time, isValid) => {
console.log("Time:", time, "Valid:", isValid);
}}
showSeconds={true} // optional in TimePicker only
/>
);
}
`
$3
`jsx
import { ClockPicker } from "react-timepicker-arc";
import "react-timepicker-arc/dist/index.css";
import { useState } from "react";
export default function App() {
const [value, setValue] = useState("");
return (
value={value}
setValue={setValue}
onTimeChange={(time, isValid) => {
console.log("Time:", time, "Valid:", isValid);
}}
// showSeconds is not available in ClockPicker
/>
);
}
`
āļø Props Overview
| Prop | Type | Default | Description |
| ------------------- | ---------------------------------------------------- | ------------------ | ----------------------------------------- |
| value | string \| number \| Date \| null \| undefined | undefined | The initial time value |
| setValue | (value: any) => void | (value) => value | Function called when time changes |
| onTimeChange | (time: string, isValid: boolean) => void | undefined | Callback when time changes |
| showSeconds | boolean (TimePicker only) | false | Whether to show seconds (TimePicker only) |
| showButtons | boolean | true | Whether to show OK/Cancel buttons |
| is12HourFormat | boolean | true | Use 12-hour format |
| showAMPM | boolean | true | Show AM/PM selector |
| align | "bottom" \| "top" \| "left" \| "right" \| "center" | "bottom" | Picker alignment |
| placeholder | string | Auto-generated | Input placeholder text |
| className | string | "" | Additional CSS class |
| returnType | TimePickerReturnType | Auto-detected | Format of returned value |
| id | string | "arc_timepicker" | Input element ID |
| icon | ReactNode | Default clock icon | Custom icon element |
| cancelButtonText | string | "Cancel" | Cancel button text |
| confirmButtonText | string | "OK" | Confirm button text |
| classNames | object | {} | Custom CSS classes for components |
š Return Types
- "time-string": "11:30 PM"
- "iso-string": "2022-04-17T15:30:45"
- "datetime-string": "04/17/2022 3:30:45 PM"
- "unix-seconds": 1650207045
- "unix-milliseconds": 1650207045000
- "date-object": Date object
šØ ClassNames Object
`typescript
{
wrapper?: string;
inputWrapper?: string;
input?: string;
icon?: string;
listsMainWrapper?: string;
listsWrapper?: string;
lists?: string;
list?: string;
listSelected?: string;
buttons?: string;
button?: string;
buttonCancel?: string;
buttonConfirm?: string;
}
`
$3
`jsx
classNames={{
wrapper: "my-timepicker",
input: "my-input",
listSelected: "my-selected-item",
}}
// Your custom CSS will override default styles
/>
`
š Migration Guide (v1.0.1 ā v2.0.0)
$3
`jsx
// ā Before (v1.0.1)
import TimePicker from "react-timepicker-arc";
import "react-timepicker-arc/dist/TimePicker.css";
// ā
After (v2.0.0+)
import { TimePicker } from "react-timepicker-arc";
import "react-timepicker-arc/dist/index.css";
`
$3
`jsx
// Option 1: TimePicker (with seconds support)
import { TimePicker } from "react-timepicker-arc";
// Option 2: ClockPicker (visual clock, no seconds)
import { ClockPicker } from "react-timepicker-arc";
`
$3
- Old: "react-timepicker-arc/dist/TimePicker.css"
- New: "react-timepicker-arc/dist/index.css"`