πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Sign inDemoInstall
Socket

lonare-react-date-picker

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lonare-react-date-picker

A simple React DatePicker component with Tailwind CSS

1.3.0
latest
npm
Version published
Maintainers
1
Created
Source

Lonare React Date Picker

A modern, customizable date picker component for React applications, built with Tailwind CSS. This component provides an intuitive interface for date selection with various configuration options.

NPM Version

License

Bundle Size

Demo GIF

Features

  • πŸ“… Clean and intuitive interface
  • 🎨 Styled with Tailwind CSS
  • πŸ“± Responsive design
  • πŸ”§ Highly customizable
  • 🎯 Date range restrictions
  • πŸš€ Easy to implement
  • ⚑ Lightweight

Installation

npm install lonare-react-date-picker

or with yarn:

yarn add lonare-react-date-picker

Prerequisites

This package requires the following peer dependencies:

{
  "react": ">=16.8.0",
  "react-dom": ">=16.8.0",
  "@heroicons/react": ">=2.0.0"
}

Make sure you have Tailwind CSS configured in your project.

Usage

import { DatePicker } from 'lonare-react-date-picker';

function App() {
  const handleDateChange = (date) => {
    console.log('Selected date:', date);
  };

  return (
    <DatePicker 
      setDate={handleDateChange}
      yearRange={{ before: 5, after: 5 }}
    />
  );
}

Screenshot

Props

PropTypeDefaultDescription
default_dateDate | stringnew Date()Initial date to display
align'left' | 'right''left'Alignment of the date picker dropdown
defaultYearnumbernullPre-selected year
defaultMonthnumbernullPre-selected month (0-11)
setDatefunctionundefinedCallback function when date is selected
dateFuturebooleanfalseOnly allow future dates
datePastbooleanfalseOnly allow past dates
dateRangeStartDate | stringnullStart date for range restriction
dateRangeEndDate | stringnullEnd date for range restriction
yearRangeobject{ before: 0, after: 5 }Number of years to show before/after current year

Examples

Basic Usage

<DatePicker setDate={(date) => console.log(date)} />

With Date Range Restriction

<DatePicker 
  dateRangeStart="2023-01-01"
  dateRangeEnd="2024-12-31"
  setDate={(date) => console.log(date)}
/>

Future Dates Only

<DatePicker 
  dateFuture={true}
  setDate={(date) => console.log(date)}
/>

Custom Year Range

<DatePicker 
  yearRange={{ before: 10, after: 10 }}
  setDate={(date) => console.log(date)}
/>

Styling

The component uses Tailwind CSS classes for styling. You can override the default styles by wrapping the component in a parent element with custom Tailwind classes.

Browser Support

  • Chrome (and Chromium based browsers)
  • Firefox
  • Safari
  • Edge

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Fork the repository
  • Create your feature branch (`git checkout -b feature/AmazingFeature`)
  • Commit your changes (`git commit -m 'Add some AmazingFeature'`)
  • Push to the branch (`git push origin feature/AmazingFeature`)
  • Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Lonare

Acknowledgments

  • Built with React
  • Styled with Tailwind CSS
  • Icons from Heroicons

Changelog

1.0.0

  • Initial release
  • Basic date picker functionality
  • Tailwind CSS styling
  • Date range restrictions
  • Year range customization

Support

If you like this project, please consider giving it a ⭐️ on GitHub!

For bugs and feature requests, please create an issue.

FAQ

How do I customize the styling?

The component uses Tailwind CSS classes which can be overridden using your project's Tailwind configuration.

Can I use this with Next.js?

Yes, the component is compatible with Next.js projects.

Does it support form libraries?

Yes, you can integrate it with form libraries like Formik or React Hook Form using the `setDate` prop.

Keywords

react

FAQs

Package last updated on 15 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts