You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Notifications: transient toasts and a persistent notice stack #347
One consumer's toast: a single slot where a newer toast replaces the old; a 2.4 s dwell on egui's clock with a repaint booked for expiry; placement that shifts with the view mode. It has no live-region announcement, no fade and no pause on hover (~30 lines of view + ~60 of timing).
Next to it, a persistent notice stack (~150 lines): cards with a sentence, inline actions and a × to dismiss; no timeout; its rect is reported so other floating UI avoids it.
Proposal: one notification model.
Transient toasts: a configurable stack or replace policy and a dwell as a Duration on a clock tests can step. Paused while hovered or focused. A polite live region (role=status). An optional enter/exit motion via the motion tokens.
Persistent notices: dismissible, with action links that have proper roles and names.
Shared: placement as a corner/edge anchor with an inset the app can change, and a queried rect for avoidance.
Must keep: one-slot replace, a deterministic dwell, view-dependent placement. Design note first; looks go to the user as candidates.
Design note: Notifications (transient toasts and persistent notices)
Status: proposal for review. No code yet. The API shape and every look decision are yours to make; I give a recommendation for each.
Goal (#351): one notification widget replaces the hand-built toast (about 30 lines of view and 60 of timing) and the notice stack (about 150 lines). It must keep the one-slot replace, a deterministic dwell, and placement that depends on the view.
Where it lives:crates/eggshell-ui-extras, behind a notify feature, built only on core's public API. Its style lives in extras, with the shadcn values behind the shadcn crate's extras feature (the Markdown pattern). The public API can carry it today. The only core addition I recommend is optional: a one-method NodeHandle::live(..) (section 3).
1. Proposed public API
The model is one type for both kinds. Whether a stack is transient is a property of the stack, not of each item (Q2).
use core::time::Duration;use eggshell_ui::Distance;use eggshell_ui_extras::notify::{Dismissed,Lifetime,Notice,NotifyExt,ScreenAnchor};#[derive(Clone,Copy)]enumAct{CopyDetails,Open}structApp{toast:Option<Notice>,// one slot: replace = assignnotices:Vec<Notice<Act>>,// a stack: push / retainnext_notice:u64,// ids are the app'scompact:bool,// a view mode that moves the toast}fnview<'f>(b:&mutBuilder<'_,'f,App>,app:&'fApp){// The transient toast, bottom-centre, 28 px up (41 px in one view mode).
b.notifications("toast", app.toast.as_slice()).at(ScreenAnchor::BottomCenter,Distance::new(if app.compact{41.0}else{28.0})).lifetime(Lifetime::Dwell(Duration::from_millis(2400))).on_dismiss(|app, _id, _why| app.toast = None).add();// Persistent notices, top-right, with actions and a × button.
b.notifications("notices",&app.notices).at(ScreenAnchor::TopRight,Distance::new(16.0)).lifetime(Lifetime::UntilDismissed).on_action(|app, id, act| app.run(id, act)).on_dismiss(|app, id, _why| app.notices.retain(|n| n.id != id)).add();}// Posting: plain data, no library call.
app.toast = Some(Notice::new(app.next_id(),"Copied"));
app.notices.push(Notice::new(app.next_id(),"Export failed.").action("Copy details",Act::CopyDetails).action("Open log",Act::Open));
pubstructNotice<Act = NoAction>{pubid:NoticeId,// a new id restarts the dwellpubtext:String,pubactions:Vec<NoticeAction<Act>>,}pubenumLifetime{Dwell(Duration),UntilDismissed}pubenumDismissed{Expired,Closed,Escape}// why `on_dismiss` ranpubenumScreenAnchor{TopLeft,TopCenter,TopRight,BottomLeft,BottomCenter,BottomRight}
Who owns state. The queue is app state: an Option<Notice> or a Vec<Notice> in the app's plain fields. The library never adds to it or removes from it. Expiry, ×, Escape and actions each come back to the app through a handler, as on_dismiss already does for overlays. This rule also settles the replace-or-stack question without any setting. The policy is the app's data structure:Option means replace and Vec means stack. A cap on visible items is truncate. Two settings that could disagree with the data simply don't exist.
The library keeps only timing: the dwell left on each visible id. It is keyed by the stack's node id and the NoticeId, and lives in egui temp data, which extras can reach publicly. This mirrors the tooltip, whose hover-intent state is library-side while the app owns what is shown. A dwell is not app data. The app would otherwise have to tick it itself, which is the 60 lines this widget deletes.
2. Behaviour
Aspect
Proposal
Replace vs stack
It follows the data: Option replaces and Vec stacks, newest nearest the anchor (Q3). A replacement carries a new id, so its dwell starts fresh and is never inherited.
Dwell
Lifetime::Dwell(Duration), a core::time::Duration. The clock is egui's input.time, converted once into Duration as tooltip::end does. A pure Dwell::tick(now, Hold) -> Remaining(Duration) | Expired follows the precedent of Tooltips::tick(now, ..). It is unit-tested with explicit Durations, and kittest steps it through step_dt. While a dwell runs, the widget books request_repaint_after(remaining), so a reactive app wakes at expiry without other input, as today.
Pause
Each dwell holds while the pointer is over the stack, while focus is within it (has_focus_within), and while the window is unfocused (!input.focused). That last case is sonner's "document hidden": a toast that expires while you're in another window was never read. All visible items pause together (sonner's behaviour, and the simplest rule). Time held is not counted, and the dwell resumes where it left off.
Escape
With focus inside a notice, Esc dismisses that notice (Dismissed::Escape). Esc anywhere else is left alone, because the page's dialogs and menus own it (Q5). The overlay is DismissOn::Never, so core's overlay Esc never fires for it.
× dismiss
It is a real button with Role::Button, named "Dismiss" plus the notice text, and it gives Dismissed::Closed. Whether a transient toast shows × is a look and behaviour choice (Q6).
Actions
Each action is a Role::Link (or Button, Q7) named by its label. Activating one runs on_action(app, id, act). The notice does not dismiss itself, because a "Copy details" action should leave it up. The app removes it in the handler if it wants that.
Live region
The stack's container is Role::Status with accesskit live = Polite. accesskit 0.25 has Live::{Off, Polite, Assertive} and Node::set_live, and egui 0.37 re-exports accesskit. Errors could be Role::Alert / Assertive (Q8). This needs a spike: whether egui's adapters actually announce a live-region change on AT-SPI, macOS and Windows has to be checked by hand with a screen reader before we rely on it.
Keyboard reach
Overlays come after the page in Tab order (docs/overlays.md), so Tab reaches notices without a hotkey. The overlay is Focus::None: posting a notice never steals focus. Sonner's Alt+T hotkey is Q9.
Placement
ScreenAnchor plus a Distance inset is a thin constructor of core's existing Placement: Anchor::Screen, Placement::edge(side).align(align), with the inset as Boundary::Window.inset(Sides { .. }). For full control, .placement(Placement) takes core's type directly. A view-dependent inset is just a value the app computes each frame.
Band
It renders as an overlay in Band::Popup, declared after the page so it stacks above an open dialog and stays reachable (Q10). Outside::PassThrough: a press beside a toast belongs to the page.
Motion
shown(!items.is_empty()) with an entrance from the extras style's KindMotion (Entrance::Slide(side) or Pop). It goes through core's presence, so reduced motion (animation_time == 0) already zeroes it. Core never fades a box (group opacity is missing; see presence.rs), so "fade" is not on the menu unless that changes. In v1 the stack as a whole enters and exits. An item arriving in or leaving a non-empty stack is instant (Q4).
Rect for avoidance
This is already public: placed.overlay("notices").map(|o| o.rect()) after layout. A view that must avoid the stack at build time keeps last frame's rect in a field, as the consumer does now, or passes it to its own overlay's Placement::boundary(Boundary::Rect(..).inset(..)). No new API (Q11).
Presence and motion (shown, entrance, KindMotion, reduced motion).
The owned button for × and for the actions. A link look is a named button Variant (shadcn's link and ghost), not new paint code.
The tooltip's Duration-based tick pattern.
has_focus_within and NodeUi::node_response for the pause.
Placed::overlay(..).rect() for avoidance.
Verdict: it can live in extras on core's public API as it stands. The live region can be set from extras through egui's public accesskit_node_builder in a draw closure, which is how core's NodeHandle::expanded works. A role only reaches accesskit on a sensing node, so the container gets sense_hover(), which is public.
The one optional core primitive:NodeHandle::live(Live), about 15 lines mirroring expanded(). I recommend it (Q1). It is not required for extras to work. The reason is that "announce changes here" is a general need: status lines, Spinner #348 and progress messages all have it. Without it, each extras widget reaches into accesskit separately.
4. Look decisions for a render round (no picks made)
I'll render each candidate at real size, in light and dark, over a busy page:
Card surface: fill (sonner/shadcn use popover), border, radius (--radius), shadow.
Width: fixed (sonner 356 px; the consumer's notice stack is fixed) or fit to content with a max.
Padding and text: a single sentence or title plus description, with typography roles.
Gap between stacked items (sonner 14 px) and the maximum visible.
Stacking style: a plain list, or sonner's collapsed pile that expands on hover.
Tone: neutral only, or success/info/warning/error variants with lucide icons (shadcn's sonner wires CircleCheck, Info, TriangleAlert, OctagonX, plus a spinning Loader2), and whether "rich colours" tint the card.
× button: shown on toasts or only on notices; its position (sonner puts it top-left, many apps top-right) and its size and icon.
Action links: link-styled text or small ghost or outline buttons; their placement (inline after the sentence, or a footer row).
Entrance: slide from the anchor edge, pop (zoom 95% plus a short slide), or none; plus durations and easing.
Toast vs notice: one look, or a visual distinction between transient and persistent items.
5. Breaking changes and PR split
Breaking changes: none. Everything is additive.
PR
Contents
Size
1 (core, optional)
NodeHandle::live(Live), with a test reading the accesskit tree.
XS (~40 lines)
2 (extras)
The notify feature: the model, the pure Dwell with unit tests, the widget (overlay, placement, pause, Esc, ×, actions, live region), and kittest tests through the full path. Tests step the clock past the dwell, check that hover and focus hold it, check that a replacement restarts it, and check that Esc only acts with focus inside.
M (~600)
3 (extras + shadcn)
NotifyStyle after the render round, its shadcn fill behind extras, and an example. A manual screen-reader check of the live region. You try the build before the PR is approved.
S–M (~250)
The consumer migrations happen in the consumers' own repos afterwards.
6. Questions for you
#
Question
My recommendation
Q1
Add NodeHandle::live(Live) to core, or set the live region from extras through egui's accesskit hook?
Add it. It is tiny and general (Spinner #348 wants it too).
Q2
Lifetime per stack (.lifetime(..)) or per notice?
Per stack. Both consumer stacks are uniform, and a mixed stack has no user yet.
Q3
Order in a stack: newest nearest the anchor (sonner), or appended in reading order?
Newest nearest the anchor.
Q4
Per-item enter and exit motion inside a non-empty stack? It costs keeping a departed item's content in library state, as the tooltip does.
Not in v1. Whole-stack motion only; revisit after the render round.
Q5
Esc: dismiss only the focused notice, or the newest toast wherever focus is?
Focused only. A global Esc would fight dialogs and menus.
Q6
Do transient toasts show ×?
No by default, with an option. The persistent notices always show it.
Q7
Actions as Role::Link or Role::Button?
Button. They act and don't navigate, even when styled as links.
Q8
Politeness: all polite, or errors assertive (Role::Alert)?
All polite in v1. Assertive interrupts and is easy to overuse.
Q9
A hotkey to focus the stack (sonner's Alt+T)?
No. Tab order reaches it. Add it through app commands (#325) if a consumer asks.
Q10
Band: Popup (above dialogs, reachable during a modal) or Floating (with the page, under popups and scrims)?
Popup. A toast posted by a dialog's action must be visible.
Q11
Rect for avoidance: the existing placed.overlay(key).rect() only, or an .on_rect(|app, rect|) callback that writes it into app state?
The existing query. It needs no new API and keeps derived layout out of app fields unless the app chooses to store it.
Looks decided (user, 2026-11-18): all 11 recommendations accepted:
popover fill, a 1px border and sonner's shadow;
a fixed 356 pt width;
16 pt padding with a 13 px sentence;
a 14 pt gap, 3 visible;
a plain list;
neutral tone in v1;
× as a trailing ghost button;
actions as small outline buttons inline;
a 24 pt inset;
one shared look for toasts and notices;
no entrance animation.
Before finalising PR 3, check each sonner reference value against sonner's actual source; the note wrote them from memory. Then build the style, the shadcn values and the example, and hand it over for a user trial.
Activity
samitbasu commentedon Nov 18, 2026
Design note: Notifications (transient toasts and persistent notices)
Status: proposal for review. No code yet. The API shape and every look decision are yours to make; I give a recommendation for each.
Goal (#351): one notification widget replaces the hand-built toast (about 30 lines of view and 60 of timing) and the notice stack (about 150 lines). It must keep the one-slot replace, a deterministic dwell, and placement that depends on the view.
Where it lives:
crates/eggshell-ui-extras, behind anotifyfeature, built only on core's public API. Its style lives in extras, with the shadcn values behind the shadcn crate'sextrasfeature (the Markdown pattern). The public API can carry it today. The only core addition I recommend is optional: a one-methodNodeHandle::live(..)(section 3).1. Proposed public API
The model is one type for both kinds. Whether a stack is transient is a property of the stack, not of each item (Q2).
Who owns state. The queue is app state: an
Option<Notice>or aVec<Notice>in the app's plain fields. The library never adds to it or removes from it. Expiry, ×, Escape and actions each come back to the app through a handler, ason_dismissalready does for overlays. This rule also settles the replace-or-stack question without any setting. The policy is the app's data structure:Optionmeans replace andVecmeans stack. A cap on visible items istruncate. Two settings that could disagree with the data simply don't exist.The library keeps only timing: the dwell left on each visible id. It is keyed by the stack's node id and the
NoticeId, and lives in egui temp data, which extras can reach publicly. This mirrors the tooltip, whose hover-intent state is library-side while the app owns what is shown. A dwell is not app data. The app would otherwise have to tick it itself, which is the 60 lines this widget deletes.2. Behaviour
Optionreplaces andVecstacks, newest nearest the anchor (Q3). A replacement carries a new id, so its dwell starts fresh and is never inherited.Lifetime::Dwell(Duration), acore::time::Duration. The clock is egui'sinput.time, converted once intoDurationastooltip::enddoes. A pureDwell::tick(now, Hold) -> Remaining(Duration) | Expiredfollows the precedent ofTooltips::tick(now, ..). It is unit-tested with explicitDurations, and kittest steps it throughstep_dt. While a dwell runs, the widget booksrequest_repaint_after(remaining), so a reactive app wakes at expiry without other input, as today.has_focus_within), and while the window is unfocused (!input.focused). That last case is sonner's "document hidden": a toast that expires while you're in another window was never read. All visible items pause together (sonner's behaviour, and the simplest rule). Time held is not counted, and the dwell resumes where it left off.Dismissed::Escape). Esc anywhere else is left alone, because the page's dialogs and menus own it (Q5). The overlay isDismissOn::Never, so core's overlay Esc never fires for it.Role::Button, named "Dismiss" plus the notice text, and it givesDismissed::Closed. Whether a transient toast shows × is a look and behaviour choice (Q6).Role::Link(orButton, Q7) named by its label. Activating one runson_action(app, id, act). The notice does not dismiss itself, because a "Copy details" action should leave it up. The app removes it in the handler if it wants that.Role::Statuswith accesskitlive = Polite. accesskit 0.25 hasLive::{Off, Polite, Assertive}andNode::set_live, and egui 0.37 re-exportsaccesskit. Errors could beRole::Alert/Assertive(Q8). This needs a spike: whether egui's adapters actually announce a live-region change on AT-SPI, macOS and Windows has to be checked by hand with a screen reader before we rely on it.docs/overlays.md), so Tab reaches notices without a hotkey. The overlay isFocus::None: posting a notice never steals focus. Sonner's Alt+T hotkey is Q9.ScreenAnchorplus aDistanceinset is a thin constructor of core's existingPlacement:Anchor::Screen,Placement::edge(side).align(align), with the inset asBoundary::Window.inset(Sides { .. }). For full control,.placement(Placement)takes core's type directly. A view-dependent inset is just a value the app computes each frame.Band::Popup, declared after the page so it stacks above an open dialog and stays reachable (Q10).Outside::PassThrough: a press beside a toast belongs to the page.shown(!items.is_empty())with an entrance from the extras style'sKindMotion(Entrance::Slide(side)orPop). It goes through core's presence, so reduced motion (animation_time == 0) already zeroes it. Core never fades a box (group opacity is missing; seepresence.rs), so "fade" is not on the menu unless that changes. In v1 the stack as a whole enters and exits. An item arriving in or leaving a non-empty stack is instant (Q4).placed.overlay("notices").map(|o| o.rect())after layout. A view that must avoid the stack at build time keeps last frame's rect in a field, as the consumer does now, or passes it to its own overlay'sPlacement::boundary(Boundary::Rect(..).inset(..)). No new API (Q11).3. Reuse, and what core must make public
Reused, with no parallel implementation:
b.overlay,Anchor::Screen,Placement::edge,Boundary::inset,Band,Focus::None,DismissOn::Never).shown,entrance,KindMotion, reduced motion).ownedbutton for × and for the actions. A link look is a named buttonVariant(shadcn'slinkandghost), not new paint code.Duration-based tick pattern.has_focus_withinandNodeUi::node_responsefor the pause.Placed::overlay(..).rect()for avoidance.Verdict: it can live in extras on core's public API as it stands. The live region can be set from extras through egui's public
accesskit_node_builderin a draw closure, which is how core'sNodeHandle::expandedworks. A role only reaches accesskit on a sensing node, so the container getssense_hover(), which is public.The one optional core primitive:
NodeHandle::live(Live), about 15 lines mirroringexpanded(). I recommend it (Q1). It is not required for extras to work. The reason is that "announce changes here" is a general need: status lines, Spinner #348 and progress messages all have it. Without it, each extras widget reaches into accesskit separately.4. Look decisions for a render round (no picks made)
I'll render each candidate at real size, in light and dark, over a busy page:
popover), border, radius (--radius), shadow.CircleCheck,Info,TriangleAlert,OctagonX, plus a spinningLoader2), and whether "rich colours" tint the card.5. Breaking changes and PR split
Breaking changes: none. Everything is additive.
NodeHandle::live(Live), with a test reading the accesskit tree.notifyfeature: the model, the pureDwellwith unit tests, the widget (overlay, placement, pause, Esc, ×, actions, live region), and kittest tests through the full path. Tests step the clock past the dwell, check that hover and focus hold it, check that a replacement restarts it, and check that Esc only acts with focus inside.NotifyStyleafter the render round, its shadcn fill behindextras, and an example. A manual screen-reader check of the live region. You try the build before the PR is approved.The consumer migrations happen in the consumers' own repos afterwards.
6. Questions for you
NodeHandle::live(Live)to core, or set the live region from extras through egui's accesskit hook?.lifetime(..)) or per notice?Role::LinkorRole::Button?Button. They act and don't navigate, even when styled as links.Role::Alert)?Popup(above dialogs, reachable during a modal) orFloating(with the page, under popups and scrims)?Popup. A toast posted by a dialog's action must be visible.placed.overlay(key).rect()only, or an.on_rect(|app, rect|)callback that writes it into app state?samitbasu commentedon Nov 18, 2026
Decisions (user, 2026-11-18):
Optionreplaces,Vecstacks); eggshell only times each notice's dwell.live(), the lifetime per stack, actions as buttons, no hotkey, the rect via the existing query.Placement: the widgets crate (#366), extras until the split. The look goes to a render round (11 items).
samitbasu commentedon Nov 18, 2026
Looks decided (user, 2026-11-18): all 11 recommendations accepted:
Before finalising PR 3, check each sonner reference value against sonner's actual source; the note wrote them from memory. Then build the style, the shadcn values and the example, and hand it over for a user trial.
Merge pull request #445 from samitbasu/notify-style-347
Notify's card on the sheet: sonner's classes as rules over its look (#…