外観

複数月表示

2ヶ月以上を並べて表示します。範囲ピッカーのデフォルトは 2 です。

import { useState } from "react";
import { DateRangePicker } from "react-date-range-picker-tailwind4";
function MultiMonth() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return <DateRangePicker value={value} onChange={setValue} numberOfMonths={3} />;
}

カスタムロケール

headless パッケージの createLocale を使用して、月/日の名前やUI文字列をカスタマイズします。

import { useState } from "react";
import { DateRangePicker } from "react-date-range-picker-tailwind4";
import { createLocale } from "react-date-range-picker-headless";
const koLocale = createLocale("ko-KR", {
confirm: "확인",
cancel: "취소",
clear: "초기화",
today: "오늘",
rangePlaceholder: "날짜 범위 선택",
rangeSeparator: " ~ ",
});
function CustomLocale() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return <DateRangePicker value={value} onChange={setValue} locale={koLocale} />;
}

キャプションのドロップダウン

月と年のナビゲーションをボタンからドロップダウンセレクターに切り替えます。現在の月から離れた日付を選択するのに便利です。

import { useState } from "react";
import { DateRangePicker } from "react-date-range-picker-tailwind4";
function CaptionDropdown() {
const [value, setValue] = useState<{ start: Date | null; end: Date | null }>({
start: null,
end: null,
});
return (
<DateRangePicker
value={value}
onChange={setValue}
captionLayout="dropdown"
fromYear={2020}
toYear={2030}
/>
);
}