Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/toast-stack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@codeui/solid": minor
"@codeui/styles": minor
---

Toaster: a new engine with Sonner's motion replaces Kobalte's toast region behind `createToaster` and `Toaster`. Toasts stack like a deck: the newest in front, two older ones peeking behind it, smaller and without content. Hovering or focusing the stack fans the toasts out, and every timer pauses until the pointer and focus leave, or while the page is hidden. Toasts enter and leave with transitions, so a new toast pushes the stack back smoothly instead of crossing over it. `limit` now hides older toasts instead of queueing newer ones. Swipe a toast toward the region's edge to dismiss it. `expand` keeps the toasts fanned out. The toasts render newest first.

Breaking: toasts follow the page theme by default; pass `theme="inverted"` to `Toaster`, or to one toast, for the old light-on-dark card. `Toaster` no longer takes Kobalte's `swipeDirection`, `pauseOnInteraction`, `pauseOnPageIdle` or `translations`. The styled parts in `@codeui/solid/toast/parts` still wrap Kobalte and are unchanged.

Toast: the description takes the muted text colour under a title, with 2px between them, so the two read apart. The tone icon grows to 20px and lines up with the title instead of centring on the whole card. The toast gains 4px of padding on its leading side. Toasts take the floating-surface shadow, `--cui-shadow-dialog`, and the cards behind the front one fade a step toward the page, so the stack reads as separate cards on any page. Toasts are 360px wide, down from 480px, and the stack keeps that width even when an app stretches the region.
3 changes: 2 additions & 1 deletion .claude/skills/verify-codeui/features/feedback.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Tooltip shows a short label next to its trigger on hover and should also show on
- `tooltip-variants` renders primary, secondary, disabled and custom JSX content.
- `tooltip-motion` pops on hover; keyboard focus opens it with `data-motion="none"`, and the focused child (not the wrapper) carries `aria-describedby`.
- `tooltip-empty` never opens when `content` is `undefined`, `null` or `""`, on hover or focus, and the focused trigger gets no `aria-describedby`.
- `toast-rise` (Toaster) renders in the inverted theme (`data-cui-theme` opposite the page) and sits 80px above the bottom of its region's container.
- `toast-rise` (Toaster) follows the page theme (no `data-cui-theme` of its own) and sits 80px above the bottom of its region's container. `designsystem-toaster--inverted` shows `theme="inverted"`.

## How to get to it (user POV)

Expand All @@ -28,6 +28,7 @@ Preconditions:
- **Motion and description.** `drive.mjs designsystem-tooltip--tooltip-story --journey .claude/skills/verify-codeui/journeys/tooltip-motion.mjs`.
- **Empty content.** `drive.mjs designsystem-tooltip--empty-content --journey .claude/skills/verify-codeui/journeys/tooltip-empty.mjs`.
- **Toast.** `drive.mjs designsystem-toaster--with-action --journey .claude/skills/verify-codeui/journeys/toast-rise.mjs`.
- **Toast stack.** `drive.mjs designsystem-toaster--stacked --journey .claude/skills/verify-codeui/journeys/toast-stack.mjs`. Collapsed: the front toast (`data-front`) is lowest and two peek above with hidden content. Hover and Tab both fan the stack out with no overlap, and Escape closes the focused toast. The story's Add notification button adds live toasts. The harness turns transitions off, so record a video with `reducedMotion: "no-preference"` to judge motion. Stories that need every toast in full pass `expand` (Tones).
- **Dismiss.** After hover, press Escape; expect count 0.
- **Theme.** Screenshot the open tooltip in both themes (`step('hovered')`).

