Skip to content
Page

Calendar

Month grid for picking a date or a range.

Mon
Tue
Wed
Thu
Fri
Sat
Sun
import { Calendar } from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/CalendarExample.tsx
import { useState } from "react";
import { Calendar } from "@pelagornis/page/components";
export default function CalendarDemo() {
const [date, setDate] = useState(() => new Date());
return <Calendar value={date} onChange={setDate} weekStartsOn={1} />;
}

Calendar can be written straight in an .mdx page. Import it below the frontmatter. It responds to input, so add client:load to hydrate it.

src/content/docs/example.mdx
---
title: Example
---
import { Calendar } from "@pelagornis/page/components";
<Calendar client:load weekStartsOn={1} />

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/CalendarExample.astro
---
import CalendarExample from "../CalendarExample";
---
<CalendarExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"calendar-example": {
render: component("./src/components/markdoc/CalendarExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% calendar-example /%}

Parts of the component and the data-refineui role each one renders.

PartRole
rootcalendar
daycalendar-day

States the component styles. Component states are exposed as data attributes.

KindStates
Pseudofocus-visible

Keys the component handles when it has focus.

KeyAction
Enteractivate
Spaceactivate