Skip to content
العربية
Boards and calendars

CalendarView

A month of events in the Gregorian or Hijri calendar. Up to 3 events show per day, the rest in a list; below 768 px it shows only the days that have events.

import { CalendarView } from "@percentsa/ui";

Examples

December 2026

  1. Wednesday 2 December 2026

  2. Thursday 3 December 2026

  3. Friday 4 December 2026

  4. Saturday 5 December 2026

  5. Sunday 6 December 2026

  6. Sunday 13 December 2026

Choose an event.

Code
export function CalendarViewExample() {
  const t = useT();
  const [calendar, setCalendar] = useState<"gregorian" | "hijri">("gregorian");
  const [picked, setPicked] = useState<string>();
  const today = useMemo(todayPlain, []);
  const events: CalendarEvent[] = [
    { id: "kickoff", title: t("Kickoff", "اجتماع الانطلاق"), start: addDays(today, -6) },
    { id: "sprint", title: t("Design sprint", "أسبوع التصميم"), start: addDays(today, -2), end: addDays(today, 2) },
    { id: "review", title: t("Client review", "مراجعة مع العميل"), start: today },
    { id: "invoice", title: t("Invoice due", "استحقاق الفاتورة"), start: today, tone: "muted" },
    { id: "lunch", title: t("Team lunch", "غداء الفريق"), start: today, tone: "muted" },
    { id: "launch", title: t("Launch", "الإطلاق"), start: addDays(today, 9) },
  ];
  const chosen = events.find((e) => e.id === picked);
  return (
    <Stack gap={4} className="w-full">
      <SegmentedControl
        className="self-start"
        aria-label={t("Calendar", "التقويم")}
        value={calendar}
        onValueChange={(v) => setCalendar(v as typeof calendar)}
        options={[
          { value: "gregorian", label: t("Gregorian", "ميلادي") },
          { value: "hijri", label: t("Hijri", "هجري") },
        ]}
      />
      <CalendarView events={events} calendar={calendar} onEventClick={(e) => setPicked(e.id)} />
      <Text size="sm" tone="muted" aria-live="polite">
        {chosen ? t(`Chosen: ${chosen.title}`, `المختار: ${chosen.title}`) : t("Choose an event.", "اختر حدثًا.")}
      </Text>
    </Stack>
  );
}