Restricciones

Días Mínimos y Máximos

Restringe la longitud del rango con minDays y maxDays (inclusive). Los usuarios no pueden confirmar un rango más corto que minDays o más largo que maxDays.

import { useState } from "react";
import "react-date-range-picker-styled/rdrp-styles.css";
import { DateRangePicker } from "react-date-range-picker-styled";
function MinMaxDays() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return <DateRangePicker value={value} onChange={setValue} minDays={3} maxDays={14} />;
}

Fechas Deshabilitadas

Usa isDateUnavailable para deshabilitar dinámicamente fechas específicas. Las fechas deshabilitadas no pueden ser seleccionadas como inicio o fin de un rango.

import { useState } from "react";
import "react-date-range-picker-styled/rdrp-styles.css";
import { DateRangePicker } from "react-date-range-picker-styled";
const isWeekend = (date: Date) => {
const day = date.getDay();
return day === 0 || day === 6;
};
function DisabledDates() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return <DateRangePicker value={value} onChange={setValue} isDateUnavailable={isWeekend} />;
}

Permitir Fecha Única

Por defecto, se permite un rango donde el inicio es igual al fin. Establece allowSingleDateInRange={false} para requerir al menos dos fechas distintas.

import { useState } from "react";
import { DateRangePicker } from "react-date-range-picker-styled";
import "react-date-range-picker-styled/rdrp-styles.css";
function AllowSingleDate() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return <DateRangePicker value={value} onChange={setValue} allowSingleDateInRange={false} />;
}