05customization
Toolbar & chrome
Kloq.Toolbar, Kloq.Nav, Kloq.Reset and useKloq() — the app bar as opt-in composable parts.
<Kloq> renders no app bar of its own — the chrome is opt-in parts you
compose as children. It used to render its own header, wordmark and all; that
made it an app, not a component. Now naming the product is the host's
business.
The parts
Use the dotted forms in "use client" files. A server component can't read
Kloq.Toolbar off the client export (it arrives as undefined and the
build fails), so there use the named exports KloqToolbar / KloqNav /
KloqReset — identical components.
| Part | Type | Notes |
|---|---|---|
Kloq.Toolbar | KloqToolbarProps | A bordered app-bar row above the surface. Pure layout — holds no state. With no children it renders the built-in arrangement: nav left, Reset right, no wordmark. |
Kloq.Nav | { className? } | ‹ › Today, the range title (with its month/year picker), and the view switcher. |
Kloq.Reset | { className? } | Restore the sample events — through the store, so it hits onCommit and persistence like any other change. In a phone-width box it is the icon alone. |
The same components are importable by name — KloqToolbar, KloqNav,
KloqReset — the statics are a convenience. The toolbar's responsiveness is
flex-wrap: below ~640px the nav and your controls stack instead of the view
switcher being squeezed to nothing.
Why children, not siblings
The parts read useKloq() — the same view, anchor date and store the grid is
using — so they have to be inside the provider. Rendering them as children of
<Kloq> buys three things a sibling layout would have to re-solve: the
keyboard layer's ownership test sees a click on Today as landing inside the
calendar, so t / ← / → keep working; design mode's scope and
hover-inspect cover the toolbar; and a host never has to prop-drill view /
onViewChange to reproduce the built-in bar.
A host that genuinely wants the bar somewhere else on the page can still
build one from the public view / onViewChange / date / onDateChange
props — that is what they are for.
useKloq()
The calendar's live view state and navigation actions, as one object —
KloqChrome. Only valid inside <Kloq>: outside it there is no calendar to
describe, and it throws rather than returning a plausible-looking default that
would hide the mistake until a button silently did nothing.
| prop | type · description |
|---|---|
view | ViewDescriptorThe resolved EFFECTIVE view: columns, dates, today's index — after any responsive collapse. |
viewSetting | KloqViewThe effective view *setting* ( |
collapsed? | booleanTrue while the box is overriding the view (three days or a day). |
narrow? | booleanTrue below the narrow breakpoint — the nav uses a short title and Reset drops to its icon. Unset until the box has been measured. |
ready? | booleanFalse on the server and during hydration when the calendar has no |
timeline? | booleanTrue when the host passed |
fits? | (view: KloqView) => booleanWhether a view fits the box at its current width; the switcher disables the ones that don't. |
date | DateThe anchor date the view is resolved around. |
atToday | booleanTrue when today is inside the visible range. |
lastStep | StepDirection | nullDirection of the last range step, for directional animation. |
step(dir) | (dir) => voidStep the range by one of the current view's units. |
goToday() | () => voidMove the range back onto today. |
switchView(view) | (view: KloqView) => voidRequest a view change — reports through |
jumpToDay(date) | (date: Date) => voidMove the anchor and switch to the day view. |
goToDate(date) | (date: Date) => voidMove the anchor, leaving the view alone. |
reset() | () => voidRestore the sample events. |
openCommand() / openShortcuts() | () => voidOpen ⌘K / the ? shortcuts overlay. |
keymap? | KeymapThe host's keymap overrides, so chrome that advertises a key shows the real binding. |
Composing your own bar
Anything inside the toolbar can call useKloq() — your components and the
built-ins read the same context, so a custom Today button is
onClick={k.goToday} and nothing more. Note the distinction the shape
encodes: view is what is drawn, viewSetting is the setting behind it,
and collapsed says a narrow box is overriding what the host asked for —
chrome that steps the range or highlights the active view should read the
effective one, or ‹ › would step by a week while showing a day.