mcpField
S
syncfusion-react-timepicker

syncfusion-react-timepicker

github.com/syncfusionDevelopment3167 installsUpdated 1w ago
Repository

About syncfusion-react-timepicker

A skill for React developers implementing Syncfusion TimePicker. It covers configuration, interaction, forms, validation, and advanced usage patterns.

Key features

  1. 01Multiple time formats and locales
  2. 02Selectable time ranges and intervals
  3. 03Keyboard navigation and event handling
  4. 04Form integration and masked input
  5. 05Mobile full-screen and RTL support

Use cases

  1. 01Restrict appointment times in a form
  2. 02Configure localized time display
  3. 03Handle selection events and update state

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/syncfusion/react-ui-components-skills --skill syncfusion-react-timepicker

After installing, type/syncfusion-react-timepickerin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
advanced-patterns.md
api-reference.md
customization-and-styling.md
events-and-methods.md
getting-started.md
time-format-and-display.md
time-range-and-selection.md

Details

From the project README

Implementing Syncfusion React TimePicker Component

The Syncfusion React TimePicker component provides a user-friendly way to select time values in applications. It supports multiple time formats, time range constraints, keyboard navigation, form integration, and mobile-optimized full-screen mode.

Documentation Navigation Guide

Getting Started

📄 Read: references/getting-started.md

  • Installation via npm (@syncfusion/ej2-react-calendars)
  • CalendarModule setup in app.module.ts
  • CSS imports and theme configuration
  • Basic TimePicker implementation
  • Component registration with useRef
  • Running development server
  • Common troubleshooting
Time Format and Display

📄 Read: references/time-format-and-display.md

  • Format string options (24-hour, 12-hour formats)
  • TimeFormatObject with skeleton property
  • Locale-based time formatting
  • Placeholder text customization
  • Float label types (Never, Always, Auto)
  • htmlAttributes for DOM attributes
  • Masked input with enableMask
  • Mask placeholder configuration
Time Range and Selection

📄 Read: references/time-range-and-selection.md

  • Minimum and maximum time constraints
  • Time step intervals (15, 30, 60 minutes)
  • ScrollTo default position
  • Value binding and two-way updates
  • Read-only and disabled states
  • OpenOnFocus behavior
  • Time popup list population
  • Stepped time intervals
Events and Methods

📄 Read: references/events-and-methods.md

  • Event handlers (change, open, close, blur, focus)
  • Event argument structures
  • Methods (show, hide, focusIn, focusOut)
  • Imperative control with useRef
  • Lifecycle events (created, destroyed)
  • Event patterns and best practices
  • Clearing values and state reset
  • ItemRender for custom formatting
Customization and Styling

📄 Read: references/customization-and-styling.md

  • CSS class customization with cssClass
  • Theme options (Material, Bootstrap, Fluent, Tailwind)
  • Full-screen mode for mobile devices
  • RTL (right-to-left) language support
  • Strict mode validation
  • Z-index management
  • Width and height configuration
  • Accessibility features
  • Theme Studio integration
API Reference

📄 Read: references/api-reference.md

  • Complete properties list (26 properties)
  • All methods with signatures (5 methods)
  • All events with event arguments (9 events)
  • Type definitions and interfaces
  • Default values and constraints
  • Use cases for each property
Advanced Patterns

📄 Read: references/advanced-patterns.md

  • Form submission with validation
  • Keyboard shortcuts and keyConfigs
  • Server timezone offset handling
  • Persistence and localStorage
  • Multi-component integration
  • Performance optimization
  • Error handling patterns
  • Complex validation scenarios

Quick Start

import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';
import '@syncfusion/ej2-base/styles/material3.css';
import '@syncfusion/ej2-calendars/styles/material3.css';

function App() {
  const [selectedTime, setSelectedTime] = React.useState(new Date('1/1/2018 9:00 AM'));

  const handleChange = (e: any) => {
    setSelectedTime(e.value);
  };

  return (
    <div style={{ padding: '20px' }}>
      <h2>Select Time</h2>
      <TimePickerComponent
        value={selectedTime}
        change={handleChange}
        placeholder="Select a time"
      />
      <p>Selected: {selectedTime ? selectedTime.toLocaleTimeString() : 'None'}</p>
    </div>
  );
}

export default App;

Common Patterns

Pattern 1: Time Picker with Min/Max Constraints
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';

function AppointmentScheduler() {
  const [appointmentTime, setAppointmentTime] = React.useState(new Date('1/1/2018 9:00 AM'));

  const minTime = new Date('1/1/2018 8:00 AM');
  const maxTime = new Date('1/1/2018 5:00 PM');

  return (
    <div>
      <h3>Select Appointment Time (8 AM - 5 PM)</h3>
      <TimePickerComponent
        value={appointmentTime}
        min={minTime}
        max={maxTime}
        step={30}
        change={(e: any) => setAppointmentTime(e.value)}
        placeholder="Choose time"
      />
    </div>
  );
}

export default AppointmentScheduler;
Pattern 2: Form with Time Picker Submission
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import { ButtonComponent } from '@syncfusion/ej2-react-buttons';
import * as React from 'react';

