Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Menubar with Checkboxes for Ark UI

A View menu of checkbox rows: Show Toolbar and Show Status Bar start checked, and Show Sidebar starts clear.

View opens three checkbox rows: Show Toolbar, Show Sidebar and Show Status Bar. Toolbar and Status Bar start checked. Sidebar starts clear. More than one can be on.

Use checkbox rows for panels people show and hide independently. For a choice where only one layout can be on, use a Radio Group. On React, Ark UI does not remember the checks after a refresh.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Menubar anatomy: trigger, root, item, separator, sub trigger, content

Usage

<Menubar>
  <MenubarMenu>
    <MenubarTrigger>View</MenubarTrigger>
    <MenubarContent>
      <MenubarGroup>
        <MenubarCheckboxItem
          checked={toolbar}
          onCheckedChange={setToolbar}
          value="toolbar"
        >
          Show Toolbar
        </MenubarCheckboxItem>
        <MenubarCheckboxItem
          checked={sidebar}
          onCheckedChange={setSidebar}
          value="sidebar"
        >
          Show Sidebar
        </MenubarCheckboxItem>
        <MenubarCheckboxItem
          checked={statusBar}
          onCheckedChange={setStatusBar}
          value="status-bar"
        >
          Show Status Bar
        </MenubarCheckboxItem>
      </MenubarGroup>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

FAQ

How do these View checkboxes stay checked?

Show Toolbar and Show Status Bar start checked and Show Sidebar starts off. The state lives in the component, so the checks are still there the next time View opens. Each MenubarCheckboxItem takes checked, onCheckedChange, which receives a boolean, and a value.

Where do the checkboxes sit?

In one MenubarMenu: the MenubarTrigger reads View, and its MenubarContent holds a MenubarGroup with the three rows.

Can more than one of these be on?

Yes. Each row keeps its own state. Use MenubarRadioGroup when only one option may be on.

How do I toggle a row from the keyboard?

Open View with Enter, Space or Arrow Down, move to the row with the arrow keys, and press Enter or Space to toggle it.

How do I name this set of toggles?

Put a MenubarLabel first inside the MenubarGroup, above the rows. It names the group and can't be focused.

What order are the rows in?

Show Toolbar, Show Sidebar, then Show Status Bar. Sidebar is the one that starts unchecked.

API Reference

Menubar

Sets checked={toolbar}, onCheckedChange={setToolbar}, value="toolbar", checked={sidebar}, onCheckedChange={setSidebar} and value="sidebar". The rest is on the Menubar page.