npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-flexi-time-selector

v1.0.3

Published

Flexible time picker for React Native apps

Downloads

414

Readme

react-native-flexi-time-selector

A modern, highly customizable Time Picker for React Native. Supports 12/24h formats, intervals, min/max ranges, and dynamic "Now" logic. Designed for productivity and beautiful UIs, this picker offers advanced restriction and presentation options for all your scheduling needs.


⏰ Time Format (Important)

All time inputs and outputs are strings in the "HH:MM" (24-hour) format.
Even if you enable use12Hour={true} for the UI, the onConfirm callback always returns a string like "14:30" (2:30 PM).


🚀 Installation

Install the package with npm or yarn:

npm install react-native-flexi-time-selector

or

yarn add react-native-flexi-time-selector

📦 Usage Examples

Import and use the TimePicker in your React Native app.
All examples assume you are using functional components and React hooks.

1. Strict Range – Office Hours

A basic picker limited to office hours, 9:00 AM to 5:00 PM.
Users can only select times within this range.

import React, { useState } from 'react';
import { View, Button } from 'react-native';
import { TimePicker } from 'react-native-flexi-time-selector';

export default function OfficeHoursExample() {
  const [visible, setVisible] = useState(false);

  return (
    <View>
      <Button title="Pick Office Hour" onPress={() => setVisible(true)} />
      {visible && (
      <TimePicker
        isVisible={visible}
        title="Schedule Meeting"
        minTime="09:00"
        maxTime="17:00"
        use12Hour={true}
        minuteInterval={30}
        onClose={() => setVisible(false)}
        onConfirm={time => {
          setVisible(false);
          // time will be a string like "14:00"
          console.log('Selected:', time);
        }}
      />
      )}
    </View>
  );
}

2. Dynamic "ASAP" Picker

Start time is always "now + 15 minutes", rounded up to the next available interval (live).
This is ideal for delivery, booking, and real-time scheduling UIs.

{visible && (
<TimePicker
  isVisible={visible}
  title="Pick Up Time"
  minTime={{ type: 'now', offsetMinutes: 15, roundUp: true }}
  minuteInterval={5}
  use12Hour={true}
  onClose={() => setVisible(false)}
  onConfirm={time => {
    // time will be a string like "14:35"
  }}
/>
)}

3. 24-Hour Format with 15-Minute Interval

A picker using military time (24-hour notation), with 15-minute steps.

{visible && (
<TimePicker
  isVisible={visible}
  title="Select Time (24h)"
  use12Hour={false}
  minuteInterval={15}
  minTime="06:00"
  maxTime="22:00"
  onClose={() => setVisible(false)}
  onConfirm={time => {
    // time will be a string like "13:45"
  }}
/>
)}

4. Pre-selected Time

Show the picker with an initial pre-selected value ("14:30", or 2:30 PM).

{visible && (
<TimePicker
  isVisible={visible}
  title="Edit Time"
  initialTime="14:30"
  minuteInterval={10}
  onClose={() => setVisible(false)}
  onConfirm={time => {
    // time will be a string like "14:30"
  }}
/>)}

5. Custom Styling & Theming

Show how to override colors and fonts via the theme and customStyles props.

{visible && (
<TimePicker
  isVisible={visible}
  title="Custom Theme"
  minTime="08:00"
  maxTime="20:00"
  use12Hour={false}
  theme={{
    primary: '#0D9488', // Teal
    bg: '#F0FDFA',
    textMain: '#134E4A',
    textSec: '#0D9488',
  }}
  customStyles={{
    confirmButton: { borderRadius: 24, backgroundColor: '#0D9488' },
    modalContainer: { borderWidth: 2, borderColor: '#14B8A6' },
  }}
  onClose={() => setVisible(false)}
  onConfirm={time => {
    // time will be a string like "12:00"
  }}
/>)}

📑 Props Reference

Below is a comprehensive reference for all TimePicker props.
Default values are shown where appropriate.

| Prop | Type / Shape | Required | Default | Description | |------------------|----------------------|----------|------------|--------------------------------------------------------------------------------------------------| | isVisible | boolean | Yes | | Whether the modal picker is visible. | | onClose | () => void | Yes | | Callback when the modal should close (cancel or overlay tap). | | onConfirm | (time: string) => void | Yes | | Called with selected time in "HH:MM" (24hr) string. | | initialTime | string | No | (now) | Pre-selected time as "HH:MM". | | minTime | string OR {type:'now', offsetMinutes?:number, roundUp?:boolean} | No | | Lower limit as "HH:MM" or dynamic config object (see below). | | maxTime | string | No | | Upper limit as "HH:MM". | | minuteInterval | 1 | 5 | 10 | 15 | 30 | 60 | No | 1 | Minutes step increments. | | use12Hour | boolean | No | true | Show times in 12-hour (AM/PM) or 24-hour mode. | | title | string | No | "Select Time" | Title text in the modal header. | | theme | { primary, bg, textMain, textSec } | No | | Color overrides for primary, backgrounds, and text colors. | | customStyles | { ...ViewStyle/TextStyle } | No | | Fine-grained RN style overrides for containers, buttons, etc. |

Min Time Dynamic Config

You can pass an object for minTime to always start from "now + N minutes", optionally rounding up to the next interval:

minTime={{
  type: 'now',
  offsetMinutes: 15, // (optional) Minutes to add to "now"
  roundUp: true      // (optional) Round to next valid interval
}}

🎨 Theming and Styling

  • Use the theme prop for quick color changes (primary, background, text).
  • Use the customStyles prop for advanced per-component overrides (e.g., confirm button, modal container, text).

🏆 Features At a Glance

  • 12/24h Support: Switchable on the fly.
  • Minute Intervals: 1, 5, 10, 15, 30, or 60-minute steps.
  • Min/Max Range: Enforce allowed time slots.
  • Dynamic "Now" Min: Set earliest selectable time to "now + N min."
  • Pre-selection: Start with any time pre-selected.
  • Accessible & Responsive: Touch friendly, works on all React Native platforms.
  • Fully Customizable: Theming and style overrides for perfect UI integration.

📢 License

MIT


💡 Contributing

PRs and suggestions are welcome! Please open issues for bugs or feature requests.


📝 Summary

  • All times are "HH:MM" (24-hour strings) for configuration and callbacks.
  • 12/24-hour display is for UI only.
  • Highly flexible, super easy to integrate.

{
  "title": "Time Format Consistency",
  "content": "All props and callbacks use HH:MM (24-hour) strings. UI can show 12h or 24h, but output is always 24h."
}