gpuicn
Theme

Theme the previews

Every preview on the site is live GPUI and follows these.

Base
Accent
Radius
gpuicn theme set --base-color neutral --radius 0.625rem

Navigation and layout

Navigation Menu

A collection of links for navigating a site or app.

Added in 0.2.0 10 lines of Rust

Gallery

Starting the preview. GPUI compiles to WebAssembly, so the first load takes a few seconds. This browser has neither WebGPU nor WebGL 2, so the live preview cannot run. The code on this page still works. The preview did not start.

Installation

After the one-time setup, run the command from your app root. The CLI writes the modules and keeps src/ui/mod.rs in step.

gpuicn add navigation-menu

If you prefer to copy the files by hand, declare them yourself:

// src/ui/mod.rs
pub mod theme;
pub mod button;
pub mod kbd;
pub mod menu;
pub mod menubar;
pub mod navigation_menu;

// src/main.rs
mod ui;

Usage

Put this in a view module and return example(state) from its render method.

use crate::ui::menu::*;
use crate::ui::navigation_menu::*;
use gpui_kit::{Entity, IntoElement};

fn example(state: &Entity<MenuState>) -> impl IntoElement {
    navigation_menu("docs", "Documentation").menu(state, "Getting started")
}

Examples

With descriptions

A link can carry an icon and a line saying where it leads.

Starting the preview. GPUI compiles to WebAssembly, so the first load takes a few seconds. This browser has neither WebGPU nor WebGL 2, so the live preview cannot run. The code on this page still works. The preview did not start.

API reference

pub fn navigation_menu(id: impl Into<ElementId>, label: impl Into<SharedString>) -> Menubar

Create a named navigation landmark; supply menus of `MenuItem::link` entries with caller-owned navigation handlers.

Installed source, 10 lines
//! Navigation menus composed from Nova menus and link items.
use super::menubar::Menubar;
use gpui_kit::{ElementId, Role, SharedString};
/// Create a named navigation landmark; supply menus of `MenuItem::link` entries with caller-owned navigation handlers.
pub fn navigation_menu(id: impl Into<ElementId>, label: impl Into<SharedString>) -> Menubar {
    let mut menu = Menubar::new(id, label);
    menu.role = Role::Navigation;
    menu
}

Platform notes

Visual reference: shadcn/ui 4.19.0, Neutral Nova. Implementation: crates/ui/registry/navigation_menu/navigation_menu.rs, using GPUI Kit 0.6.4.

Navigation Menu composes the Menubar trigger and popup behavior with link items. The application handles link activation and routing through on_click. Arbitrary rich navigation panels are outside this API.

The Rust source and Usage example define the supported API. Browser DOM/CSS behavior, exact exit animations and cross-platform screen-reader parity are not implied by the native component. See migration qualification for the checks completed on this revision.