1.0.26 • Published 4 months ago

@trackpilots/date-picker v1.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@trackpilots/date-picker

npm license downloads

A customizable date picker component built with React and Tailwind CSS.

✨ Screenshots

Screenshot

🚀 Installation

You can install the package using npm or yarn:

Using npm

npm install @trackpilots/date-picker
# or
yarn add @trackpilots/date-picker

Make sure Tailwind CSS is installed in your project.

📌 Usage

Use in Your Component

import React, { useState } from "react";
import DateFilter from "@trackpilots/date-picker";

const App = () => {
  const [selectedDate, setSelectedDate] = useState(null);
  const [chosenDate, setChosenDate] = useState(null);

  const handleSelect = (date) => {
    setSelectedDate(date);
    console.log("Selected Date:", date);
  };

  const handleChoose = (date) => {
    setChosenDate(date);
    console.log("Choosed Date:", date);
  };

  return (
    <div className="p-4">
      <h2 className="text-lg font-bold">Date Picker</h2>
      <DateFilter
        defaultChoosenDate={"This Month"}
        onSelect={handleSelect}
        onChoose={handleChoose}
        selectedColor="#FF5733"
      />
      <p className="mt-2">Choosed Date: {chosenDate ? chosenDate.toDateString() : "None"}</p>
      <p>Selected Date: {selectedDate ? selectedDate.toDateString() : "None"}</p>
    </div>
  );
};

export default App;

📌 DateFilter Component

A React Date Filter component that allows users to select predefined date ranges like "Today", "Yesterday", "Last 7 Days", "Last Week","This Week", "This Month", "Last Month" or "Custom Range".

⚙️ Props

Prop NameTypeDefaultDescription
defaultChoosenDatestring or nullTodayPredefined date range selection (e.g.,"Today", "Yesterday", "Last 7 Days", "Last Week","This Week", "This Month", "Last Month", "Custom Range").
startDateDate or nullnullThe starting date of the picker.
endDateDate or nullnullThe ending date of the picker.
onSelectfunction() => {}Triggered when a date is selected.
onChoosefunction() => {}Triggered when a date is choosed.
selectedColorstring"#9D55FF"Highlight color for the selected date.
iconReact.ElementTypeIoCalendarOutlineCustom calendar icon component.

✨ Example

<DateFilter 
  startDate={new Date("2024-06-01")} 
  endDate={new Date("2024-06-30")} 
  onSelect={(date) => console.log("User selected:", date)} 
  onChoose={(date) => console.log("User Choosed:", date)} 
  selectedColor="#007BFF"
/>

📦 Dependencies

📌 Maintainers

These packages are maintained by Quick App Studio Developers.

📄 License

This project is licensed under the MIT License.

1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.23

4 months ago

1.0.21

4 months ago

1.0.20

4 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.0.16

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.11

4 months ago

1.0.10

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago