Behavior

Close on Select

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

ℹ️ Info

For time-enabled pickers, shouldCloseOnSelect only applies to preset clicks — not date clicks, since the user still needs to set the time.

import { useState } from "react";
import "react-date-range-picker-styled/rdrp-styles.css";
import { DateRangeTimePicker } from "react-date-range-picker-styled";
function ShouldCloseOnSelect() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return (
<DateRangeTimePicker
value={value}
onChange={setValue}
shouldCloseOnSelect
time={{ minuteStep: 5 }}
/>
);
}

Multiple Months

Display more than the default two months side by side.

import { useState } from "react";
import "react-date-range-picker-styled/rdrp-styles.css";
import { DateRangeTimePicker } from "react-date-range-picker-styled";
function MultiMonth() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return (
<DateRangeTimePicker
value={value}
onChange={setValue}
numberOfMonths={3}
time={{ minuteStep: 5 }}
/>
);
}

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 "react-date-range-picker-styled/rdrp-styles.css";
import { DateRangeTimePicker } from "react-date-range-picker-styled";
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 }}>
<DateRangeTimePicker
value={value}
onChange={setValue}
name="booking"
time={{ minuteStep: 5 }}
/>
<button
type="submit"
style={{
padding: "6px 14px",
border: "1px solid #d1d5db",
borderRadius: 6,
background: "#3b82f6",
color: "#fff",
cursor: "pointer",
fontSize: 13,
}}
>
Submit
</button>
</form>
);
}