Skip to content

Examples

Calendar

Render occurrence projections and hand empty-range selections back to an App-owned creation flow.

Public contractsNxCalendar

Live preview

Live

Calendar projection

Occurrences render domain records; selecting empty time only calls the App-owned creation flow.

NxCalendar

Use Alt and arrow keys to move; add Shift to resize.

Selected range: Select an empty time range to inspect the creation callback.

Copyable source

Code example
TSX
import { useState } from "react";

import type { NxCalendarSelection } from "@nexia/sdk/host";
import { NxCalendar } from "@nexia/sdk/host";

export function CalendarExample() {
    const [day] = useState(() =>
        new Date().toLocaleDateString("sv-SE", { timeZone: "Asia/Seoul" })
    );
    const [selection, setSelection] = useState<NxCalendarSelection | null>(
        null
    );

    return (
        <div>
            <div className="h-[34rem]">
                <NxCalendar
                    occurrences={[
                        {
                            source_key: "production.operations",
                            app_key: "manufacturing",
                            occurrence_id: "operation-42",
                            source_revision: "1",
                            resource: {
                                app_key: "manufacturing",
                                resource_key: "operation",
                                resource_id: "42",
                                display: "Operation 42",
                            },
                            title: "CNC operation 42",
                            start: `${day}T09:00:00+09:00`,
                            end: `${day}T11:00:00+09:00`,
                            all_day: false,
                            timezone: "Asia/Seoul",
                            allowed_actions: [],
                        },
                    ]}
                    timezone="Asia/Seoul"
                    locale="en"
                    initialView="timeGridWeek"
                    fill
                    loadingLabel="Loading calendar"
                    emptyTitle="No scheduled work"
                    emptyDescription="No occurrences fall within this range."
                    errorTitle="Calendar unavailable"
                    errorDescription="Reload and try again."
                    readOnlyDescription="This calendar is read-only."
                    retryLabel="Retry"
                    actionErrorMessage={(reason) =>
                        `Calendar action rejected: ${reason}`
                    }
                    keyboardInstructions="Use Alt and arrow keys to move; add Shift to resize."
                    onSelectRange={setSelection}
                />
            </div>
            {selection ? (
                <p>
                    Create from {selection.start} to {selection.end}
                </p>
            ) : null}
        </div>
    );
}