Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs(design-system): NavMenu component (#39188)

Danny White3068a6eabe78
diff --git a/apps/design-system/README.md b/apps/design-system/README.md
index e8db8fd5246..0dd571441fe 100644
--- a/apps/design-system/README.md
+++ b/apps/design-system/README.md
@@ -4,28 +4,46 @@ Design resources for building consistent user experiences at Supabase.
## Getting Started
-First, make a copy of _.env.local.example_ and name it _env.local_. Then run the development server as described below.
+First, make a copy of _.env.local.example_ and name it _env.local_. Then install any required packages and start the development server:
-From within this _design-system_ directory, run:
+```bash
+cd apps/design-system
+pnpm i
+pnpm dev:full
+```
+
+The `dev:full` command runs both the Next.js development server and Contentlayer concurrently, which is recommended for most development workflows.
+
+### Alternative commands
+
+You can also run the development server and content watcher separately:
```bash
+# Run only the Next.js development server
pnpm dev
+
+# Run only the content watcher (in a separate terminal shell)
+pnpm content:dev
```
-Or from the root directory run:
+Or run the development server from the root directory:
```bash
pnpm dev:design-system
```
-Open [http://localhost:3003](http://localhost:3003) with your browser to see the result.
-
-### Watching for MDX changes
+To run both the development server and content watcher from the root directory, you can use:
-If you would like to watch for changes to MDX files with hot reload, you can run the following command in a separate terminal shell:
+```bash
+# Run the development server
+pnpm dev:design-system
+# Run the content watcher (in a separate terminal shell)
+pnpm --filter=design-system content:dev
```
-pnpm content:dev
-```
-This runs Contentlayer concurrently and watches for any changes.
+Open [http://localhost:3003](http://localhost:3003) in your browser to see the result.
+
+### Watching for MDX changes
+
+The `dev:full` command automatically watches for changes to MDX files with hot reload. If you're running the `pnpm dev` separately, you'll need to run `pnpm content:dev` in a separate terminal shell to watch for content changes.
diff --git a/apps/design-system/__registry__/index.tsx b/apps/design-system/__registry__/index.tsx
index ea8252799c7..912c60fe77c 100644
--- a/apps/design-system/__registry__/index.tsx
+++ b/apps/design-system/__registry__/index.tsx
@@ -918,6 +918,39 @@ export const Index: Record<string, any> = {
subcategory: "undefined",
chunks: []
},
+ "nav-menu-demo": {
+ name: "nav-menu-demo",
+ type: "components:example",
+ registryDependencies: ["nav-menu"],
+ component: React.lazy(() => import("@/registry/default/example/nav-menu-demo")),
+ source: "",
+ files: ["registry/default/example/nav-menu-demo.tsx"],
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: []
+ },
+ "nav-menu-badges": {
+ name: "nav-menu-badges",
+ type: "components:example",
+ registryDependencies: ["nav-menu"],
+ component: React.lazy(() => import("@/registry/default/example/nav-menu-badges")),
+ source: "",
+ files: ["registry/default/example/nav-menu-badges.tsx"],
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: []
+ },
+ "nav-menu-icons": {
+ name: "nav-menu-icons",
+ type: "components:example",
+ registryDependencies: ["nav-menu"],
+ component: React.lazy(() => import("@/registry/default/example/nav-menu-icons")),
+ source: "",
+ files: ["registry/default/example/nav-menu-icons.tsx"],
+ category: "undefined",
+ subcategory: "undefined",
+ chunks: []
+ },
"popover-demo": {
name: "popover-demo",
type: "components:example",
diff --git a/apps/design-system/config/docs.ts b/apps/design-system/config/docs.ts
index cd0c0bf8e2c..c41034a9f2f 100644
--- a/apps/design-system/config/docs.ts
+++ b/apps/design-system/config/docs.ts
@@ -69,6 +69,16 @@ export const docsConfig: DocsConfig = {
},
],
},
+ {
+ title: 'UI Patterns',
+ items: [
+ {
+ title: 'Navigation',
+ href: '/docs/ui-patterns/navigation',
+ items: [],
+ },
+ ],
+ },
{
title: 'Fragment Components',
items: [
@@ -289,6 +299,11 @@ export const docsConfig: DocsConfig = {
href: '/docs/components/menubar',
items: [],
},
+ {
+ title: 'NavMenu',
+ href: '/docs/components/nav-menu',
+ items: [],
+ },
{
title: 'Navigation Menu',
href: '/docs/components/navigation-menu',
diff --git a/apps/design-system/content/docs/changelog.mdx b/apps/design-system/content/docs/changelog.mdx
index bd19ae0967b..a96a3e675f1 100644
--- a/apps/design-system/content/docs/changelog.mdx
+++ b/apps/design-system/content/docs/changelog.mdx
@@ -4,6 +4,14 @@ description: Latest updates and announcements.
toc: false
---
+## 2nd Oct 2025 - Update button styles
+
+- UI Patterns section added for higher-level guidance
+- [`Navigation`](/design-system/docs/ui-patterns/navigation) UI pattern added
+- [`NavMenu`](/design-system/docs/components/nav-menu) component added
+
+[PR](https://github.com/supabase/supabase/pull/39188)
+
## 1st Sep 2025 - Update button styles
- [`Color usage`](/design-system/docs/color-usage) page updated
diff --git a/apps/design-system/content/docs/components/nav-menu.mdx b/apps/design-system/content/docs/components/nav-menu.mdx
new file mode 100644
index 00000000000..b6ed65529b3
--- /dev/null
+++ b/apps/design-system/content/docs/components/nav-menu.mdx
@@ -0,0 +1,57 @@
+---
+title: NavMenu
+description: A horizontal list of related views within a consistent context.
+component: true
+---
+
+<Admonition type="warning" title="Consider renaming">
+ This component is titled very similarly to the [Navigation Menu](../components/navigation-menu)
+ component. Consider renaming it to something like TabMenu or
+ [UnderlineNav](https://primer.style/product/components/underline-nav/).
+</Admonition>
+
+<ComponentPreview
+ name="nav-menu-demo"
+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
+ peekCode
+ wide
+/>
+
+## Usage
+
+NavBar is exclusively used as sub-navigation within PageLayout.
+
+```tsx
+import { NavMenu, NavMenuItem } from 'ui'
+```
+
+```tsx
+<NavMenu>
+ <NavMenuItem active={true}>
+ <Link href="#">Overview</Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#">Documentation</Link>
+ </NavMenuItem>
+</NavMenu>
+```
+
+## Examples
+
+### With counter badges
+
+You may include counter badges to indicate the number of items within a tab, for example the amount of buckets in storage.
+
+<ComponentPreview
+ name="nav-menu-badges"
+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
+/>
+
+### With icons
+
+You may include icons to more clearly represent the content of each tab. Every tab should have an icon (or no icon).
+
+<ComponentPreview
+ name="nav-menu-icons"
+ className="[&_.preview>[data-orientation=vertical]]:sm:max-w-[70%]"
+/>
diff --git a/apps/design-system/content/docs/ui-patterns/navigation.mdx b/apps/design-system/content/docs/ui-patterns/navigation.mdx
new file mode 100644
index 00000000000..a0fc17e816f
--- /dev/null
+++ b/apps/design-system/content/docs/ui-patterns/navigation.mdx
@@ -0,0 +1,14 @@
+---
+title: Navigation
+description: Navigation patterns help users understand where they are and where they can go next.
+---
+
+Supabase has a necessarily complex navigation system to handle multiple products and levels of hierarchy. This page introduces those general patterns, best practices, and the components involved.
+
+## Components
+
+### NavMenu
+
+A horizontal list of related views within a consistent PageLayout context, allowing for clearer page-level organisation. Activating a NavMenu item should trigger a URL change.
+
+[NavMenu component guidelines](../components/nav-menu)
diff --git a/apps/design-system/package.json b/apps/design-system/package.json
index cd51dbaaf6b..daeefc6cec0 100644
--- a/apps/design-system/package.json
+++ b/apps/design-system/package.json
@@ -6,6 +6,7 @@
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "next dev --turbopack --port 3003",
+ "dev:full": "concurrently \"pnpm dev\" \"pnpm content:dev\"",
"build": "pnpm run content:build && pnpm run build:registry && next build --turbopack",
"build:registry": "tsx --tsconfig ./tsconfig.scripts.json ./scripts/build-registry.mts && prettier --log-level silent --write \"registry/**/*.{ts,tsx,mdx}\" --cache",
"start": "next start",
@@ -53,6 +54,7 @@
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"config": "workspace:^",
+ "concurrently": "^8.2.2",
"mdast-util-toc": "^6.1.1",
"postcss": "^8.5.3",
"rimraf": "^4.1.3",
diff --git a/apps/design-system/registry/default/example/nav-menu-badges.tsx b/apps/design-system/registry/default/example/nav-menu-badges.tsx
new file mode 100644
index 00000000000..c5a66032185
--- /dev/null
+++ b/apps/design-system/registry/default/example/nav-menu-badges.tsx
@@ -0,0 +1,25 @@
+import Link from 'next/link'
+import { Badge, NavMenu, NavMenuItem } from 'ui'
+
+export default function NavMenuWithIcons() {
+ return (
+ <NavMenu>
+ <NavMenuItem active={true}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ Buckets
+ <Badge variant="default">10</Badge>
+ </Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ Policies <Badge variant="default">2</Badge>
+ </Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ Settings
+ </Link>
+ </NavMenuItem>
+ </NavMenu>
+ )
+}
diff --git a/apps/design-system/registry/default/example/nav-menu-demo.tsx b/apps/design-system/registry/default/example/nav-menu-demo.tsx
new file mode 100644
index 00000000000..e952c3d2cd7
--- /dev/null
+++ b/apps/design-system/registry/default/example/nav-menu-demo.tsx
@@ -0,0 +1,21 @@
+import Link from 'next/link'
+import { NavMenu, NavMenuItem } from 'ui'
+
+export default function NavMenuDemo() {
+ return (
+ <NavMenu>
+ <NavMenuItem active={true}>
+ <Link href="#">Overview</Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#">Invocations</Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#">Logs</Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#">Code</Link>
+ </NavMenuItem>
+ </NavMenu>
+ )
+}
diff --git a/apps/design-system/registry/default/example/nav-menu-icons.tsx b/apps/design-system/registry/default/example/nav-menu-icons.tsx
new file mode 100644
index 00000000000..86ef4549ac4
--- /dev/null
+++ b/apps/design-system/registry/default/example/nav-menu-icons.tsx
@@ -0,0 +1,29 @@
+import Link from 'next/link'
+import { ArchiveIcon, ShieldIcon, SettingsIcon } from 'lucide-react'
+import { Badge, NavMenu, NavMenuItem } from 'ui'
+
+export default function NavMenuWithIcons() {
+ return (
+ <NavMenu>
+ <NavMenuItem active={true}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ <ArchiveIcon size={14} />
+ Buckets
+ <Badge variant="default">10</Badge>
+ </Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ <ShieldIcon size={14} />
+ Policies
+ </Link>
+ </NavMenuItem>
+ <NavMenuItem active={false}>
+ <Link href="#" className="inline-flex items-center gap-2">
+ <SettingsIcon size={14} />
+ Settings
+ </Link>
+ </NavMenuItem>
+ </NavMenu>
+ )
+}
diff --git a/apps/design-system/registry/examples.ts b/apps/design-system/registry/examples.ts
index b79b6322d44..4e389b1d238 100644
--- a/apps/design-system/registry/examples.ts
+++ b/apps/design-system/registry/examples.ts
@@ -575,6 +575,24 @@ export const examples: Registry = [
registryDependencies: ['navigation-menu'],
files: ['example/navigation-menu-responsive.tsx'],
},
+ {
+ name: 'nav-menu-demo',
+ type: 'components:example',
+ registryDependencies: ['nav-menu'],
+ files: ['example/nav-menu-demo.tsx'],
+ },
+ {
+ name: 'nav-menu-badges',
+ type: 'components:example',
+ registryDependencies: ['nav-menu'],
+ files: ['example/nav-menu-badges.tsx'],
+ },
+ {
+ name: 'nav-menu-icons',
+ type: 'components:example',
+ registryDependencies: ['nav-menu'],
+ files: ['example/nav-menu-icons.tsx'],
+ },
// {
// name: 'pagination-demo',
// type: 'components:example',
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8953bc8888b..691c7ece6bd 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -314,6 +314,9 @@ importers:
'@types/react-dom':
specifier: 'catalog:'
version: 18.3.0
+ concurrently:
+ specifier: ^8.2.2
+ version: 8.2.2
config:
specifier: workspace:^
version: link:../../packages/config
@@ -11036,6 +11039,11 @@ packages:
resolution: {integrity: sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg==}
+ resolution: {integrity: sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==}
+ engines: {node: ^14.13.0 || >=16.0.0}
+ hasBin: true
+
resolution: {integrity: sha512-H9MWcoPsYddwbOGM6difjVwVZHl63nwMEwDJG/L7VGtuaJhb12h2caPG2tVPWs7emuYix252iGfqOyrz1GczTQ==}
engines: {node: '>=18'}
@@ -18045,6 +18053,9 @@ packages:
resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==}
+ resolution: {integrity: sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==}
+
resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==}
@@ -31831,6 +31842,18 @@ snapshots:
dependencies:
source-map: 0.6.1
+ dependencies:
+ chalk: 4.1.2
+ date-fns: 2.30.0
+ lodash: 4.17.21
+ rxjs: 7.8.1
+ shell-quote: 1.8.3
+ spawn-command: 0.0.2
+ supports-color: 8.1.1
+ tree-kill: 1.2.2
+ yargs: 17.7.2
+
dependencies:
chalk: 4.1.2
@@ -40720,6 +40743,8 @@ snapshots:
+
dependencies:
spdx-expression-parse: 3.0.1