Behavior
Close on Select
When shouldCloseOnSelect is enabled, the picker automatically confirms and closes when the end date is selected.
import { useState } from "react";import { DateRangePicker } from "react-date-range-picker-tailwind3";
function ShouldCloseOnSelect() { const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({ start: null, end: null, });
return <DateRangePicker value={value} onChange={setValue} shouldCloseOnSelect />;}Multiple Months
Display more than the default two months side by side.
import { useState } from "react";import { DateRangePicker } from "react-date-range-picker-tailwind3";
function MultiMonth() { const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({ start: null, end: null, });
return <DateRangePicker value={value} onChange={setValue} numberOfMonths={3} />;}Form Integration
Use the name prop to include hidden inputs for native form submission.
💡 Tip
The submit button styling in this example is custom — the library only provides the date picker.
import { type SubmitEvent, useState } from "react";import { DateRangePicker } from "react-date-range-picker-tailwind3";
function FormIntegration() { const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({ start: null, end: null, });
const handleSubmit = (e: SubmitEvent<HTMLFormElement>) => { e.preventDefault(); const formData = new FormData(e.currentTarget); const start = formData.get("booking"); const end = formData.get("booking-end"); alert( `Submitted range: ${typeof start === "string" ? start : ""} ~ ${typeof end === "string" ? end : ""}`, ); };
return ( <form onSubmit={handleSubmit} style={{ display: "flex", alignItems: "center", gap: 8 }}> <DateRangePicker value={value} onChange={setValue} name="booking" /> <button type="submit" style={{ padding: "6px 14px", border: "1px solid #d1d5db", borderRadius: 6, background: "#3b82f6", color: "#fff", cursor: "pointer", fontSize: 13, }} > Submit </button> </form> );}