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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shonum/tailwind-datepicker-react

v0.0.4

Published

A tailwindcss/flowbite datepicker component built as a react component with types

Downloads

2

Readme

NPM Version NPM Minified Size GitHub deployments

Tailwind-datepicker-react

A Tailwindcss/Flowbite datepicker component built as a React component with types based on the original datepicker from Flowbite. This component can also be used as a plugin using the Flowbite React library.

Date logic from VanillaJS-datepicker.

Demo

thumbnail

Installation

  1. Install the package
npm install tailwind-datepicker-react
yarn add tailwind-datepicker-react
  1. Add the styles to your tailwind.config.js file
module.exports = {
    ...
    content: [
        ...
        "./node_modules/tailwind-datepicker-react/dist/**/*.js", // <--- Add this line
    ],

};
  1. Import the component and use it
import Datepicker from "tailwind-datepicker-react"

Usage

Basic

const options = {
	title: "Demo Title",
	autoHide: true,
	todayBtn: false,
	clearBtn: true,
	maxDate: new Date("2030-01-01"),
	minDate: new Date("1950-01-01"),
	theme: {
		background: "bg-gray-700 dark:bg-gray-800",
		todayBtn: "",
		clearBtn: "",
		icons: "",
		text: "",
		disabledText: "bg-red-500",
		input: "",
		inputIcon: "",
		selected: "",
	},
	icons: {
		// () => ReactElement | JSX.Element
		prev: () => <span>Previous</span>,
		next: () => <span>Next</span>,
	},
	datepickerClassNames: "top-12",
	defaultDate: new Date("2022-01-01"),
	language: "en",
}

const DemoComponent = () => {
	const [show, setShow] = useState <boolean>(false)
	const handleChange = (selectedDate: Date) => {
		console.log(selectedDate)
	}
	const handleClose = (state: boolean) => {
		setShow(state)
	}

	return (
		<div>
			<Datepicker options={options} onChange={handleChange} show={show} setShow={handleClose} />
		</div>
	)
}

Advanced - Custom input field

const options = {
    title: "Demo Title",
	autoHide: true,
	todayBtn: false,
	clearBtn: true,
    maxDate: new Date("2030-01-01"),
    minDate: new Date("1950-01-01"),
	theme: {
		background: "bg-gray-700 dark:bg-gray-800",
		todayBtn: "",
		clearBtn: "",
		icons: "",
		text: "",
		disabledText: "bg-red-500",
		input: "",
		inputIcon: "",
		selected: "",
	},
    icons: { // () => ReactElement | JSX.Element
        prev: () => <span>Previous</span>,
        next: () => <span>Next</span>,
    },
	datepickerClassNames: "top-12",
	defaultDate: new Date("2022-01-01"),
	language: "en",
}

const DemoComponent = () => {
    const [show, setShow] = useState<boolean>(false)
    const [selectedDate, setSelectedDate] = useState<Date | null>(null)
	const handleChange = (selectedDate: Date) => {
        setSelectedDate(selectedDate)
		console.log(selectedDate)
	}
    const handleClose = (state: boolean) => {
        setShow(state)
    }

	return (
		<div>
			<Datepicker options={options} onChange={handleChange} show={show} setShow={handleClose} />
                <div className="...">
					<div className="...">
						<CalendarIcon />
					</div>
                    <input
                        type="text"
                        className="..."
                        placeholder="Select Date"
                        value={selectedDate}
                        onFocus={() => setShow(true)}
                        readOnly
                    />
				</div>
            </DatePicker>
		</div>
	)
}

DatePicker Props

  • children?: ReactElement
  • options?: IOptions
  • onChange?: (date: Date) => void
  • show: boolean
  • setShow: (show: boolean) => void
  • classNames?: string

IOptions

  • title?: string - Default: disabled
  • autoHide?: boolean - Default: true
  • todayBtn?: boolean - Default: true
  • clearBtn?: boolean - Default: true
  • maxDate?: Date - Default: disabled
  • minDate?: Date - Default: disabled
  • theme?: ITheme - Default: As seen on demo page
  • icons?: IIcons - Default: As seen on demo page
  • datepickerClassNames?: string - Default: ""
  • defaultDate?: Date - Default: new Date()
  • language?: string - Default: en

ITheme

  • background: string
  • todayBtn: string
  • clearBtn: string
  • icons: string
  • text: string
  • disabledText: string
  • input: string
  • inputIcon: string
  • selected: string

IIcons

  • prev: () => ReactNode | JSX.Element
  • next: () => ReactNode | JSX.Element

License

This project is open-source under the MIT License.