Skip to content

The Open Standard for Generative UI

Nav: rename Demos and Lab, add preview mega-menu (#826)

Zahle Khan5ba5d205a0ac
diff --git a/docs/app/(home)/projects/page.module.css b/docs/app/(home)/lab/page.module.css
similarity index 100%
rename from docs/app/(home)/projects/page.module.css
rename to docs/app/(home)/lab/page.module.css
diff --git a/docs/app/(home)/projects/page.tsx b/docs/app/(home)/lab/page.tsx
similarity index 98%
rename from docs/app/(home)/projects/page.tsx
rename to docs/app/(home)/lab/page.tsx
index d94f29875..3dec83070 100644
--- a/docs/app/(home)/projects/page.tsx
+++ b/docs/app/(home)/lab/page.tsx
@@ -279,17 +279,17 @@ const projects: ProjectItem[] = [
const DISCORD_URL = "https://discord.gg/suzHfJnpw";
export const metadata: Metadata = {
- title: "OpenUI Projects",
+ title: "OpenUI Lab",
description: "Official and community projects built around OpenUI.",
- alternates: { canonical: "/projects" },
+ alternates: { canonical: "/lab" },
openGraph: {
- title: "OpenUI Projects",
+ title: "OpenUI Lab",
description: "Discover official and community projects built around OpenUI.",
- url: "/projects",
+ url: "/lab",
type: "website",
},
twitter: {
- title: "OpenUI Projects",
+ title: "OpenUI Lab",
description: "Discover official and community projects built around OpenUI.",
card: "summary_large_image",
},
@@ -303,14 +303,14 @@ function DiscordIcon({ className }: { className?: string }) {
);
}
-export default function ProjectsPage() {
+export default function LabPage() {
return (
<main className={styles.page}>
<PageHero
smallSubtitle
title={
<>
- OpenUI <PageHeroAccent>Projects</PageHeroAccent>
+ OpenUI <PageHeroAccent>Lab</PageHeroAccent>
</>
}
subtitle={
diff --git a/docs/app/(home)/sections/HeroSection/HeroSection.tsx b/docs/app/(home)/sections/HeroSection/HeroSection.tsx
index 653ac54b1..5603cd53b 100644
--- a/docs/app/(home)/sections/HeroSection/HeroSection.tsx
+++ b/docs/app/(home)/sections/HeroSection/HeroSection.tsx
@@ -230,7 +230,7 @@ function CommandTabs({
function DesktopPlaygroundButton({ className = "" }: { className?: string }) {
return (
<PillLink
- href="/playground"
+ href="/demos"
className={`${styles.desktopPlaygroundButton} ${className}`.trim()}
arrow={<TrailingArrow />}
>
diff --git a/docs/app/api/playground/stream/route.ts b/docs/app/api/playground/stream/route.ts
index 132003e54..a5e931a44 100644
--- a/docs/app/api/playground/stream/route.ts
+++ b/docs/app/api/playground/stream/route.ts
@@ -24,7 +24,7 @@ export async function POST(req: NextRequest) {
headers: {
Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
"Content-Type": "application/json",
- "HTTP-Referer": `${BASE_URL}/playground`,
+ "HTTP-Referer": `${BASE_URL}/demos`,
"X-Title": "OpenUI Playground",
},
body: JSON.stringify({
diff --git a/docs/app/playground/components/CatalogPanel/CatalogPanel.css b/docs/app/demos/components/CatalogPanel/CatalogPanel.css
similarity index 100%
rename from docs/app/playground/components/CatalogPanel/CatalogPanel.css
rename to docs/app/demos/components/CatalogPanel/CatalogPanel.css
diff --git a/docs/app/playground/components/CatalogPanel/CatalogPanel.tsx b/docs/app/demos/components/CatalogPanel/CatalogPanel.tsx
similarity index 100%
rename from docs/app/playground/components/CatalogPanel/CatalogPanel.tsx
rename to docs/app/demos/components/CatalogPanel/CatalogPanel.tsx
diff --git a/docs/app/playground/components/CodePanel/CodePanel.css b/docs/app/demos/components/CodePanel/CodePanel.css
similarity index 100%
rename from docs/app/playground/components/CodePanel/CodePanel.css
rename to docs/app/demos/components/CodePanel/CodePanel.css
diff --git a/docs/app/playground/components/CodePanel/CodePanel.tsx b/docs/app/demos/components/CodePanel/CodePanel.tsx
similarity index 100%
rename from docs/app/playground/components/CodePanel/CodePanel.tsx
rename to docs/app/demos/components/CodePanel/CodePanel.tsx
diff --git a/docs/app/playground/components/Header/Header.tsx b/docs/app/demos/components/Header/Header.tsx
similarity index 100%
rename from docs/app/playground/components/Header/Header.tsx
rename to docs/app/demos/components/Header/Header.tsx
diff --git a/docs/app/playground/components/Modal/Modal.css b/docs/app/demos/components/Modal/Modal.css
similarity index 100%
rename from docs/app/playground/components/Modal/Modal.css
rename to docs/app/demos/components/Modal/Modal.css
diff --git a/docs/app/playground/components/Modal/Modal.tsx b/docs/app/demos/components/Modal/Modal.tsx
similarity index 100%
rename from docs/app/playground/components/Modal/Modal.tsx
rename to docs/app/demos/components/Modal/Modal.tsx
diff --git a/docs/app/playground/components/PreviewPanel/PreviewPanel.css b/docs/app/demos/components/PreviewPanel/PreviewPanel.css
similarity index 100%
rename from docs/app/playground/components/PreviewPanel/PreviewPanel.css
rename to docs/app/demos/components/PreviewPanel/PreviewPanel.css
diff --git a/docs/app/playground/components/PreviewPanel/PreviewPanel.tsx b/docs/app/demos/components/PreviewPanel/PreviewPanel.tsx
similarity index 100%
rename from docs/app/playground/components/PreviewPanel/PreviewPanel.tsx
rename to docs/app/demos/components/PreviewPanel/PreviewPanel.tsx
diff --git a/docs/app/playground/constants.ts b/docs/app/demos/constants.ts
similarity index 100%
rename from docs/app/playground/constants.ts
rename to docs/app/demos/constants.ts
diff --git a/docs/app/playground/layout.css b/docs/app/demos/layout.css
similarity index 100%
rename from docs/app/playground/layout.css
rename to docs/app/demos/layout.css
diff --git a/docs/app/playground/layout.tsx b/docs/app/demos/layout.tsx
similarity index 73%
rename from docs/app/playground/layout.tsx
rename to docs/app/demos/layout.tsx
index 35b1cf933..c1f2b6841 100644
--- a/docs/app/playground/layout.tsx
+++ b/docs/app/demos/layout.tsx
@@ -5,10 +5,10 @@ import "./layout.css";
export const metadata: Metadata = {
alternates: {
- canonical: "/playground",
+ canonical: "/demos",
},
};
-export default function PlaygroundLayout({ children }: { children: ReactNode }) {
+export default function DemosLayout({ children }: { children: ReactNode }) {
return <WebsiteThemeProvider>{children}</WebsiteThemeProvider>;
}
diff --git a/docs/app/playground/page.tsx b/docs/app/demos/page.tsx
similarity index 99%
rename from docs/app/playground/page.tsx
rename to docs/app/demos/page.tsx
index 587ba56f3..d1c3cb970 100644
--- a/docs/app/playground/page.tsx
+++ b/docs/app/demos/page.tsx
@@ -10,7 +10,7 @@ import { Header } from "./components/Header/Header";
import { PreviewPanel } from "./components/PreviewPanel/PreviewPanel";
import { MODELS, STARTER_PROMPTS, type Model, type Status, type Theme } from "./constants";
-export default function PlaygroundPage() {
+export default function DemosPage() {
const { theme, setTheme } = useTheme();
const [prompt, setPrompt] = useState("");
const [model, setModel] = useState<Model>("anthropic/claude-sonnet-4.6");
diff --git a/docs/app/sitemap.ts b/docs/app/sitemap.ts
index a8a31298f..181a6f678 100644
--- a/docs/app/sitemap.ts
+++ b/docs/app/sitemap.ts
@@ -1,6 +1,6 @@
import { BASE_URL, blog, source } from "@/lib/source";
-const STATIC_PATHS = ["/", "/playground", "/compare", "/chat", "/blog"];
+const STATIC_PATHS = ["/", "/demos", "/compare", "/lab", "/chat", "/blog"];
export default async function sitemap() {
const staticRoutes = STATIC_PATHS.map((path) => ({
diff --git a/docs/components/docs-route-layout.tsx b/docs/components/docs-route-layout.tsx
index 008d6912a..ae0fc28b4 100644
--- a/docs/components/docs-route-layout.tsx
+++ b/docs/components/docs-route-layout.tsx
@@ -50,7 +50,7 @@ export function DocsRouteLayout({ tree, children }: DocsRouteLayoutProps) {
collapsible: false,
banner: (
<div className="flex flex-col mb-2">
- <SidebarBannerLink href="/playground" label="Playground" external icon={<Play />} />
+ <SidebarBannerLink href="/demos" label="Demos" external icon={<Play />} />
<SidebarBannerLink
href={siteConfig.discordUrl}
label="Discord"
diff --git a/docs/components/site-primary-nav.module.css b/docs/components/site-primary-nav.module.css
index 9631e5df9..323383360 100644
--- a/docs/components/site-primary-nav.module.css
+++ b/docs/components/site-primary-nav.module.css
@@ -1,4 +1,6 @@
.nav {
+ /* Positioning context for the shared dropdown viewport. */
+ position: relative;
display: none;
align-items: center;
gap: 0.5rem;
@@ -64,88 +66,194 @@
color: inherit;
}
-.dropdownPanel {
+/* The single shared panel. Its width/height/offset are set inline from the
+ measured content, so moving between menus morphs this one box rather than
+ swapping two. `left: 0` + `translate` keeps the animated offset independent
+ of the -50% centring a `transform` shorthand would otherwise fight over. */
+.viewport {
position: absolute;
top: calc(100% + 0.5rem);
- left: 50%;
+ left: 0;
z-index: 60;
- display: flex;
- flex-direction: column;
- gap: 0.5rem;
- min-width: 24rem;
- padding: 0.625rem;
+ overflow: hidden;
border: 1px solid var(--openui-border-default);
- border-radius: 14px;
+ border-radius: 20px;
background: var(--openui-foreground);
- box-shadow: var(--openui-shadow-l);
+ /* A wide, soft cast so the panel reads as floating clear of the page rather
+ than pinned to it — shadow-l is only an 8px blur and disappears against
+ the hero. One step down from 2xl: still clearly separates the panel from
+ the page, without the heavier cast reading as too much. */
+ box-shadow: var(--openui-shadow-xl);
opacity: 0;
pointer-events: none;
- transform: translate(-50%, -4px);
transition:
opacity 0.18s ease,
- transform 0.18s ease;
+ visibility 0s linear 0.18s;
+ visibility: hidden;
}
-.dropdown:hover .dropdownPanel,
-.dropdown:focus-within .dropdownPanel {
+/* Bridges the 0.5rem gap between the trigger row and the panel so the pointer
+ can travel down into the menu without leaving the nav and closing it. */
+.viewport::before {
+ content: "";
+ position: absolute;
+ top: -0.5rem;
+ right: 0;
+ left: 0;
+ height: 0.5rem;
+}
+
+.viewport[data-open="true"] {
opacity: 1;
pointer-events: auto;
- transform: translate(-50%, 0);
+ transition:
+ opacity 0.18s ease,
+ visibility 0s,
+ width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
+ height 0.32s cubic-bezier(0.22, 1, 0.36, 1),
+ translate 0.32s cubic-bezier(0.22, 1, 0.36, 1);
+ visibility: visible;
+}
+
+/* Size/offset only animate once the box is already on screen — opening from
+ closed snaps straight to the right dimensions. */
+.viewport:not(.viewportMorph) {
+ transition:
+ opacity 0.18s ease,
+ visibility 0s;
+}
+
+/* Pinned to the left edge, not centred. The viewport is sized to exactly the
+ active menu's width, so left:0 lines them up — whereas centring re-resolves
+ the offset on every frame of the width animation, which makes the labels
+ visibly slide while the box morphs. The outgoing menu is wider and simply
+ gets clipped on the right as it fades. */
+/* Width is written inline by the nav: the natural size at full width, or the
+ viewport minus a margin once that no longer fits. Columns then share whatever
+ that width is, so the cards shrink together rather than the panel clipping.
+ Each card carries 6px of its own padding so its hover fill can bleed 6px past
+ the artwork without any layout shift; the panel's padding and gap are reduced
+ by that same 6px per edge, so the rendered spacing is 20px from the panel edge
+ to the artwork and 20px between artwork edges, whatever the bleed is:
+ track 284 + 6*2 = 296 panel 14*2 + 296*4 + 8*3 = 1236
+ Only the artwork scales — it holds its aspect ratio — while the label and
+ description keep their size and re-wrap into the narrower column. */
+.viewportContent {
+ position: absolute;
+ top: 0;
+ left: 0;
+ display: grid;
+ grid-auto-flow: column;
+ grid-auto-columns: minmax(0, 1fr);
+ gap: 8px;
+ padding: 14px;
+ opacity: 0;
+ transition: opacity 0.16s ease;
}
-/* While the dropdown is open, keep its trigger tab in the hover state — even
- once the pointer moves down into the panel. */
-.dropdown:hover .dropdownTrigger,
-.dropdown:focus-within .dropdownTrigger {
+.viewportContent[data-active="true"] {
+ opacity: 1;
+}
+
+/* While a dropdown is open, keep its trigger tab in the hover state — even once
+ the pointer moves down into the panel. */
+.dropdownTriggerOpen,
+.dropdown:hover .dropdownTrigger {
background: var(--openui-highlight-strong);
}
.dropdownItem {
+ /* Design spec is 3% black; the token set only steps 2/4/8%, so it's declared
+ here. Dark mode needs a light overlay — 3% black is invisible on a dark
+ surface — so it flips to a white wash of equivalent weight. */
+ --nav-card-hover: rgb(0 0 0 / 0.03);
+
position: relative;
display: flex;
- padding: 1rem;
- border-radius: 9px;
+ flex-direction: column;
+ /* Bleeds the hover fill 6px past the artwork. Compensated for in the panel's
+ padding/gap below, so this adds no visible spacing. */
+ padding: 6px;
+ /* Concentric with the 12px artwork radius inside it (12 + 6px padding). */
+ border-radius: 18px;
color: var(--openui-text-neutral-primary);
text-decoration: none;
transition: background-color 0.15s ease;
}
+[data-theme="dark"] .dropdownItem {
+ --nav-card-hover: rgb(255 255 255 / 0.04);
+}
+
.dropdownItem:hover {
- background: var(--openui-highlight);
+ background: var(--nav-card-hover);
+}
+
+/* 284x160 preview slot. The art is decorative, so it sits behind the label and
+ is cropped to fill rather than letterboxed. */
+/* Renders the artwork exactly as exported — no border, no background, no
+ radius of its own. The art carries its own surface fill, 1px stroke and 12px
+ corners, so anything added here double-draws the edge or shows through as a
+ plate behind it. Drop-in replacements need no CSS changes. */
+.dropdownPreview {
+ position: relative;
+ display: block;
+ aspect-ratio: 284 / 160;
+}
+
+/* The art is authored at the slot's exact 284:160 ratio, so it is drawn whole
+ rather than cropped — object-fit: cover would silently trim a mismatched
+ export instead of making the mismatch obvious. */
+.dropdownPreviewImage {
+ display: block;
+ width: 100%;
+ height: 100%;
+ object-fit: fill;
+}
+
+/* Per-theme artwork: render both variants, reveal the one matching the theme. */
+.dropdownPreviewDark {
+ display: none;
+}
+
+[data-theme="dark"] .dropdownPreviewLight {
+ display: none;
+}
+
+[data-theme="dark"] .dropdownPreviewDark {
+ display: block;
}
.dropdownText {
display: flex;
min-width: 0;
flex-direction: column;
- gap: 0.25rem;
+ gap: 0.375rem;
+ padding: 0.625rem 0.5rem 0.5rem;
}
.dropdownTitleRow {
display: flex;
align-items: center;
+ justify-content: space-between;
gap: 0.5rem;
}
.dropdownTitle {
font-family: "Inter Display", sans-serif;
- font-size: 1.25rem;
+ font-size: 1rem;
font-weight: 500;
- line-height: 1.15;
+ line-height: 1.5;
color: var(--openui-text-neutral-primary);
}
-/* Arrow-in-circle revealed next to the title on hover (mirrors the menu reference). */
+/* Plain arrow pinned to the end of the title row, revealed on hover. */
.dropdownArrow {
display: inline-flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
- width: 1.25rem;
- height: 1.25rem;
- border-radius: 9999px;
- background: var(--openui-inverted-background);
- color: var(--openui-background);
+ color: var(--openui-text-neutral-primary);
opacity: 0;
transform: translateX(-0.25rem);
transition:
@@ -161,11 +269,27 @@
.dropdownDescription {
font-family: "Inter", sans-serif;
font-size: 14px;
- line-height: 1.3;
+ line-height: 1.57;
color: var(--openui-text-neutral-secondary);
opacity: 0.8;
}
+@media (prefers-reduced-motion: reduce) {
+ .dropdownItem,
+ .dropdownArrow,
+ .viewportContent {
+ transition: none;
+ }
+
+ /* Keep the open/close fade, drop the morph. */
+ .viewport,
+ .viewport[data-open="true"] {
+ transition:
+ opacity 0.18s ease,
+ visibility 0s;
+ }
+}
+
@media (min-width: 1024px) {
.nav {
display: flex;
diff --git a/docs/components/site-primary-nav.tsx b/docs/components/site-primary-nav.tsx
index 0dbe18b03..afed37d45 100644
--- a/docs/components/site-primary-nav.tsx
+++ b/docs/components/site-primary-nav.tsx
@@ -3,6 +3,7 @@
import { ArrowRight } from "@phosphor-icons/react";
import Link from "next/link";
import { usePathname } from "next/navigation";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
import styles from "./site-primary-nav.module.css";
type NavLeaf = {
@@ -17,6 +18,10 @@ type NavDropdownChild = {
href: string;
description?: string;
newTab?: boolean;
+ /* Preview art shown above the label in the desktop mega-menu, exported at 2x
+ from the menu design's own frames. Decorative — the adjacent title already
+ names the destination. */
+ preview?: { light: string; dark: string };
};
type NavDropdown = {
@@ -29,42 +34,67 @@ export type NavItem = NavLeaf | NavDropdown;
export const PRIMARY_SITE_NAV_ITEMS: NavItem[] = [
{ title: "Docs", href: "/docs", newTab: false },
{
- title: "Playground",
+ // Order and titles follow the menu design (Figma node 756:545).
+ title: "Demos",
children: [
{
- title: "OpenUI Playground",
- description: "Compare OpenUI Lang with raw code and JSON.",
- href: "/playground",
+ title: "Compare",
+ description: "See how AI apps look with and without OpenUI.",
+ href: "/compare",
+ preview: {
+ light: "/nav/compare-light.webp",
+ dark: "/nav/compare-dark.webp",
+ },
},
{
- title: "OpenUI Chat",
- description: "Try OpenUI OSS and Cloud in a live chat.",
- href: "/chat",
+ title: "Dashboard example",
+ description: "A demo built on GitHub data that responds with dashboard.",
+ href: "/demo/github",
+ preview: {
+ light: "/nav/dashboard-light.webp",
+ dark: "/nav/dashboard-dark.webp",
+ },
},
{
- title: "Compare OpenUI",
- description: "Compare Markdown, OpenUI OSS, and Cloud side by side.",
- href: "/compare",
+ title: "OpenUI Chat",
+ description: "A ChatGPT-like assistant powered by OpenUI that responds with UI.",
+ href: "/chat",
+ preview: {
+ light: "/nav/chat-light.webp",
+ dark: "/nav/chat-dark.webp",
+ },
},
{
- title: "Dashboard Demo",
- description: "Testdrive a dashboard building experience.",
- href: "/demo/github",
+ title: "OpenUI vs JSON",
+ description: "See how OpenUI runs 3x faster on 67% fewer tokens.",
+ href: "/demos",
+ preview: {
+ light: "/nav/vsjson-light.webp",
+ dark: "/nav/vsjson-dark.webp",
+ },
},
],
},
{
- title: "Projects",
+ title: "Lab",
children: [
{
title: "OpenClaw OS",
- description: "Workspace for your OpenClaw agents.",
+ description: "A workspace for running and managing your OpenClaw agents.",
href: "/openclaw-os",
+ preview: {
+ light: "/nav/openclaw-light.webp",
+ dark: "/nav/openclaw-dark.webp",
+ },
},
{
title: "Community projects",
- description: "Tools, packages, plugins, and examples",
- href: "/projects",
+ description: "Tools, packages, plugins, and examples built by the community.",
+ href: "/lab",
+ preview: {
+ light: "/nav/community-light.webp",
+ dark: "/nav/community-dark.webp",
+ },
},
],
},
@@ -77,53 +107,295 @@ export function isNavDropdown(item: NavItem): item is NavDropdown {
return "children" in item;
}
+/* Panel geometry, mirrored from .viewportContent in the stylesheet. Kept in
+ sync by hand because the natural width has to be known before layout. */
+const CARD_TRACK = 296;
+const PANEL_GAP = 8;
+const PANEL_PADDING = 14;
+/* Smallest gap left between the panel and either edge of the window. */
+const VIEWPORT_MARGIN = 16;
+/* Forgiveness around the nav+panel box before the menu counts as left. */
+const POINTER_SLACK = 12;
+/* How long the pointer must rest on a neighbouring nav link before an open menu
+ closes. Long enough that crossing one on the way to a card doesn't count,
+ short enough that settling on it closes right away. */
+const NEIGHBOUR_DWELL_MS = 150;
+
+function DropdownCard({ child, onNavigate }: { child: NavDropdownChild; onNavigate: () => void }) {
+ return (
+ <Link
+ className={styles.dropdownItem}
+ href={child.href}
+ role="menuitem"
+ onClick={onNavigate}
+ {...(child.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {})}
+ >
+ {child.preview && (
+ <span className={styles.dropdownPreview}>
+ {/* Both variants render; CSS reveals the one matching the theme, so
+ there's no hydration flash on first paint. */}
+ <img
+ src={child.preview.light}
+ alt=""
+ aria-hidden="true"
+ width={852}
+ height={480}
+ loading="lazy"
+ draggable={false}
+ className={`${styles.dropdownPreviewImage} ${styles.dropdownPreviewLight}`}
+ />
+ <img
+ src={child.preview.dark}
+ alt=""
+ aria-hidden="true"
+ width={852}
+ height={480}
+ loading="lazy"
+ draggable={false}
+ className={`${styles.dropdownPreviewImage} ${styles.dropdownPreviewDark}`}
+ />
+ </span>
+ )}
+ <span className={styles.dropdownText}>
+ <span className={styles.dropdownTitleRow}>
+ <span className={styles.dropdownTitle}>{child.title}</span>
+ <span className={styles.dropdownArrow} aria-hidden="true">
+ <ArrowRight size={18} />
+ </span>
+ </span>
+ {child.description && (
+ <span className={styles.dropdownDescription}>{child.description}</span>
+ )}
+ </span>
+ </Link>
+ );
+}
+
+/**
+ * The dropdowns share a single panel ("viewport") so that moving between two
+ * menus morphs one box — it slides to the new trigger and resizes to the new
+ * content — instead of cross-fading two separate panels. Every menu's content
+ * is always mounted (inert when inactive) so the box can be measured before it
+ * animates, and so the artwork isn't re-fetched on each open.
+ *
+ * The box's geometry is written straight to the DOM rather than held in state:
+ * it's derived from measurements that only exist after layout, and round-tripping
+ * it through React would cost an extra render on every hover.
+ */
export function SitePrimaryNav() {
const pathname = usePathname();
+ const dropdowns = PRIMARY_SITE_NAV_ITEMS.filter(isNavDropdown);
+
+ const [active, setActive] = useState<string | null>(null);
+
+ // Close on navigation. The link's own onClick covers the common case, but a
+ // route change can also come from elsewhere (back/forward, a nested link), and
+ // the pointer often never leaves the nav, so nothing else would close it.
+ // Adjusting state during render is React's sanctioned pattern here — an effect
+ // would paint the stale open menu for a frame first.
+ const [navigatedFrom, setNavigatedFrom] = useState(pathname);
+ if (pathname !== navigatedFrom) {
+ setNavigatedFrom(pathname);
+ setActive(null);
+ }
+
+ const navRef = useRef<HTMLElement>(null);
+ const viewportRef = useRef<HTMLDivElement>(null);
+ const triggerRefs = useRef<Record<string, HTMLButtonElement | null>>({});
+ const contentRefs = useRef<Record<string, HTMLDivElement | null>>({});
+
+ const wasOpenRef = useRef(false);
+ const watcherRef = useRef<((event: PointerEvent) => void) | null>(null);
+ const neighbourTimerRef = useRef<number | null>(null);
+
+ // Neither the watcher nor a pending close may outlive the component.
+ useEffect(
+ () => () => {
+ if (watcherRef.current) document.removeEventListener("pointermove", watcherRef.current);
+ if (neighbourTimerRef.current !== null) window.clearTimeout(neighbourTimerRef.current);
+ },
+ [],
+ );
+
+ useLayoutEffect(() => {
+ const viewport = viewportRef.current;
+ if (!viewport) return;
+
+ if (!active) {
+ viewport.classList.remove(styles.viewportMorph);
+ wasOpenRef.current = false;
+ return;
+ }
+
+ const content = contentRefs.current[active];
+ const trigger = triggerRefs.current[active];
+ const nav = navRef.current;
+ if (!content || !trigger || !nav) return;
+
+ const place = () => {
+ const navRect = nav.getBoundingClientRect();
+ const triggerRect = trigger.getBoundingClientRect();
+ const viewportWidth = document.documentElement.clientWidth;
+
+ // Natural width is arithmetic, not measured: measuring would need the
+ // content laid out unconstrained first, and it can't be — its columns are
+ // sized from the width set below.
+ const columns = content.children.length;
+ const natural = PANEL_PADDING * 2 + columns * CARD_TRACK + PANEL_GAP * (columns - 1);
+ const width = Math.min(natural, viewportWidth - VIEWPORT_MARGIN * 2);
+
+ // Set the width first so the cards reflow, then read the height they
+ // settled at — narrower columns wrap the descriptions onto more lines.
+ content.style.width = `${width}px`;
+ const height = content.offsetHeight;
+
+ // Centre on the trigger, then push back inside the viewport if that would
+ // hang the panel off either edge. Once the panel is as wide as the space
+ // allows, both clamps meet and it sits centred on screen.
+ const centredOnTrigger = triggerRect.left + triggerRect.width / 2 - width / 2;
+ const left = Math.min(
+ Math.max(centredOnTrigger, VIEWPORT_MARGIN),
+ viewportWidth - width - VIEWPORT_MARGIN,
+ );
+
+ viewport.style.width = `${width}px`;
+ viewport.style.height = `${height}px`;
+ viewport.style.translate = `${left - navRect.left}px 0`;
+ };
+
+ const openingFromClosed = !wasOpenRef.current;
+ // Opening from closed must not animate — the box would otherwise grow from
+ // whatever geometry the previously-open menu left behind.
+ if (openingFromClosed) viewport.classList.remove(styles.viewportMorph);
+
+ place();
+
+ // Keep it inside the viewport if the window changes while the menu is open.
+ window.addEventListener("resize", place);
+
+ if (openingFromClosed) {
+ // Flush the geometry above while transitions are still disarmed, then arm
+ // them for subsequent menu switches. Reading a layout property forces the
+ // style recalc synchronously, so this needs no rAF — which matters because
+ // rAF doesn't fire in a backgrounded tab and would leave the morph unarmed.
+ void viewport.offsetWidth;
+ viewport.classList.add(styles.viewportMorph);
+ wasOpenRef.current = true;
+ }
+
+ return () => window.removeEventListener("resize", place);
+ }, [active]);
+
+ const stopWatchingPointer = () => {
+ if (watcherRef.current) {
+ document.removeEventListener("pointermove", watcherRef.current);
+ watcherRef.current = null;
+ }
+ };
+
+ const cancelNeighbourClose = () => {
+ if (neighbourTimerRef.current !== null) {
+ window.clearTimeout(neighbourTimerRef.current);
+ neighbourTimerRef.current = null;
+ }
+ };
+
+ const close = () => {
+ stopWatchingPointer();
+ cancelNeighbourClose();
+ setActive(null);
+ };
+
+ /**
+ * Docs and Blogs flank the dropdowns, so the pointer crosses one whenever it
+ * reaches diagonally for a card at either end of an open panel. Closing on
+ * entry killed the menu mid-reach; not closing at all left it hanging while
+ * the pointer sat on a different nav item. So the close waits on dwell —
+ * crossing is over in a few frames, settling isn't.
+ */
+ const scheduleNeighbourClose = () => {
+ cancelNeighbourClose();
+ neighbourTimerRef.current = window.setTimeout(close, NEIGHBOUR_DWELL_MS);
+ };
+
+ /**
+ * The panel is far wider than the nav and hangs below it, so moving from a
+ * trigger diagonally towards a card at either end leaves the nav's box long
+ * before reaching the panel — the pointer crosses open space beside the nav
+ * that belongs to neither.
+ *
+ * So leaving the nav doesn't close anything by itself. It starts watching the
+ * pointer, and the menu closes only once the pointer is outside the box that
+ * encloses both the nav and the open panel. Every path from a trigger to any
+ * card stays inside that box, however diagonal, at whatever speed — there's no
+ * delay to outrun.
+ *
+ * (A bridge element over that space would have been simpler, but at this width
+ * it would sit on top of the header's logo and buttons and swallow their
+ * clicks.)
+ */
+ const watchPointer = () => {
+ stopWatchingPointer();
+ const onMove = (event: PointerEvent) => {
+ const nav = navRef.current;
+ const panel = viewportRef.current;
+ if (!nav || !panel) return;
+ const a = nav.getBoundingClientRect();
+ const b = panel.getBoundingClientRect();
+ const inside =
+ event.clientX >= Math.min(a.left, b.left) - POINTER_SLACK &&
+ event.clientX <= Math.max(a.right, b.right) + POINTER_SLACK &&
+ event.clientY >= Math.min(a.top, b.top) - POINTER_SLACK &&
+ event.clientY <= Math.max(a.bottom, b.bottom) + POINTER_SLACK;
+ if (!inside) close();
+ };
+ watcherRef.current = onMove;
+ document.addEventListener("pointermove", onMove);
+ };
return (
- <nav className={styles.nav}>
+ <nav
+ className={styles.nav}
+ ref={navRef}
+ onPointerLeave={watchPointer}
+ /* pointerover, not pointerenter: enter only fires crossing the nav's own
+ boundary, so coming back in over a trigger or the panel — both
+ descendants — would leave the watcher running. over bubbles from any
+ descendant, so every way back in stops it. */
+ onPointerOver={stopWatchingPointer}
+ onKeyDown={(event) => {
+ if (event.key === "Escape") close();
+ }}
+ onBlur={(event) => {
+ if (!event.currentTarget.contains(event.relatedTarget as Node | null)) close();
+ }}
+ >
{PRIMARY_SITE_NAV_ITEMS.map((item) => {
if (isNavDropdown(item)) {
const isActive = item.children.some((child) => pathname.startsWith(child.href));
+ const isOpen = active === item.title;
return (
- <div className={styles.dropdown} key={item.title}>
+ <div
+ className={styles.dropdown}
+ key={item.title}
+ onPointerEnter={() => setActive(item.title)}
+ >
<button
type="button"
className={`${styles.link} ${styles.dropdownTrigger} ${
isActive ? styles.linkActive : ""
- }`.trim()}
+ } ${isOpen ? styles.dropdownTriggerOpen : ""}`.trim()}
aria-haspopup="menu"
+ aria-expanded={isOpen}
+ ref={(node) => {
+ triggerRefs.current[item.title] = node;
+ }}
+ onFocus={() => setActive(item.title)}
+ onClick={() => setActive(isOpen ? null : item.title)}
>
{item.title}
</button>
- <div className={styles.dropdownPanel} role="menu">
- {item.children.map((child) => {
- return (
- <Link
- className={styles.dropdownItem}
- href={child.href}
- key={child.href}
- role="menuitem"
- {...(child.newTab
- ? { target: "_blank", rel: "noopener noreferrer" }
- : {})}
- >
- <span className={styles.dropdownText}>
- <span className={styles.dropdownTitleRow}>
- <span className={styles.dropdownTitle}>{child.title}</span>
- <span className={styles.dropdownArrow} aria-hidden="true">
- <ArrowRight size={14} weight="bold" />
- </span>
- </span>
- {child.description && (
- <span className={styles.dropdownDescription}>{child.description}</span>
- )}
- </span>
- </Link>
- );
- })}
- </div>
</div>
);
}
@@ -136,6 +408,8 @@ export function SitePrimaryNav() {
className={`${styles.link} ${isActive ? styles.linkActive : ""}`.trim()}
href={item.href}
key={item.href}
+ onPointerEnter={scheduleNeighbourClose}
+ onPointerLeave={cancelNeighbourClose}
{...(item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {})}
>
{item.title}
@@ -143,6 +417,28 @@ export function SitePrimaryNav() {
</Link>
);
})}
+
+ <div className={styles.viewport} data-open={active ? "true" : "false"} ref={viewportRef}>
+ {dropdowns.map((item) => (
+ <div
+ className={styles.viewportContent}
+ key={item.title}
+ data-active={active === item.title ? "true" : "false"}
+ // Inactive menus stay mounted for measurement but must not be
+ // reachable by pointer, screen reader, or tab order.
+ inert={active !== item.title}
+ ref={(node) => {
+ contentRefs.current[item.title] = node;
+ }}
+ role="menu"
+ aria-label={item.title}
+ >
+ {item.children.map((child) => (
+ <DropdownCard child={child} key={child.href} onNavigate={close} />
+ ))}
+ </div>
+ ))}
+ </div>
</nav>
);
}
diff --git a/docs/content/docs/openui-lang/index.mdx b/docs/content/docs/openui-lang/index.mdx
index 199abae8f..b40ae4573 100644
--- a/docs/content/docs/openui-lang/index.mdx
+++ b/docs/content/docs/openui-lang/index.mdx
@@ -54,4 +54,4 @@ OpenUI Lang was created to solve these core issues:
</Card>
</Cards>
-Want to try it? [Open the Playground](/playground) or follow the [Quick Start](/docs/openui-lang/quickstart).
+Want to try it? [Open the Demos](/demos) or follow the [Quick Start](/docs/openui-lang/quickstart).
diff --git a/docs/next.config.mjs b/docs/next.config.mjs
index fc309d0ec..0d9de7277 100644
--- a/docs/next.config.mjs
+++ b/docs/next.config.mjs
@@ -33,24 +33,41 @@ const config = {
},
{
source: "/docs/add-ons",
- destination: "/projects",
+ destination: "/lab",
permanent: false,
},
{
source: "/add-ons",
- destination: "/projects",
+ destination: "/lab",
permanent: false,
},
{
source: "/ecosystem",
- destination: "/projects",
+ destination: "/lab",
permanent: false,
},
{
source: "/registry",
- destination: "/projects",
+ destination: "/lab",
permanent: false,
},
+ // Nav rename: Playground -> Demos, Projects -> Lab. Keep the old
+ // paths working for external links and search results.
+ {
+ source: "/playground",
+ destination: "/demos",
+ permanent: true,
+ },
+ {
+ source: "/projects",
+ destination: "/lab",
+ permanent: true,
+ },
+ {
+ source: "/showcase",
+ destination: "/lab",
+ permanent: true,
+ },
{
source: "/blog/should-chat-be-the-new-homepage-for-saas",
destination: "/blog/beyond-the-chatbar",
diff --git a/docs/public/meta-image.png b/docs/public/meta-image.png
index 3e513db15..43ca9158a 100644
Binary files a/docs/public/meta-image.png and b/docs/public/meta-image.png differ
diff --git a/docs/public/nav/chat-dark.webp b/docs/public/nav/chat-dark.webp
new file mode 100644
index 000000000..1dcdf822b
Binary files /dev/null and b/docs/public/nav/chat-dark.webp differ
diff --git a/docs/public/nav/chat-light.webp b/docs/public/nav/chat-light.webp
new file mode 100644
index 000000000..341651485
Binary files /dev/null and b/docs/public/nav/chat-light.webp differ
diff --git a/docs/public/nav/community-dark.webp b/docs/public/nav/community-dark.webp
new file mode 100644
index 000000000..5f1145b0f
Binary files /dev/null and b/docs/public/nav/community-dark.webp differ
diff --git a/docs/public/nav/community-light.webp b/docs/public/nav/community-light.webp
new file mode 100644
index 000000000..e4f2ae89a
Binary files /dev/null and b/docs/public/nav/community-light.webp differ
diff --git a/docs/public/nav/compare-dark.webp b/docs/public/nav/compare-dark.webp
new file mode 100644
index 000000000..470adaa71
Binary files /dev/null and b/docs/public/nav/compare-dark.webp differ
diff --git a/docs/public/nav/compare-light.webp b/docs/public/nav/compare-light.webp
new file mode 100644
index 000000000..446a7cedb
Binary files /dev/null and b/docs/public/nav/compare-light.webp differ
diff --git a/docs/public/nav/dashboard-dark.webp b/docs/public/nav/dashboard-dark.webp
new file mode 100644
index 000000000..b9f85fb00
Binary files /dev/null and b/docs/public/nav/dashboard-dark.webp differ
diff --git a/docs/public/nav/dashboard-light.webp b/docs/public/nav/dashboard-light.webp
new file mode 100644
index 000000000..28a476040
Binary files /dev/null and b/docs/public/nav/dashboard-light.webp differ
diff --git a/docs/public/nav/openclaw-dark.webp b/docs/public/nav/openclaw-dark.webp
new file mode 100644
index 000000000..b6b5b24ba
Binary files /dev/null and b/docs/public/nav/openclaw-dark.webp differ
diff --git a/docs/public/nav/openclaw-light.webp b/docs/public/nav/openclaw-light.webp
new file mode 100644
index 000000000..b14b0bded
Binary files /dev/null and b/docs/public/nav/openclaw-light.webp differ
diff --git a/docs/public/nav/vsjson-dark.webp b/docs/public/nav/vsjson-dark.webp
new file mode 100644
index 000000000..bef33a442
Binary files /dev/null and b/docs/public/nav/vsjson-dark.webp differ
diff --git a/docs/public/nav/vsjson-light.webp b/docs/public/nav/vsjson-light.webp
new file mode 100644
index 000000000..ecc923086
Binary files /dev/null and b/docs/public/nav/vsjson-light.webp differ