Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(today): keep views in views and add a quill icon stack (#114019)

Adam Leith060bb60ee425
diff --git a/frontend/src/design.md b/frontend/src/design.md
index 2b4bbe8a1a54..1014bf13c43f 100644
--- a/frontend/src/design.md
+++ b/frontend/src/design.md
@@ -62,6 +62,7 @@ Compose from the listed parts only. Part names are shown without their prefix (e
- Drawer (Trigger, Content, Header, Title, Description, Footer, Close, Handle, Backdrop, Portal)
- DropdownMenu (Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, SelectAll, Label, Separator, Shortcut, Group, Sub, SubTrigger, SubContent, Portal; useDropdownMenuSelectAll)
- Empty (Header, Media, Title, Description, Content)
+- IconStack (Item)
- Field (Label, Description, Error, Group, Set, Legend, Separator, Content, Title)
- Heading
- Input
@@ -249,6 +250,7 @@ Use via Tailwind utilities (`bg-primary text-primary-foreground`, `border-border
- loading → see §3 Loading and progress
- empty → Empty, with a next action where one exists; inside pickers use ComboboxEmpty / AutocompleteEmpty
+ - icon → `IconStack` with one `IconStackItem` per product or type it covers, colored `var(--color-product-<product>-light)`; no product → leave `color` out for grey
- error:
- field or section → inline message near the failure, with retry where possible
- whole view failed to load → one page-level error with retry
diff --git a/frontend/src/layout/today/TodayProductsSidebar.tsx b/frontend/src/layout/today/TodayProductsSidebar.tsx
index 52b0b4fc8dd3..5c117abaac3e 100644
--- a/frontend/src/layout/today/TodayProductsSidebar.tsx
+++ b/frontend/src/layout/today/TodayProductsSidebar.tsx
@@ -16,8 +16,9 @@ import { FileSystemIconType, FileSystemImport } from '~/queries/schema/schema-ge
import { TodayPaneGroupLabel } from './TodayPaneGroupLabel'
import { TodayPaneRow } from './TodayPaneRow'
-import { matchesPaneQuery } from './todayPaneSearch'
+import { matchesPaneQuery, viewTypesForPaneSearch } from './todayPaneSearch'
import { TodayPaneSearchList } from './TodayPaneSearchList'
+import { TodayProductsViewsHint } from './TodayProductsViewsHint'
import { todayToolsLogic } from './todayToolsLogic'
/** The Products sub-nav: recently viewed tools, every saved object type, then the tools by category. */
@@ -35,12 +36,14 @@ export function TodayProductsSidebar(): JSX.Element {
[type.pluralLabel, ...libraryRowProductLabels(type.value)].some((label) => matchesPaneQuery(label, search))
)
const showLibrary = showAllObjects || libraryTypes.length > 0
+ const searchedViewTypes = viewTypesForPaneSearch(search)
const recentSection = recentTools.length ? { key: 'recent', label: 'Recently viewed', tools: recentTools } : null
const categorySections = toolGroups.map((group) => ({
key: group.category,
label: group.category,
tools: group.tools,
}))
+ const hasProducts = !!recentSection || showLibrary || categorySections.length > 0
// A tool can show in Recently viewed and in its own group, so the group keeps the two rows apart on the keyboard path.
const optionValue = (groupKey: string, tool: FileSystemImport): string => `${groupKey}:${tool.href ?? ''}`
@@ -72,49 +75,46 @@ export function TodayProductsSidebar(): JSX.Element {
searchLabel="Search products"
dataAttr="today-products-search"
>
- {!recentSection && !showLibrary && !categorySections.length ? (
+ {!hasProducts && !searchedViewTypes.length && (
<Text size="xs" variant="muted" className="block px-2 py-1">
No products match that search.
</Text>
- ) : (
- <>
- {recentSection && renderToolSection(recentSection, true)}
- {showLibrary && (
- <div>
- <TodayPaneGroupLabel first={!recentSection}>Library</TodayPaneGroupLabel>
- {showAllObjects && (
- <TodayPaneRow
- value="library:all"
- label="All objects"
- icon={<IconFolder />}
- to={urls.library()}
- active={path === urls.library()}
- dataAttr="today-library-all"
- />
- )}
- {libraryTypes.map((type) => (
- <TodayPaneRow
- key={type.value}
- value={`library:${type.value}`}
- label={type.pluralLabel}
- icon={iconForType(type.value as FileSystemIconType)}
- to={libraryListHref(type.value) ?? urls.library(type.value)}
- // A product page can share a scene with a Library list. The product's own row then takes the highlight.
- active={
- path === urls.library(type.value) ||
- (objectPageType === type.value && !activeHref)
- }
- action={<LibraryCreateButton objectType={type.value} />}
- dataAttr="today-library-type"
- />
- ))}
- </div>
- )}
- {categorySections.map((section, index) =>
- renderToolSection(section, !recentSection && !showLibrary && index === 0)
+ )}
+ {recentSection && renderToolSection(recentSection, true)}
+ {showLibrary && (
+ <div>
+ <TodayPaneGroupLabel first={!recentSection}>Library</TodayPaneGroupLabel>
+ {showAllObjects && (
+ <TodayPaneRow
+ value="library:all"
+ label="All objects"
+ icon={<IconFolder />}
+ to={urls.library()}
+ active={path === urls.library()}
+ dataAttr="today-library-all"
+ />
)}
- </>
+ {libraryTypes.map((type) => (
+ <TodayPaneRow
+ key={type.value}
+ value={`library:${type.value}`}
+ label={type.pluralLabel}
+ icon={iconForType(type.value as FileSystemIconType)}
+ to={libraryListHref(type.value) ?? urls.library(type.value)}
+ // A product page can share a scene with a Library list. The product's own row then takes the highlight.
+ active={
+ path === urls.library(type.value) || (objectPageType === type.value && !activeHref)
+ }
+ action={<LibraryCreateButton objectType={type.value} />}
+ dataAttr="today-library-type"
+ />
+ ))}
+ </div>
+ )}
+ {categorySections.map((section, index) =>
+ renderToolSection(section, !recentSection && !showLibrary && index === 0)
)}
+ {searchedViewTypes.length > 0 && <TodayProductsViewsHint viewTypes={searchedViewTypes} />}
</TodayPaneSearchList>
</div>
)
diff --git a/frontend/src/layout/today/TodayProductsViewsHint.tsx b/frontend/src/layout/today/TodayProductsViewsHint.tsx
new file mode 100644
index 000000000000..d6ed8c93f994
--- /dev/null
+++ b/frontend/src/layout/today/TodayProductsViewsHint.tsx
@@ -0,0 +1,47 @@
+import {
+ Button,
+ Empty,
+ EmptyContent,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyTitle,
+ IconStack,
+ IconStackItem,
+} from '@posthog/quill'
+
+import { LinkPrimitive } from 'lib/lemon-ui/Link'
+import { urls } from 'scenes/urls'
+import { VIEW_TYPES, ViewTypeInfo } from 'scenes/views/viewsUtils'
+import { ViewTypeIcon } from 'scenes/views/ViewTypeIcon'
+
+/** Points a Products search for a view type to the Views pane, where those types live. */
+export function TodayProductsViewsHint({ viewTypes }: { viewTypes: ViewTypeInfo[] }): JSX.Element {
+ const title = viewTypes
+ .map((info, index) => (index === 0 ? info.pluralLabel : info.pluralLabel.toLowerCase()))
+ .join(' and ')
+ return (
+ <Empty className="mt-2 gap-3 p-4" data-attr="today-products-views-hint">
+ <EmptyHeader>
+ <IconStack>
+ {VIEW_TYPES.map((info) => (
+ <IconStackItem key={info.type} color={info.color}>
+ <ViewTypeIcon type={info.type} />
+ </IconStackItem>
+ ))}
+ </IconStack>
+ <EmptyTitle>{`${title} are in Views`}</EmptyTitle>
+ <EmptyDescription>Canvases, notebooks and dashboards live in Views.</EmptyDescription>
+ </EmptyHeader>
+ <EmptyContent>
+ <Button
+ size="sm"
+ variant="outline"
+ render={<LinkPrimitive to={urls.views()} />}
+ data-attr="today-products-views-hint-open"
+ >
+ Open Views
+ </Button>
+ </EmptyContent>
+ </Empty>
+ )
+}
diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scss
index bc9222d19838..c4a740552c05 100644
--- a/frontend/src/layout/today/TodayShell.scss
+++ b/frontend/src/layout/today/TodayShell.scss
@@ -223,6 +223,9 @@ body.has-today-phone-layout .Toastify__toast-container--bottom-right {
}
.TodayPane {
+ // The pane sits on the shell's chrome, not the app background.
+ --quill-icon-stack-ring: var(--chrome);
+
display: flex;
flex: 1 1 auto;
flex-direction: column;
diff --git a/frontend/src/layout/today/TodayViewsSidebar.tsx b/frontend/src/layout/today/TodayViewsSidebar.tsx
index a8bcda83377f..b4b67e4384ac 100644
--- a/frontend/src/layout/today/TodayViewsSidebar.tsx
+++ b/frontend/src/layout/today/TodayViewsSidebar.tsx
@@ -11,7 +11,7 @@ import { urls } from 'scenes/urls'
import { VIEW_TYPE_INFO } from 'scenes/views/viewsUtils'
import { ViewTypeIcon } from 'scenes/views/ViewTypeIcon'
-import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { ProductIconWrapper, iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import { FileSystemIconType } from '~/queries/schema/schema-general'
import { TodayPaneGroupLabel } from './TodayPaneGroupLabel'
@@ -159,7 +159,15 @@ export function TodayViewsSidebar(): JSX.Element {
key={`${item.type}-${item.id}`}
value={`view:${item.type}-${item.id}`}
label={item.name}
- icon={building ? <Spinner /> : <ViewTypeIcon type={item.type} />}
+ icon={
+ building ? (
+ <Spinner />
+ ) : (
+ <ProductIconWrapper colorOverride={[VIEW_TYPE_INFO[item.type].color]}>
+ <ViewTypeIcon type={item.type} />
+ </ProductIconWrapper>
+ )
+ }
meta={building ? 'Building' : shortTimeAgo(item.timestamp)}
to={item.href}
active={path === removeProjectIdIfPresent(item.href)}
diff --git a/frontend/src/layout/today/todayPaneSearch.test.ts b/frontend/src/layout/today/todayPaneSearch.test.ts
new file mode 100644
index 000000000000..d2c1548a63ba
--- /dev/null
+++ b/frontend/src/layout/today/todayPaneSearch.test.ts
@@ -0,0 +1,14 @@
+import { viewTypesForPaneSearch } from './todayPaneSearch'
+
+describe('todayPaneSearch', () => {
+ test.each([
+ ['dash', ['dashboard']],
+ ['My Dashboards', ['dashboard']],
+ ['notebook', ['notebook']],
+ ['canvas', ['canvas']],
+ ['da', []],
+ ['feature flags', []],
+ ])('points a Products search for %s to these view types: %j', (search, types) => {
+ expect(viewTypesForPaneSearch(search).map((info) => info.type)).toEqual(types)
+ })
+})
diff --git a/frontend/src/layout/today/todayPaneSearch.ts b/frontend/src/layout/today/todayPaneSearch.ts
index 5b535ca86c14..1f2b839bec34 100644
--- a/frontend/src/layout/today/todayPaneSearch.ts
+++ b/frontend/src/layout/today/todayPaneSearch.ts
@@ -1,4 +1,20 @@
+import { VIEW_TYPES, ViewTypeInfo } from 'scenes/views/viewsUtils'
+
export function matchesPaneQuery(label: string, query: string): boolean {
const needle = query.trim().toLowerCase()
return needle === '' || label.toLowerCase().includes(needle)
}
+
+// A shorter search, like "da", matches too many words to mean a view type.
+const VIEW_TYPE_SEARCH_MIN_LENGTH = 3
+
+export function viewTypesForPaneSearch(search: string): ViewTypeInfo[] {
+ const query = search.trim().toLowerCase()
+ if (query.length < VIEW_TYPE_SEARCH_MIN_LENGTH) {
+ return []
+ }
+ // The second check catches a search that wraps the type name, like "my dashboards".
+ return VIEW_TYPES.filter(
+ (info) => matchesPaneQuery(info.pluralLabel, query) || query.includes(info.label.toLowerCase())
+ )
+}
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
index 323e874d1dc4..609768db60df 100644
--- a/frontend/src/layout/today/todayShellLogic.test.ts
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -38,8 +38,8 @@ describe('todayShellLogic', () => {
['/project/1/canvases/new', 'views'],
['/project/1/notebooks/abc', 'views'],
['/project/1/dashboard/12', 'views'],
- ['/project/1/notebooks', 'products'],
- ['/project/1/dashboard', 'products'],
+ ['/project/1/notebooks', 'views'],
+ ['/project/1/dashboard', 'views'],
['/project/1/persons', 'products'],
['/project/1/activity/events', 'products'],
['/project/1/airplane', null],
@@ -59,8 +59,8 @@ describe('todayShellLogic', () => {
})
test.each([
- ['Notebooks', true],
- ['Dashboards', true],
+ ['Notebooks', false],
+ ['Dashboards', false],
['Session replay', true],
['Persons', true],
['Activity', true],
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
index e03655a8bd2b..746c54e20429 100644
--- a/frontend/src/layout/today/todayShellLogic.ts
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -78,12 +78,11 @@ export function railPaneForPath(pathname: string): TodayRailPane | null {
if (isUnder(path, '/ai') || isUnder(path, '/spaces')) {
return 'spaces'
}
- // Each notebook and dashboard is a view, but their list pages are rows in the Products list.
if (
isUnder(path, urls.views()) ||
isUnder(path, '/canvases') ||
- path.startsWith(`${urls.notebooks()}/`) ||
- path.startsWith(`${urls.dashboards()}/`)
+ isUnder(path, urls.notebooks()) ||
+ isUnder(path, urls.dashboards())
) {
return 'views'
}
diff --git a/frontend/src/scenes/project-homepage/today/Today.scss b/frontend/src/scenes/project-homepage/today/Today.scss
index 00b573cb68f0..66b2b1593580 100644
--- a/frontend/src/scenes/project-homepage/today/Today.scss
+++ b/frontend/src/scenes/project-homepage/today/Today.scss
@@ -239,54 +239,10 @@
}
.TodayChipStack {
- position: relative;
- display: inline-block;
- width: 130px;
- height: 26px;
+ --quill-icon-stack-ring: var(--today-paper);
+
margin-left: 10px;
vertical-align: -8px;
- isolation: isolate;
-}
-
-.TodayChipStack__chip {
- --index: 0;
- --report-color: #5c5c57;
-
- position: absolute;
- top: 0;
- left: 0;
- z-index: calc(6 - var(--index));
- display: flex;
- align-items: center;
- justify-content: center;
- width: 26px;
- height: 26px;
- color: #fff;
- background: var(--report-color);
- border: 3px solid var(--today-paper);
- border-radius: 8px;
- box-shadow: 0 1px 2px #00000024;
- transition: transform 0.18s;
- transform: translateX(calc(var(--index) * 16px)) rotate(var(--tilt));
-
- svg {
- width: 13px;
- height: 13px;
- }
-
- .TodayChipStack:hover & {
- transform: translateX(calc(var(--index) * 23px)) rotate(0);
- }
-
- .TodayChipStack:hover &:hover {
- z-index: 20;
- transform: translateX(calc(var(--index) * 23px)) translateY(-4px) rotate(-6deg) scale(1.08);
- }
-
- &[data-active='true'] {
- z-index: 20;
- transform: translateX(calc(var(--index) * 16px)) translateY(-4px) rotate(-8deg) scale(1.08);
- }
}
// A link inside running text. A container sets `--today-link` to change its resting colour.
diff --git a/frontend/src/scenes/project-homepage/today/TodayChipStack.tsx b/frontend/src/scenes/project-homepage/today/TodayChipStack.tsx
index c64c916bb2c2..64e0db258bf9 100644
--- a/frontend/src/scenes/project-homepage/today/TodayChipStack.tsx
+++ b/frontend/src/scenes/project-homepage/today/TodayChipStack.tsx
@@ -1,3 +1,5 @@
+import { IconStack, IconStackItem } from '@posthog/quill'
+
export interface TodayChip {
key: string
/** Read out for the chip, which shows only an icon. */
@@ -6,8 +8,8 @@ export interface TodayChip {
icon: JSX.Element
/** Lifted, because the matching item is hovered elsewhere on the page. */
active?: boolean
- onClick?: () => void
- onHoverChange?: (hovered: boolean) => void
+ onClick: () => void
+ onHoverChange: (hovered: boolean) => void
}
interface TodayChipStackProps {
@@ -20,30 +22,26 @@ export function TodayChipStack({ chips, dataAttr }: TodayChipStackProps): JSX.El
return null
}
return (
- <span className="TodayChipStack">
- {chips.map((chip, index) => (
- <button
+ <IconStack className="TodayChipStack">
+ {chips.map((chip) => (
+ <IconStackItem
key={chip.key}
- type="button"
- className="TodayChipStack__chip"
- aria-label={`Open ${chip.label}`}
- data-active={chip.active ?? false}
- data-attr={dataAttr}
- // eslint-disable-next-line react/forbid-dom-props
- style={
- {
- '--index': index,
- '--tilt': index % 2 === 0 ? '-3deg' : '3deg',
- '--report-color': chip.color,
- } as React.CSSProperties
+ color={chip.color}
+ active={chip.active}
+ render={
+ <button
+ type="button"
+ aria-label={`Open ${chip.label}`}
+ data-attr={dataAttr}
+ onClick={chip.onClick}
+ onMouseEnter={() => chip.onHoverChange(true)}
+ onMouseLeave={() => chip.onHoverChange(false)}
+ />
}
- onClick={chip.onClick}
- onMouseEnter={() => chip.onHoverChange?.(true)}
- onMouseLeave={() => chip.onHoverChange?.(false)}
>
{chip.icon}
- </button>
+ </IconStackItem>
))}
- </span>
+ </IconStack>
)
}
diff --git a/frontend/src/scenes/tools/toolsUtils.ts b/frontend/src/scenes/tools/toolsUtils.ts
index b603cacc7628..169e43777fe1 100644
--- a/frontend/src/scenes/tools/toolsUtils.ts
+++ b/frontend/src/scenes/tools/toolsUtils.ts
@@ -1,4 +1,4 @@
-import { libraryRowOpensProduct, productObjectType } from 'scenes/library/libraryUtils'
+import { VIEW_FILE_SYSTEM_TYPES, libraryRowOpensProduct, productObjectType } from 'scenes/library/libraryUtils'
import { urls } from 'scenes/urls'
import { getDefaultTreePersons } from '~/layout/panel-layout/ProjectTree/defaultTree'
@@ -44,8 +44,9 @@ export function toolMatchesSearch(tool: FileSystemImport, search: string): boole
return !query || `${toolLabel(tool)} ${toolCategory(tool)}`.toLowerCase().includes(query)
}
+/** Whether a page gets its own row in the Products list. Library rows and the Views pane open the other pages. */
export function isToolItem(item: FileSystemImport): boolean {
- return !!item.href && !libraryRowOpensProduct(item)
+ return !!item.href && !libraryRowOpensProduct(item) && !VIEW_FILE_SYSTEM_TYPES.has(productObjectType(item))
}
let productLabelsByLibraryType: Map<string, string[]> | null = null
diff --git a/frontend/src/scenes/views/viewsUtils.ts b/frontend/src/scenes/views/viewsUtils.ts
index 71e69cffe0f6..2dd4a8c90962 100644
--- a/frontend/src/scenes/views/viewsUtils.ts
+++ b/frontend/src/scenes/views/viewsUtils.ts
@@ -14,6 +14,7 @@ export interface ViewTypeInfo {
pluralLabel: string
/** One line for the "New" menu. */
description: string
+ color: string
}
export const VIEW_TYPES: ViewTypeInfo[] = [
@@ -22,18 +23,22 @@ export const VIEW_TYPES: ViewTypeInfo[] = [
label: 'Canvas',
pluralLabel: 'Canvases',
description: 'A freeform page that AI builds from your prompt',
+ // Canvases have no product color of their own, so they take product analytics'.
+ color: 'var(--color-product-product-analytics-light)',
},
{
type: 'notebook',
label: 'Notebook',
pluralLabel: 'Notebooks',
description: 'A doc that mixes your notes with live insights and replays',
+ color: 'var(--color-product-notebooks-light)',
},
{
type: 'dashboard',
label: 'Dashboard',
pluralLabel: 'Dashboards',
description: 'A grid of saved insights for your key metrics',
+ color: 'var(--color-product-dashboards-light)',
},
]
diff --git a/packages/quill/packages/primitives/AGENTS.md b/packages/quill/packages/primitives/AGENTS.md
index 15c8c6fcf19b..7c9c3a19f559 100644
--- a/packages/quill/packages/primitives/AGENTS.md
+++ b/packages/quill/packages/primitives/AGENTS.md
@@ -148,6 +148,7 @@ Don't hand-roll `<p className="text-xs text-muted-foreground">` when `<Text size
| Avatar | — | lg, default, sm, xs | Compose `Avatar > AvatarImage + AvatarFallback`; image errors fall back to initials/icon |
| ChatGlobe | — | — | Sweeping globe for "browsing the web"; sizes from its container. Still globe under reduced motion |
| AvatarGroup | — | default, sm, xs | Row of Avatars; `stacked` overlaps + spreads on hover (no reflow), `reverse` spreads left; `size` forwards to children |
+| IconStack | — | — | Fanned colored icon tiles (`IconStackItem`, `color` per product, grey default); spreads on hover. The Empty icon, or a trailing set of items after text |
---
@@ -633,6 +634,23 @@ The arrow inherits the popup's border and background, so restyling the popover c
</Tooltip>
```
+For a row of icon buttons, share one tooltip across them so it slides from trigger to trigger instead of closing and reopening. Create a handle with `createTooltipHandle`, pass it and a `payload` to each `TooltipTrigger`, and render one `Tooltip` with the same handle that reads the payload:
+
+```tsx
+const [tooltip] = React.useState(() => createTooltipHandle<string>())
+
+<TooltipProvider>
+ {items.map((item) => (
+ <TooltipTrigger key={item.key} handle={tooltip} payload={item.label} render={<Button size="icon" aria-label={item.label} />}>
+ {item.icon}
+ </TooltipTrigger>
+ ))}
+ <Tooltip handle={tooltip}>{({ payload }) => <TooltipContent>{payload}</TooltipContent>}</Tooltip>
+</TooltipProvider>
+```
+
+On React 18, put the trigger inside a component's `render` (`<IconStackItem render={<TooltipTrigger … />} />`), not the other way round, because the trigger needs a ref that a plain function component drops.
+
### Radio Group
```tsx
@@ -697,6 +715,30 @@ Vertical: `<ButtonGroup orientation="vertical">`
</Empty>
```
+For the icon, prefer `IconStack` with one `IconStackItem` per product or type the empty state is about, over `EmptyMedia variant="icon"`.
+A stack of one tile is fine. Inside an Empty the stack centers its hover spread.
+Give each tile its product's color through `color` (in the web app, `var(--color-product-<product>-light)`).
+Leave `color` out when the empty state belongs to no product; the tile stays grey.
+When the stack sits on a surface other than the app background, set `--quill-icon-stack-ring` to that surface so the tile rings match it.
+
+```tsx
+<EmptyHeader>
+ <IconStack>
+ <IconStackItem color="var(--color-product-notebooks-light)">
+ <IconNotebook />
+ </IconStackItem>
+ <IconStackItem color="var(--color-product-dashboards-light)">
+ <IconDashboard />
+ </IconStackItem>
+ </IconStack>
+ <EmptyTitle>No views yet</EmptyTitle>
+</EmptyHeader>
+```
+
+Outside an Empty, the same stack can trail a line of text for the items the line is about.
+Tiles are decorative by default; `render={<button aria-label="…" />}` makes one clickable, and `active` lifts it while its item is hovered elsewhere.
+For tooltips on the tiles, use one shared tooltip (see Tooltip) so it slides between them: `render={<TooltipTrigger handle={tooltip} payload={label} render={<button aria-label={label} />} />}`.
+
### Item List
```tsx
diff --git a/packages/quill/packages/primitives/src/empty.css b/packages/quill/packages/primitives/src/empty.css
index 92fe7869c7b7..8128b58c3355 100644
--- a/packages/quill/packages/primitives/src/empty.css
+++ b/packages/quill/packages/primitives/src/empty.css
@@ -61,4 +61,13 @@
width: 1rem;
height: 1rem;
}
+
+ /* An IconStack in the media slot spreads evenly to both sides, so it stays centered. */
+ .quill-empty .quill-icon-stack {
+ --icon-stack-shift: calc(
+ (var(--icon-stack-count) - 1) * (var(--icon-stack-spread) - var(--icon-stack-step)) / -2
+ );
+
+ margin-bottom: 0.5rem;
+ }
}
diff --git a/packages/quill/packages/primitives/src/icon-stack.css b/packages/quill/packages/primitives/src/icon-stack.css
new file mode 100644
index 000000000000..3080a48ad714
--- /dev/null
+++ b/packages/quill/packages/primitives/src/icon-stack.css
@@ -0,0 +1,96 @@
+@layer components {
+ /* Tiles overlap and tilt alternately, then spread flat on hover. Only `transform`
+ moves, so the stack's box never reflows and nothing beside it shifts. */
+ .quill-icon-stack {
+ --icon-stack-size: 1.625rem;
+ --icon-stack-step: 1rem;
+ --icon-stack-spread: 1.4375rem;
+
+ /* The spread anchors the left edge. A container that centers the stack overrides the shift. */
+ --icon-stack-shift: 0px;
+
+ position: relative;
+ display: inline-block;
+ flex-shrink: 0;
+ width: calc(var(--icon-stack-size) + (var(--icon-stack-count) - 1) * var(--icon-stack-step));
+ height: var(--icon-stack-size);
+ isolation: isolate;
+ }
+
+ .quill-icon-stack__slot {
+ --icon-stack-x: calc(var(--icon-stack-index) * var(--icon-stack-step));
+ --icon-stack-tilt: -3deg;
+
+ position: absolute;
+ top: 0;
+ left: 0;
+
+ /* Leftmost on top. */
+ z-index: calc(var(--icon-stack-count) - var(--icon-stack-index));
+ display: flex;
+ transition: transform 180ms cubic-bezier(0.645, 0.045, 0.355, 1);
+ transform: translateX(var(--icon-stack-x)) rotate(var(--icon-stack-tilt));
+ }
+
+ .quill-icon-stack__slot:nth-child(even) {
+ --icon-stack-tilt: 3deg;
+ }
+
+ /* Only the tile lifts. Its slot holds still, so the hover stays at the tile's resting edge. */
+ .quill-icon-stack__slot:is(:has(> [data-active]), :hover:has(> :is(a, button))) {
+ z-index: 20;
+ }
+
+ .quill-icon-stack__slot:is(:has(> [data-active]), :hover:has(> :is(a, button))) > .quill-icon-stack__item {
+ transform: translateY(-4px) rotate(calc(-6deg - var(--icon-stack-tilt))) scale(1.08);
+ }
+
+ /* The ring defaults to the app background. Set `--quill-icon-stack-ring` when the stack
+ sits on another surface (a sidebar, a card) so the ring matches it. */
+ .quill-icon-stack__item {
+ box-sizing: border-box;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: var(--icon-stack-size);
+ height: var(--icon-stack-size);
+ padding: 0;
+ color: var(--background);
+ background: var(--muted-foreground);
+ border: 3px solid var(--quill-icon-stack-ring, var(--background));
+ border-radius: 0.5rem;
+ box-shadow: 0 1px 2px color-mix(in oklab, var(--foreground) 14%, transparent);
+ transition: transform 180ms cubic-bezier(0.645, 0.045, 0.355, 1);
+ }
+
+ /* A product color is mid-tone in both themes, so its glyph stays white. */
+ .quill-icon-stack__item[data-colored] {
+ color: white;
+ background: var(--icon-stack-color);
+ }
+
+ :is(a, button).quill-icon-stack__item {
+ cursor: pointer;
+ }
+
+ .quill-icon-stack__item svg:not([class*='size-']) {
+ flex-shrink: 0;
+ width: 0.8125rem;
+ height: 0.8125rem;
+ pointer-events: none;
+ }
+
+ @media (hover: hover) and (pointer: fine) {
+ .quill-icon-stack:hover .quill-icon-stack__slot {
+ --icon-stack-x: calc(var(--icon-stack-index) * var(--icon-stack-spread) + var(--icon-stack-shift));
+ --icon-stack-tilt: 0deg;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quill-icon-stack__slot,
+ .quill-icon-stack__item {
+ transition: none;
+ }
+ }
+}
diff --git a/packages/quill/packages/primitives/src/icon-stack.stories.tsx b/packages/quill/packages/primitives/src/icon-stack.stories.tsx
new file mode 100644
index 000000000000..bd6058f3c1a4
--- /dev/null
+++ b/packages/quill/packages/primitives/src/icon-stack.stories.tsx
@@ -0,0 +1,153 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { Folder, LayoutDashboard, NotebookText, Palette } from 'lucide-react'
+import * as React from 'react'
+
+import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from './empty'
+import { IconStack, IconStackItem } from './icon-stack'
+import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, createTooltipHandle } from './tooltip'
+
+const meta: Meta<typeof IconStack> = {
+ title: 'Primitives/IconStack',
+ component: IconStack,
+ tags: ['autodocs'],
+}
+
+export default meta
+type Story = StoryObj<typeof meta>
+
+export const InEmpty: Story = {
+ render: () => {
+ return (
+ <div className="flex gap-4">
+ <Empty>
+ <EmptyHeader>
+ <IconStack>
+ <IconStackItem color="#7c3aed">
+ <Palette />
+ </IconStackItem>
+ <IconStackItem color="#ef4444">
+ <NotebookText />
+ </IconStackItem>
+ <IconStackItem color="#ff8b07">
+ <LayoutDashboard />
+ </IconStackItem>
+ </IconStack>
+ <EmptyTitle>Notebooks are in Views</EmptyTitle>
+ <EmptyDescription>One colored tile per product the empty state is about.</EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ <Empty>
+ <EmptyHeader>
+ <IconStack>
+ <IconStackItem>
+ <Folder />
+ </IconStackItem>
+ </IconStack>
+ <EmptyTitle>No files yet</EmptyTitle>
+ <EmptyDescription>No product, so the tile stays grey.</EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ </div>
+ )
+ },
+}
+
+const ITEMS = [
+ { key: 'canvas', label: 'Open the canvas', color: '#7c3aed', icon: <Palette /> },
+ { key: 'notebook', label: 'Open the notebook', color: '#ef4444', icon: <NotebookText /> },
+ { key: 'dashboard', label: 'Open the dashboard', color: '#ff8b07', icon: <LayoutDashboard /> },
+ { key: 'folder', label: 'Open the folder', icon: <Folder /> },
+]
+
+export const Interactive: Story = {
+ render: () => {
+ return (
+ <p className="text-sm">
+ Four things need you today{' '}
+ <IconStack className="ml-2 align-middle">
+ {ITEMS.map((item) => (
+ <IconStackItem
+ key={item.key}
+ color={item.color}
+ render={<button type="button" aria-label={item.label} />}
+ >
+ {item.icon}
+ </IconStackItem>
+ ))}
+ </IconStack>
+ </p>
+ )
+ },
+}
+
+function ActiveOnHoverStory(): React.ReactElement {
+ const [hoveredKey, setHoveredKey] = React.useState<string | null>(null)
+ return (
+ <div className="flex flex-col gap-4 text-sm">
+ <p>
+ Four things need you today{' '}
+ <IconStack className="ml-2 align-middle">
+ {ITEMS.map((item) => (
+ <IconStackItem
+ key={item.key}
+ color={item.color}
+ active={hoveredKey === item.key}
+ render={<button type="button" aria-label={item.label} />}
+ >
+ {item.icon}
+ </IconStackItem>
+ ))}
+ </IconStack>
+ </p>
+ <ul className="flex flex-col gap-1">
+ {ITEMS.map((item) => (
+ <li
+ key={item.key}
+ className="w-fit cursor-default rounded px-2 py-1 hover:bg-muted"
+ onMouseEnter={() => setHoveredKey(item.key)}
+ onMouseLeave={() => setHoveredKey(null)}
+ >
+ {item.label}
+ </li>
+ ))}
+ </ul>
+ </div>
+ )
+}
+
+export const ActiveOnHover: Story = {
+ render: () => <ActiveOnHoverStory />,
+}
+
+function WithTooltipsStory(): React.ReactElement {
+ const [tooltip] = React.useState(() => createTooltipHandle<string>())
+ return (
+ <TooltipProvider>
+ <p className="text-sm">
+ Four things need you today{' '}
+ <IconStack className="ml-2 align-middle">
+ {ITEMS.map((item) => (
+ <IconStackItem
+ key={item.key}
+ color={item.color}
+ render={
+ <TooltipTrigger
+ handle={tooltip}
+ payload={item.label}
+ render={<button type="button" aria-label={item.label} />}
+ />
+ }
+ >
+ {item.icon}
+ </IconStackItem>
+ ))}
+ </IconStack>
+ </p>
+ <Tooltip handle={tooltip}>{({ payload }) => <TooltipContent>{payload}</TooltipContent>}</Tooltip>
+ </TooltipProvider>
+ )
+}
+
+export const WithTooltips: Story = {
+ render: () => <WithTooltipsStory />,
+}
diff --git a/packages/quill/packages/primitives/src/icon-stack.tsx b/packages/quill/packages/primitives/src/icon-stack.tsx
new file mode 100644
index 000000000000..5480cb2a6929
--- /dev/null
+++ b/packages/quill/packages/primitives/src/icon-stack.tsx
@@ -0,0 +1,58 @@
+import { mergeProps } from '@base-ui/react/merge-props'
+import { useRender } from '@base-ui/react/use-render'
+import * as React from 'react'
+
+import './icon-stack.css'
+import { cn } from './lib/utils'
+
+function IconStack({ className, children, style, ...props }: React.ComponentProps<'span'>): React.ReactElement {
+ const items = React.Children.toArray(children)
+ return (
+ <span
+ data-quill
+ data-slot="icon-stack"
+ className={cn('quill-icon-stack', className)}
+ style={{ ...style, '--icon-stack-count': items.length } as React.CSSProperties}
+ {...props}
+ >
+ {items.map((child, index) => (
+ <span
+ key={React.isValidElement(child) ? child.key : index}
+ className="quill-icon-stack__slot"
+ style={{ '--icon-stack-index': index } as React.CSSProperties}
+ >
+ {child}
+ </span>
+ ))}
+ </span>
+ )
+}
+
+function IconStackItem({
+ className,
+ color,
+ active = false,
+ style,
+ render,
+ ...props
+}: useRender.ComponentProps<'span'> & { color?: string; active?: boolean }): React.ReactElement {
+ return useRender({
+ defaultTagName: 'span',
+ props: mergeProps<'span'>(
+ {
+ 'aria-hidden': render ? undefined : true,
+ className: cn('quill-icon-stack__item', className),
+ style: color ? ({ ...style, '--icon-stack-color': color } as React.CSSProperties) : style,
+ },
+ props
+ ),
+ render,
+ state: {
+ slot: 'icon-stack-item',
+ active,
+ colored: !!color,
+ },
+ })
+}
+
+export { IconStack, IconStackItem }
diff --git a/packages/quill/packages/primitives/src/index.ts b/packages/quill/packages/primitives/src/index.ts
index 5848cafa6fda..5b0acdc8d01f 100644
--- a/packages/quill/packages/primitives/src/index.ts
+++ b/packages/quill/packages/primitives/src/index.ts
@@ -205,6 +205,7 @@ export {
FieldTitle,
} from './field'
export { Heading, headingVariants } from './heading'
+export { IconStack, IconStackItem } from './icon-stack'
export { Input } from './input'
export {
NumberFieldRoot,
@@ -350,6 +351,6 @@ export { Text, textVariants } from './text'
export { Textarea } from './textarea'
export { Toggle, toggleVariants } from './toggle'
export { ToggleGroup, ToggleGroupItem } from './toggle-group'
-export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from './tooltip'
+export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, createTooltipHandle } from './tooltip'
export { ThemeProvider, useTheme, type Theme } from './theme-provider'
export { cn } from './lib/utils'
diff --git a/packages/quill/packages/primitives/src/tooltip.css b/packages/quill/packages/primitives/src/tooltip.css
index 325f80858dc1..5b639b853f0e 100644
--- a/packages/quill/packages/primitives/src/tooltip.css
+++ b/packages/quill/packages/primitives/src/tooltip.css
@@ -26,6 +26,13 @@
transform-origin: var(--transform-origin);
}
+ /* A shared tooltip slides to its next trigger. Base UI writes the position to these properties. */
+ .quill-tooltip__positioner[data-glide] {
+ transition-timing-function: cubic-bezier(0.645, 0.045, 0.355, 1);
+ transition-duration: 180ms;
+ transition-property: top, left, right, bottom, transform;
+ }
+
.quill-tooltip__content[data-starting-style],
.quill-tooltip__content[data-ending-style] {
opacity: 0;
@@ -61,6 +68,7 @@
}
@media (prefers-reduced-motion: reduce) {
+ .quill-tooltip__positioner[data-glide],
.quill-tooltip__content,
.quill-tooltip__content[data-starting-style],
.quill-tooltip__content[data-ending-style] {
diff --git a/packages/quill/packages/primitives/src/tooltip.tsx b/packages/quill/packages/primitives/src/tooltip.tsx
index 8b094265ce8d..3fc92574be18 100644
--- a/packages/quill/packages/primitives/src/tooltip.tsx
+++ b/packages/quill/packages/primitives/src/tooltip.tsx
@@ -8,11 +8,29 @@ function TooltipProvider({ delay = 250, ...props }: TooltipPrimitive.Provider.Pr
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delay={delay} {...props} />
}
-function Tooltip({ ...props }: TooltipPrimitive.Root.Props): React.ReactElement {
- return <TooltipPrimitive.Root data-slot="tooltip" {...props} />
+const TooltipGlideContext = React.createContext(false)
+
+const createTooltipHandle = TooltipPrimitive.createHandle
+
+function Tooltip<Payload>({ onOpenChangeComplete, ...props }: TooltipPrimitive.Root.Props<Payload>): React.ReactElement {
+ // A tooltip shared through a handle glides between its triggers. It starts once the tooltip has
+ // opened in place, so the first placement does not slide in from the corner of the page.
+ const [glide, setGlide] = React.useState(false)
+ return (
+ <TooltipGlideContext.Provider value={glide}>
+ <TooltipPrimitive.Root
+ data-slot="tooltip"
+ onOpenChangeComplete={(open) => {
+ setGlide(open && props.handle !== undefined)
+ onOpenChangeComplete?.(open)
+ }}
+ {...props}
+ />
+ </TooltipGlideContext.Provider>
+ )
}
-function TooltipTrigger({ ...props }: TooltipPrimitive.Trigger.Props): React.ReactElement {
+function TooltipTrigger<Payload>({ ...props }: TooltipPrimitive.Trigger.Props<Payload>): React.ReactElement {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
}
@@ -26,6 +44,7 @@ function TooltipContent({
...props
}: TooltipPrimitive.Popup.Props &
Pick<TooltipPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>): React.ReactElement {
+ const glide = React.useContext(TooltipGlideContext)
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Positioner
@@ -35,7 +54,8 @@ function TooltipContent({
alignOffset={alignOffset}
side={side}
sideOffset={sideOffset}
- className="isolate"
+ data-glide={glide ? '' : undefined}
+ className="quill-tooltip__positioner isolate"
>
<TooltipPrimitive.Popup
data-slot="tooltip-content"
@@ -50,4 +70,4 @@ function TooltipContent({
)
}
-export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
+export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider, createTooltipHandle }