Navigation Menu
A collection of links and menus for website navigation.
Derived from Family's sidebar links and overlay menu. The popup surface is a guess.
import { NavigationMenu } from "@replicas/ui";
export default function NavigationMenuDemo() {
return (
<NavigationMenu.Root>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Trigger>Workspace</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Link href="#" description="Recent activity across your teams">
Home
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Notifications and mentions">
Inbox
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Documents shared with you">
Files
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Trigger>Projects</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Link href="#" description="In progress · Due Dec 3">
Mobile app launch
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Planned · Q1">
Website redesign
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Popup />
</NavigationMenu.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Navigation Menu in the Family style: the measured tokens, the CSS and the structure.
Show Prompt
# Family Navigation Menu
A collection of links and menus for website navigation.
Build a Navigation Menu in this project that looks and behaves like Family's. Measured from the running Family app (app.family.co). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/navigation-menu) if it has none.
Fidelity: Derived from Family's sidebar links and overlay menu. The popup surface is a guess.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--body-color` | `#222` | `#fff` |
| `--body-color-muted` | `#17171780` | `#ffffff80` |
| `--body-bg-secondary` | `#f9fafb` | `#272727` |
| `--focus-color` | `#007aff80` | `#007aff80` |
| `--overlay-filter` | `none` | `none` |
| `--overlay-color` | `#fff` | `#fff` |
| `--overlay-background` | `#171717` | `#171717` |
| `--overlay-shadow` | `0px 2px 14px 0px #0003` | `0px 2px 14px 0px #0003` |
| `--overlay-selection-color` | `#fff` | `#fff` |
| `--overlay-selection-color-muted` | `#ffffff80` | `#ffffff80` |
| `--overlay-selection-background` | `#ffffff1a` | `#ffffff1a` |
| `--font-regular` | `"Family Inter", "Family Inter Fallback"` | `"Family Inter", "Family Inter Fallback"` |
| `--font-size-mini` | `0.8125rem` | `0.8125rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-size-regular` | `1rem` | `1rem` |
| `--font-weight-medium` | `500` | `500` |
| `--letter-spacing-small` | `-0.00563rem` | `-0.00563rem` |
| `--letter-spacing-input` | `-0.01125rem` | `-0.01125rem` |
| `--radius-menu` | `0.875rem` | `0.875rem` |
| `--radius-item` | `0.5rem` | `0.5rem` |
| `--radius-tabs` | `0.75rem` | `0.75rem` |
| `--duration-snappy-out` | `0.3s` | `0.3s` |
| `--ease-snappy-out` | `cubic-bezier(0.19, 1, 0.22, 1)` | `cubic-bezier(0.19, 1, 0.22, 1)` |
| `--ease-popover` | `ease` | `ease` |
| `--duration-popover` | `0.1s` | `0.1s` |
| `--duration-item` | `50ms` | `50ms` |
## CSS
Scoped under `[data-style="family"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="family"] {
.ui-navigation-menu {
min-width: max-content;
}
.ui-navigation-menu-list {
display: flex;
align-items: center;
gap: 0.25rem;
margin: 0;
padding: 0;
list-style: none;
}
.ui-navigation-menu-trigger {
position: relative;
isolation: isolate;
box-sizing: border-box;
display: inline-flex;
align-items: center;
gap: 0.75rem;
margin: 0;
padding: 0.75rem;
border: 0;
border-radius: var(--radius-tabs);
outline: none;
background: none;
color: var(--body-color-muted);
font-family: inherit;
font-size: var(--font-size-regular);
font-weight: var(--font-weight-medium);
line-height: 1.25rem;
letter-spacing: var(--letter-spacing-input);
white-space: nowrap;
user-select: none;
cursor: pointer;
transition: color 60ms;
&::before {
content: "";
position: absolute;
inset: 0;
z-index: -1;
border-radius: inherit;
background: var(--body-bg-secondary);
opacity: 0;
transition: opacity 60ms;
}
@media (hover: hover) {
&:hover:not([data-disabled]) {
color: var(--body-color);
&::before {
opacity: 1;
}
}
}
&[data-popup-open] {
color: var(--body-color);
&::before {
opacity: 1;
}
}
&:focus-visible {
outline: 0.125rem solid var(--focus-color);
}
&[data-disabled] {
opacity: 0.3;
}
}
.ui-navigation-menu-positioner {
box-sizing: border-box;
z-index: 2147483647;
width: var(--positioner-width);
height: var(--positioner-height);
max-width: var(--available-width);
outline: none;
transition:
top var(--duration-snappy-out) var(--ease-snappy-out),
left var(--duration-snappy-out) var(--ease-snappy-out),
width var(--duration-snappy-out) var(--ease-snappy-out),
height var(--duration-snappy-out) var(--ease-snappy-out);
&::before {
content: "";
position: absolute;
}
&[data-side="bottom"]::before {
top: calc(var(--side-offset) * -1);
right: 0;
left: 0;
height: var(--side-offset);
}
&[data-side="top"]::before {
right: 0;
bottom: calc(var(--side-offset) * -1);
left: 0;
height: var(--side-offset);
}
&[data-side="left"]::before {
top: 0;
right: calc(var(--side-offset) * -1);
bottom: 0;
width: var(--side-offset);
}
&[data-side="right"]::before {
top: 0;
bottom: 0;
left: calc(var(--side-offset) * -1);
width: var(--side-offset);
}
}
.ui-navigation-menu-popup {
box-sizing: border-box;
position: relative;
width: var(--popup-width);
height: var(--popup-height);
border-radius: var(--radius-menu);
outline: none;
background: var(--overlay-background);
box-shadow: var(--overlay-shadow);
backdrop-filter: var(--overlay-filter);
color: var(--overlay-color);
font-family: var(--font-regular);
transform-origin: var(--transform-origin);
transition:
width var(--duration-snappy-out) var(--ease-snappy-out),
height var(--duration-snappy-out) var(--ease-snappy-out);
animation: family-navigation-menu-enter-pop var(--duration-popover) var(--ease-popover) both;
&[data-ending-style] {
animation-name: family-navigation-menu-exit-pop;
}
}
.ui-navigation-menu-viewport {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
}
.ui-navigation-menu-content {
box-sizing: border-box;
display: flex;
flex-direction: column;
width: max-content;
min-width: 13.125rem;
max-width: 20rem;
padding: 0.375rem;
}
.ui-navigation-menu-link {
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
gap: 0.125rem;
padding: 0.5rem 0.5625rem;
border-radius: var(--radius-item);
outline: none;
color: inherit;
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
line-height: 1.125rem;
letter-spacing: var(--letter-spacing-small);
text-decoration: none;
cursor: pointer;
user-select: none;
transition: all var(--duration-item);
@media (hover: hover) {
&:hover {
background: var(--overlay-selection-background);
transition-duration: 0s;
}
}
&:focus-visible {
background: var(--overlay-selection-background);
}
&[data-active] {
color: var(--overlay-selection-color);
}
}
.ui-navigation-menu-title {
font-weight: inherit;
}
.ui-navigation-menu-description {
color: var(--overlay-selection-color-muted);
font-size: var(--font-size-mini);
font-weight: var(--font-weight-medium);
line-height: 1.125rem;
}
@media (prefers-reduced-motion: reduce) {
.ui-navigation-menu-popup {
animation-duration: 0s;
}
}
}
@keyframes family-navigation-menu-enter-pop {
0% {
opacity: 0;
transform: scale(0.96);
}
100% {
opacity: 1;
transform: scale(1);
}
}
@keyframes family-navigation-menu-exit-pop {
0% {
opacity: 1;
transform: scale(1);
}
100% {
opacity: 0;
transform: scale(0.96);
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { NavigationMenu as BaseNavigationMenu } from "@base-ui/react/navigation-menu";
import type { CSSProperties, ReactNode } from "react";
import { usePortalContainer } from "./portal";
const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);
function Root({ className, ...props }: Omit<BaseNavigationMenu.Root.Props, "className"> & { className?: string }) {
return <BaseNavigationMenu.Root className={join("ui-navigation-menu", className)} {...props} />;
}
function List({ className, ...props }: Omit<BaseNavigationMenu.List.Props, "className"> & { className?: string }) {
return <BaseNavigationMenu.List className={join("ui-navigation-menu-list", className)} {...props} />;
}
function Trigger({
className,
...props
}: Omit<BaseNavigationMenu.Trigger.Props, "className"> & { className?: string }) {
return <BaseNavigationMenu.Trigger className={join("ui-navigation-menu-trigger", className)} {...props} />;
}
function Content({
className,
...props
}: Omit<BaseNavigationMenu.Content.Props, "className"> & { className?: string }) {
return <BaseNavigationMenu.Content className={join("ui-navigation-menu-content", className)} {...props} />;
}
type LinkProps = Omit<BaseNavigationMenu.Link.Props, "className"> & {
className?: string;
description?: ReactNode;
};
function Link({ className, description, children, ...props }: LinkProps) {
return (
<BaseNavigationMenu.Link className={join("ui-navigation-menu-link", className)} {...props}>
<span className="ui-navigation-menu-title">{children}</span>
{description ? <span className="ui-navigation-menu-description">{description}</span> : null}
</BaseNavigationMenu.Link>
);
}
type PopupProps = Omit<BaseNavigationMenu.Popup.Props, "className"> & {
className?: string;
side?: BaseNavigationMenu.Positioner.Props["side"];
align?: BaseNavigationMenu.Positioner.Props["align"];
sideOffset?: number;
};
function Popup({ className, side = "bottom", align = "start", sideOffset = 4, ...props }: PopupProps) {
return (
<BaseNavigationMenu.Portal container={usePortalContainer()}>
<BaseNavigationMenu.Positioner
className="ui-navigation-menu-positioner"
side={side}
align={align}
sideOffset={sideOffset}
style={{ "--side-offset": `${sideOffset}px` } as CSSProperties}
>
<BaseNavigationMenu.Popup className={join("ui-navigation-menu-popup", className)} {...props}>
<BaseNavigationMenu.Viewport className="ui-navigation-menu-viewport" />
</BaseNavigationMenu.Popup>
</BaseNavigationMenu.Positioner>
</BaseNavigationMenu.Portal>
);
}
export const NavigationMenu = {
Root,
List,
Item: BaseNavigationMenu.Item,
Trigger,
Content,
Link,
Popup,
};
```
## Example
```tsx
import { NavigationMenu } from "@replicas/ui";
export default function NavigationMenuDemo() {
return (
<NavigationMenu.Root>
<NavigationMenu.List>
<NavigationMenu.Item>
<NavigationMenu.Trigger>Workspace</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Link href="#" description="Recent activity across your teams">
Home
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Notifications and mentions">
Inbox
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Documents shared with you">
Files
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
<NavigationMenu.Item>
<NavigationMenu.Trigger>Projects</NavigationMenu.Trigger>
<NavigationMenu.Content>
<NavigationMenu.Link href="#" description="In progress · Due Dec 3">
Mobile app launch
</NavigationMenu.Link>
<NavigationMenu.Link href="#" description="Planned · Q1">
Website redesign
</NavigationMenu.Link>
</NavigationMenu.Content>
</NavigationMenu.Item>
</NavigationMenu.List>
<NavigationMenu.Popup />
</NavigationMenu.Root>
);
}
```
## Foundations
The rest of the Family style, as a skill: https://replicas.raphaelsalaja.com/skills/family/SKILL.md