Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Calendar View Navbar Block for React

A calendar navbar for a shared scheduling app that moves a day, week, month or agenda label with Today, previous and next.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A calendar navbar for React with Base UI, the bar of Hourfold, a shared calendar. Previous and next step the range, Today jumps to the current day, and a segment (Day, Week, Month, Agenda) changes how the range is written: a weekday and date, a Monday-to-Sunday week, a month and year, or a two-week agenda. The label is filled in after mount from the visitor's clock, so the server and the first paint both say Today, and a hidden line reserves the width of the longest range so the bar doesn't jump. T is the shortcut for Today. New event is the Shine Button, a link to #new-event. On a phone the segment becomes a native select and the words hide. The page's rails and top rule come from the Guides spine, and interior hairlines meet that rule with a plus. The block stays 56 pixels high. It's built from Segment Group, Native Select, Button, Shine Button, Kbd and Guides. For calendars and scheduling tools whose header is the date control.

FAQ

Where does the date come from, and can I set a fixed one?

The first paint says Today, with no clock read, so server and client markup match. After mount an effect takes the local year, month and day and writes the range for the current view. Nothing in the file is a typed date. To open on a known day, set anchor yourself after you know it and skip that effect. Week ranges start on Monday. Stepping a month clamps to the last day of the month, so the 31st doesn't spill into the next one.

How do the four views change the label?

Day writes the weekday and the date. Week writes the Monday-to-Sunday range, and names both months when the week crosses one. Month writes the month and the year. Agenda writes the fourteen days that start on the anchor. Previous and next move by one day, one week, one month or two weeks. The buttons' names follow the view ("Previous week", "Next month"). Changing the view keeps the anchor and rewrites the label.

How does the view control work with a keyboard?

From the md breakpoint the views are a segment group named Calendar view. The arrow keys move to a view and choose it. Below md the same choice is a native select, which behaves like any select on that platform. T jumps to today from anywhere that isn't a text field. Previous, next, Today and New event follow in the tab order.

How do I point New event at a real composer?

New event is a link to #new-event. Point that href at your composer. It does not create an event in this demo. The Shine Button renders the link with render, with nativeButton={false}.

How does it fit on a phone?

Below md the segment is hidden and a native select shows the same four views. Below sm the wordmark is its icon, Today is an icon with the word kept for screen readers (both hide under 23 rem, about 368 px, to make room; the t key still works), and New event is an icon. The range is written with three-letter month and weekday names (Oct 12–18) and truncates only if a range that crosses a month still doesn't fit; a screen reader gets the full string. The key hint on Today shows from lg. Nothing wraps. The bar is 56 pixels at every width.

What moves, and what happens with reduced motion?

Nothing moves on load. Stepping the range replaces the text in a cell whose width is reserved from the sm breakpoint, so the row doesn't shift. A band of light sweeps across New event once on hover and keyboard focus. With reduced motion that light fades in where it stands.

  • Pro

    Contextual Navbar

    Cells and splits

    A navbar with a Site | App segment control whose two link sets and action sets cross-fade in one grid cell, so the bar's width and height never change.

  • Pro

    Environment Switcher Navbar

    Accounts and scopes

    An app bar with a Production, Staging and Development segment control that shows the environment's base URL with a copy button and asks for confirmation before switching to Production.

  • Pro

    A navbar for a meal-planning app that centres its three destinations in a tray of equal segments, each an icon, a label and a count, with one raised thumb that slides under the current one and folds to icons on a phone.

  • Pro

    A builder navbar for a landing-page tool that switches the preview between desktop, tablet and mobile, shows the viewport size, and undoes those choices.

  • Pro

    A two-row header whose second row shows the chosen section's four links, the three link sets cross-fading in one grid cell, with the current section and the current page both marked.

  • Pro

    An app navbar whose shortcuts work: G then H, P or S moves between pages, a question mark opens a dialog with every key in a table, and each link shows its keys on hover and keyboard focus.