Behavior

Close on Select

When shouldCloseOnSelect is enabled, the picker automatically confirms and closes when a date is clicked.

import { useState } from "react";
import { DateTimePicker } from "react-date-range-picker-tailwind3";
function ShouldCloseOnSelect() {
const [value, setValue] = useState<Date | null>(null);
return (
<DateTimePicker
value={value}
onChange={setValue}
shouldCloseOnSelect
time={{ minuteStep: 5 }}
/>
);
}

Multiple Months

Display multiple months side by side.

import { useState } from "react";
import { DateTimePicker } from "react-date-range-picker-tailwind3";
function MultiMonth() {
const [value, setValue] = useState<Date | null>(null);
return (
<DateTimePicker value={value} onChange={setValue} numberOfMonths={2} time={{ minuteStep: 5 }} />
);
}

Form Integration

Use the name prop to include a hidden input 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 { DateTimePicker } from "react-date-range-picker-tailwind3";
function FormIntegration() {
const [value, setValue] = useState<Date | null>(null);
const handleSubmit = (e: SubmitEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
const appointment = formData.get("appointment");
alert(`Submitted datetime: ${typeof appointment === "string" ? appointment : ""}`);
};
return (
<form onSubmit={handleSubmit}>
<DateTimePicker value={value} onChange={setValue} name="appointment" />
<button type="submit" style={{ marginTop: 8 }}>
Submit
</button>
</form>
);
}