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

Overlays

Hover Card

Previews content behind a link or trigger.

Added in 0.2.0 15 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 preview-card button

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

// src/ui/mod.rs
pub mod theme;
pub mod preview_card;
pub mod button;

// src/main.rs
mod ui;

Usage

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

use crate::ui::button::Button;
use crate::ui::preview_card::*;
use gpui_kit::{IntoElement, ParentElement};

fn example() -> impl IntoElement {
    preview_card("profile")
        .trigger(Button::new("profile.link").label("@gpuicn"))
        .content(|_, _, cx| {
            preview_card_popup("profile.popup", cx).child("Native GPUI components")
        })
}

Examples

Profile

The popup takes any content: here an avatar, a name and a short bio.

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.

In a sentence

A link trigger sits in running text; rest the pointer on it to preview the page.

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 preview_card(id: impl Into<ElementId>) -> HoverCard

Supply a trigger and a content builder to the Kit hover card.

pub fn preview_card_popup(id: impl Into<ElementId>, cx: &App) -> Stateful<Div>

The 256px Nova preview surface.

Installed source, 15 lines
//! Nova hover-card surfaces using Kit's delayed hover lifecycle.
use super::theme::{UiTheme, primitives::surface};
pub use gpui_kit::base::{HoverCard, HoverCardState};
use gpui_kit::{App, Div, ElementId, InteractiveElement as _, Stateful, Styled, div};

/// Supply a trigger and a content builder to the Kit hover card.
pub fn preview_card(id: impl Into<ElementId>) -> HoverCard {
    HoverCard::new(id)
}
/// The 256px Nova preview surface.
pub fn preview_card_popup(id: impl Into<ElementId>, cx: &App) -> Stateful<Div> {
    let t = UiTheme::read(cx);
    surface::popover(div().id(id).w(t.space(64.)).p(t.space(2.5)), t)
}

Platform notes

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

Kit HoverCard owns hover/focus timing, trigger and positioning. gpuicn supplies the Nova surface. The application provides trigger content and the preview closure.

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.