Expand Down
14 changes: 7 additions & 7 deletions .claude/skills/verify-codeui/journeys/toast-rise.mjs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Toaster: the toast uses the inverted theme and sits 80px from the bottom of its frame.
// Toaster: the toast follows the page theme and sits 80px from the bottom of its frame.
export default async ({ page, step, check, theme }) => {
const toast = page.getByRole("status").first();
await step("toasts shown", () => toast.waitFor());
await check("inverted theme", async () => {
await check("follows the page theme", async () => {
const value = await toast.getAttribute("data-cui-theme");
const bg = await toast.evaluate(el => getComputedStyle(el).backgroundColor);
return { pass: value === (theme === "dark" ? "light" : "dark"), value, bg };
const scheme = await toast.evaluate(el => getComputedStyle(el).colorScheme);
return { pass: value === null && scheme.includes(theme), value, scheme };
});
await check("80px from the bottom of the frame, radius 16, explicit line height", async () => {
const m = await page.evaluate(() => {
const region = document.querySelector("[data-cui=toast-region]");
const frame = region.parentElement.getBoundingClientRect();
const toasts = [...document.querySelectorAll("[role=status]")];
const last = toasts.at(-1).getBoundingClientRect();
const c = getComputedStyle(toasts.at(-1));
const front = document.querySelector("[role=status][data-front]");
const last = front.getBoundingClientRect();
const c = getComputedStyle(front);
return { gap: Math.round(frame.bottom - last.bottom), radius: c.borderRadius, fontSize: c.fontSize, lineHeight: c.lineHeight };
});
return { pass: m.gap === 80 && m.radius === "16px" && m.lineHeight !== "normal", ...m };
Expand Down
65 changes: 65 additions & 0 deletions .claude/skills/verify-codeui/journeys/toast-stack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const rects = page =>
page.$$eval('[data-cui-stack] > [data-cui="toast"]:not([data-closed])', els =>
els.map(el => {
const r = el.getBoundingClientRect();
const title = el.querySelector('[data-cui="toast-title"]');
return {
index: el.style.getPropertyValue("--cui-toast-index"),
top: Math.round(r.top),
bottom: Math.round(r.bottom),
width: Math.round(r.width),
contentOpacity: title ? getComputedStyle(title).opacity : null,
};
}),
);

export default async ({ page, step, check, focus }) => {
await page.waitForSelector('[data-cui-stack] > [data-cui="toast"][data-mounted]');
await page.mouse.move(5, 5);
await step("collapsed", async () => {});
await check("collapsed: front is lowest, two peek above", async () => {
const r = await rects(page);
const by = i => r.find(x => x.index === String(i));
const pass =
r.length === 3 &&
by(0).contentOpacity === "1" &&
by(1).contentOpacity === "0" &&
by(1).top < by(0).top &&
by(2).top < by(1).top &&
by(0).top - by(2).top < 40;
return { pass, r };
});
await step("hover fans out", async () => {
await page.locator('[data-cui="toast"][data-front]').hover();
});
await check("expanded: no overlap, all readable", async () => {
const r = (await rects(page)).sort((a, b) => a.top - b.top);
const pass = r.every(
(x, i) => x.contentOpacity === "1" && (i === 0 || r[i - 1].bottom <= x.top),
);
return { pass, r };
});
await step("pointer leaves", async () => {
await page.mouse.move(5, 5);
});
await check("collapsed again", async () => {
const r = await rects(page);
return { pass: r.filter(x => x.contentOpacity === "0").length === 2, r };
});
await step("Tab reaches a toast", async () => {
await page.keyboard.press("Tab");
await page.keyboard.press("Tab");
});
await check("focus expands the stack", async () => {
const r = await rects(page);
return { pass: r.every(x => x.contentOpacity === "1"), r, focus: await focus() };
});
await step("Escape closes the focused toast", async () => {
await page.keyboard.press("Escape");
await page.waitForTimeout(400);
});
await check("two toasts remain", async () => {
const r = await rects(page);
return { pass: r.length === 2, r };
});
};
10 changes: 3 additions & 7 deletions apps/docs/content/docs/(kit)/components/toast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ A `Toaster` has one `position`. The default is `bottom-center`. Toasts rise from

`title` and `description` take JSX or a callback. The callback receives the toast context, `{ id, dismiss }`, so the content can close its own toast. The content renders inside `Toaster`, so it reads the context of the providers around `Toaster`, such as the locale.

`icon` replaces the tone icon. `icon: null` hides it. `theme` picks the toast's theme. The default, `inverted`, renders the opposite of the theme around the `Toaster`, as CodeImage does: a light card on a dark page, and a dark card on a light page. It follows the page when the theme changes while the toast is open. `page` uses the page theme. `light` and `dark` force one.
`icon` replaces the tone icon. `icon: null` hides it. `theme` picks the toast's theme. The default, `page`, follows the theme around the `Toaster`. `inverted` renders its opposite, as CodeImage does: a light card on a dark page, and a dark card on a light page, and it flips when the page theme changes while the toast is open. `light` and `dark` force one. Set `theme` on `Toaster` to give all its toasts one theme; a toast's own `theme` overrides it.

### Action

Expand Down Expand Up @@ -103,9 +103,9 @@ Every timer of a `Toaster` pauses while the pointer is over its toasts or focus

All three do nothing when the id is not open. A `ToastId` is a number scoped to its controller. Two controllers can return the same id.

### Queue
### Stack

A `Toaster` shows three toasts at once. Set `limit` to change that. A later toast waits until a visible one closes, and its timer starts when it appears.
A `Toaster` stacks its toasts like a deck: the newest in front, two older ones peeking behind it. Hovering or focusing the stack fans the toasts out, and every timer pauses until the pointer and focus leave. Timers also pause while the page is hidden. Set `limit` to show more or fewer toasts; older ones stay open but hidden. Set `expand` to keep the toasts fanned out. Swipe a toast toward the region's edge to dismiss it, and press alt+T to move focus to the toasts.

### Two toasters on one page

Expand All @@ -121,10 +121,6 @@ Each controller has its own toasts, ids, and default duration. `clear()` on one

<PropsTable name="Toaster" />

Inherited from Kobalte's [toast region](https://kobalte.dev/docs/core/components/toast):

<PropsTable name="ToasterInherited" />

### `createToaster`

`createToaster(options)` returns a `ToastController`. Created inside a component, the controller dismisses its toasts when that component's owner is disposed.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/design/motion.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Naming the movements gives designers, developers and agents a shared vocabulary.
| **Expand** | Accordion | Height and opacity 200ms, reversible mid-way |
| **Morph** | The content after a value changes | The changed property, 150–200ms |
| **Collapse to origin** | Closing something that lives on elsewhere | Shrinks into where it can be found again, 200ms |
| **Rise** | Corner card, toast | From the edge 400ms; leaves in 200ms |
| **Rise** | Corner card, toast | From the edge 400ms; leaves in 200ms. Several toasts stack as a deck and fan out on hover or focus in 400ms |
| **Reveal** | A surface growing in place | `clip-path`, 260ms |
| **Slide** | Phone sheet, side sheet | From its edge in 260ms on the drawer curve; out in 200ms ease-out; turns around if reopened mid-exit; follows the finger when dragged |
| **Ring** | Selection ring | From `scale(0.92)` with a fade, 200ms |
Expand Down
6 changes: 4 additions & 2 deletions apps/docs/export-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@
"TooltipDefaults": "components/tooltip#defaults-for-a-whole-app",
"TooltipProvider": "components/tooltip#defaults-for-a-whole-app",
"HoverCardGroup": "components/hover-card#hovercardgroup",
"HoverCardGroupProps": "components/hover-card#hovercardgroup"
"HoverCardGroupProps": "components/hover-card#hovercardgroup",
"ToastTheme": "components/toast#toaster"
},
"@codeui/solid/accordion/parts": {
"AccordionClasses": "components/accordion#anatomy",
Expand Down Expand Up @@ -985,7 +986,8 @@
"ToasterProps": "components/toast#toaster",
"ToastId": "components/toast#createtoaster",
"ToastOptions": "components/toast#createtoaster",
"ToastPromiseOptions": "components/toast#createtoaster"
"ToastPromiseOptions": "components/toast#createtoaster",
"ToastTheme": "components/toast#toaster"
},
"@codeui/solid/checkbox": {
"Checkbox": "components/checkbox#checkbox",
Expand Down
26 changes: 10 additions & 16 deletions packages/docs-demos/src/props/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import type { CreateToasterOptions, ToasterProps, ToastOptions } from "@codeui/s
import type { RegionProps, RootProps } from "@codeui/solid/toast/parts";
import type { PropNotes } from "./notes";

/** Props that Toaster adds on top of the styled toast region. */
export type Toaster = Pick<ToasterProps, "toaster" | "closeLabel" | "position" | "class" | "classes">;

/** Kobalte toast region options that Toaster passes through. */
export type ToasterInherited = Pick<
/** The props of Toaster. */
export type Toaster = Pick<
ToasterProps,
"limit" | "hotkey" | "swipeDirection" | "pauseOnInteraction" | "pauseOnPageIdle" | "aria-label" | "translations"
"toaster" | "closeLabel" | "position" | "limit" | "expand" | "hotkey" | "theme" | "aria-label" | "class" | "classes"
>;

/** The options createToaster takes. */
Expand All @@ -30,17 +27,14 @@ export const notes = {
Toaster: {
toaster: { description: "The controller whose toasts this region shows." },
closeLabel: { description: "Accessible name of each toast's close button, in the app's language." },
position: { default: '"bottom-center"', description: "Viewport edge and alignment of the region." },
class: { description: "Class merged after the kit styles on the region." },
classes: { description: "Classes for the region and list parts. Per-toast classes go in the toast options." },
},
ToasterInherited: {
limit: { default: "3", description: "Most toasts shown at once. Later toasts wait in the queue." },
position: { default: '"bottom-center"', description: "Viewport edge and alignment of the region. Toasts swipe away toward this edge." },
limit: { default: "3", description: "Toasts shown in the stack. Older toasts stay open but hidden behind them." },
expand: { default: "false", description: "Keeps every toast fanned out instead of stacking them." },
hotkey: { default: '["altKey", "KeyT"]', description: "Keys that move focus to the toast list." },
swipeDirection: { default: '"right"', description: "Direction of the swipe that dismisses a toast." },
pauseOnInteraction: { default: "true", description: "Pauses every timer while the pointer is over the list or focus is inside it." },
pauseOnPageIdle: { default: "true", description: "Pauses every timer while the window is not focused." },
theme: { default: '"page"', description: "Theme of every toast. `inverted` renders the opposite of the page theme." },
"aria-label": { default: '"Notifications (alt+T)"', description: "Accessible name of the region." },
class: { description: "Class merged after the kit styles on the region." },
classes: { description: "Classes for the region and list parts. Per-toast classes go in the toast options." },
},
CreateToaster: {
duration: { default: "5000", description: "Milliseconds before a toast closes, when the toast sets no duration." },
Expand All @@ -53,7 +47,7 @@ export const notes = {
action: { description: "An inline text button. Its `onClick` receives the toast context. The toast stays open." },
closeable: { default: "true", description: "Shows the close button." },
duration: { default: "createToaster duration", description: "Milliseconds before the toast closes. `Infinity` keeps it open." },
theme: { description: "Renders the toast in this theme, whatever the page theme." },
theme: { default: "Toaster theme", description: "Overrides the Toaster theme for this toast." },
class: { description: "Class merged after the kit styles on the toast root." },
classes: { description: "Classes for the parts of this toast, keyed by part name." },
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Rules for every movement:
- Hover styles only under `@media (hover: hover) and (pointer: fine)`.
- **No materials.** Unlike Apple's design language, Inkstone has no translucency or `backdrop-filter` on the interface. Matte is a trait.

The kit's popover, hover card, menu, list popovers and tooltip follow Pop, and its toast follows Rise. Pop uses CSS keyframes. The kit keeps each closing surface mounted until its exit finishes. The rest of the kit's motion is slower than these rules today: buttons press in 200ms `ease`, and the focus ring transitions with `ease-in`. **Proposed:** move them to Press and a 120ms colour change.
The kit's popover, hover card, menu, list popovers and tooltip follow Pop, and its toast follows Rise. Several toasts stack like a deck, after Sonner: the newest in front, up to two older ones peeking 12px behind it at 95% and 90% scale with their content hidden, each a step closer to the page colour (`filter: brightness()`) so the cards read apart. A toast is a floating surface: `--cui-shadow-dialog`, with its inner ring in dark mode. A toast enters with a transition from its edge, so the stack moves back while it rises. Hover or focus fans them out with `transform` and `clip-path` over 400ms ease-out; a toast leaves toward its edge in 200ms; `expand` keeps them fanned out. Pop uses CSS keyframes. The kit keeps each closing surface mounted until its exit finishes. The rest of the kit's motion is slower than these rules today: buttons press in 200ms `ease`, and the focus ring transitions with `ease-in`. **Proposed:** move them to Press and a 120ms colour change.

The kit sheet follows Slide with transitions, and its scrim fades with it. It stays mounted until its exit ends, and the page under it takes clicks during that exit. Opened or closed from the keyboard, it does not move.

Expand Down
Loading
Loading