Components
Loading preview...
Calendar [React-Area]
npx shadcn@latest add https://21st.dev/r/originui/calendar-rac"use client";
import { RangeCalendar } from "@/components/ui/calendar-rac";
import { getLocalTimeZone, isWeekend, today } from "@internationalized/date";
import { useLocale } from "react-aria";
import type { DateValue } from "react-aria-components";
function Component() {
const now = today(getLocalTimeZone());
const disabledRanges = [
[now, now],
[now.add({ days: 14 }), now.add({ days: 14 })],
[now.add({ days: 23 }), now.add({ days: 23 })],
];
const { locale } = useLocale();
const isDateUnavailable = (date: DateValue) =>
isWeekend(date, locale) ||
disabledRanges.some(
(interval) => date.compare(interval[0]) >= 0 && date.compare(interval[1]) <= 0,
);
return (
<div>
<RangeCalendar
className="rounded-lg border border-border p-2"
isDateUnavailable={isDateUnavailable}
minValue={today(getLocalTimeZone())}
/>
<p
className="mt-4 text-center text-xs text-muted-foreground"
role="region"
aria-live="polite"
>
Disabled dates -{" "}
<a
className="underline hover:text-foreground"
href="https://react-spectrum.adobe.com/react-aria/DateRangePicker.html"
target="_blank"
rel="noopener nofollow"
>
React Aria
</a>
</p>
</div>
);
}
export { Component };