function ScheduleForm() {
  const [formData, setFormData] = React.useState({
    startTime: new Date('1/1/2018 9:00 AM'),
    endTime: new Date('1/1/2018 5:00 PM'),
  });

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault();
    console.log('Schedule data:', {
      startTime: formData.startTime?.toLocaleTimeString(),
      endTime: formData.endTime?.toLocaleTimeString(),
    });
  };

  return (
    <form onSubmit={handleSubmit}>
      <h3>Schedule Meeting</h3>
      
      <label>Start Time:</label>
      <TimePickerComponent
        value={formData.startTime}
        change={(e: any) => setFormData(prev => ({ ...prev, startTime: e.value }))}
      />

      <label style={{ marginTop: '10px' }}>End Time:</label>
      <TimePickerComponent
        value={formData.endTime}
        min={formData.startTime}
        change={(e: any) => setFormData(prev => ({ ...prev, endTime: e.value }))}
      />

      <ButtonComponent type="submit" isPrimary={true} style={{ marginTop: '15px' }}>
        Schedule
      </ButtonComponent>
    </form>
  );
}

export default ScheduleForm;
Pattern 3: Time Picker with Custom Format
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';

function TimeFormatDemo() {
  const [time12hr, setTime12hr] = React.useState(new Date('1/1/2018 2:30 PM'));
  const [time24hr, setTime24hr] = React.useState(new Date('1/1/2018 14:30'));

  return (
    <div style={{ padding: '20px' }}>
      <div>
        <h4>12-Hour Format (hh:mm a)</h4>
        <TimePickerComponent
          value={time12hr}
          format="hh:mm a"
          change={(e: any) => setTime12hr(e.value)}
        />
        <p>Value: {time12hr?.toLocaleTimeString('en-US', { hour12: true })}</p>
      </div>

      <div style={{ marginTop: '20px' }}>
        <h4>24-Hour Format (HH:mm)</h4>
        <TimePickerComponent
          value={time24hr}
          format="HH:mm"
          change={(e: any) => setTime24hr(e.value)}
        />
        <p>Value: {time24hr?.toLocaleTimeString('en-US', { hour12: false })}</p>
      </div>
    </div>
  );
}

export default TimeFormatDemo;
Pattern 4: Event Handling and State Management
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';

function EventTrackingExample() {
  const [selectedTime, setSelectedTime] = React.useState<Date | null>(null);
  const [eventLog, setEventLog] = React.useState<string[]>([]);

  const handleChange = (e: any) => {
    setSelectedTime(e.value);
    setEventLog(prev => [...prev, `Changed: ${e.value?.toLocaleTimeString()}`]);
  };

  const handleOpen = (e: any) => {
    setEventLog(prev => [...prev, 'Popup opened']);
  };

  const handleClose = (e: any) => {
    setEventLog(prev => [...prev, 'Popup closed']);
  };

  return (
    <div style={{ padding: '20px' }}>
      <h3>Time Picker with Event Tracking</h3>
      <TimePickerComponent
        value={selectedTime}
        change={handleChange}
        open={handleOpen}
        close={handleClose}
        placeholder="Select time to track events"
      />

      <div style={{ marginTop: '20px', padding: '10px', border: '1px solid #ccc' }}>
        <h4>Event Log:</h4>
        <ul>
          {eventLog.map((event, idx) => (
            <li key={idx}>{event}</li>
          ))}
        </ul>
      </div>
    </div>
  );
}

export default EventTrackingExample;
Pattern 5: Masked Time Input
import { TimePickerComponent } from '@syncfusion/ej2-react-calendars';
import * as React from 'react';

function MaskedTimePickerExample() {
  const [maskedTime, setMaskedTime] = React.useState(new Date('1/1/2018 10:30 AM'));

  return (
    <div style={{ padding: '20px' }}>
      <h3>Masked Time Input</h3>
      <TimePickerComponent
        value={maskedTime}
        enableMask={true}
        format="hh:mm a"
        maskPlaceholder={{
          hour: 'HH',
          minute: 'MM',
          second: 'SS',
        }}
        change={(e: any) => setMaskedTime(e.value)}
        placeholder="Enter time (HH:MM AM/PM)"
      />
      <p>Masked input helps users enter time in correct format</p>
    </div>
  );
}

export default MaskedTimePickerExample;

Key Props Reference

PropTypeDefaultPurpose
valueDatenullCurrent selected time value
formatstringBased on cultureTime display format (e.g., "HH:mm", "hh:mm a")
minDate00:00Minimum selectable time
maxDate00:00Maximum selectable time
stepnumber30Time interval in minutes between list items
enabledbooleantrueEnable/disable the component
readonlybooleanfalseRead-only state (no editing)
placeholderstring-Input placeholder text
openOnFocusbooleanfalseOpen popup on input focus
enableMaskbooleanfalseEnable masked input mode
enableRtlbooleanfalseEnable right-to-left layout
strictModebooleanfalseValidate input and restrict to valid times
showClearButtonbooleantrueShow/hide clear button
fullScreenModebooleanfalseMobile full-screen mode
cssClassstring-Custom CSS class for styling
floatLabelTypestringNeverFloat label position
allowEditbooleantrueAllow manual input editing
localestring'en-US'Locale for time formatting
scrollToDate-Default scroll position in popup
widthstring/number-Component width
zIndexnumber1000Z-index of popup
serverTimezoneOffsetnumber-Server timezone offset for processing
htmlAttributesobject{}Custom HTML attributes

Related Skills


Next Steps:

Comments

Markdown supported