sugarcraft / sugar-toast
PHP port of DaltonSW/bubbleup — floating alert notification component for terminal UIs. Supports error/warning/info/success alerts at 6 screen positions, dynamic width, NerdFont/Unicode/ASCII symbols, auto-dismiss timers.
v0.2.0
2026-05-07 01:29 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is not auto-updated.
Last update: 2026-05-07 14:50:24 UTC
README
SugarToast
PHP port of DaltonSW/bubbleup — floating alert notification component for terminal UIs. Alerts float to the top of your TUI like bubbles in soda.
Features
- 6 positions: TopLeft, TopCenter, TopRight, BottomLeft, BottomCenter, BottomRight
- 4 alert types: Error, Warning, Info, Success — each with distinct styling
- Dynamic width: fixed or auto-sizing between minWidth and maxWidth
- Symbol sets: NerdFont (icons), Unicode (boxed), ASCII (plain text)
- Auto-dismiss: duration-based expiry support
- Multiple alerts: queue of toasts rendered in order
- Pure renderer: outputs ANSI strings; works with any TUI framework
Install
composer require sugarcraft/sugar-toast
Quick Start
use SugarCraft\Toast\{Position, Toast, ToastType}; $toast = Toast::new(50) // max width 50 ->withPosition(Position::TopRight) ->withDuration(10.0); // seconds // Add alerts $toast = $toast->alert(ToastType::Success, 'File saved!'); $toast = $toast->alert(ToastType::Error, 'Connection failed'); // Render into a viewport $bg = str_repeat("background content\n", 20); echo $toast->View($bg);
Alert Types
ToastType::Error ToastType::Warning ToastType::Info ToastType::Success
Positions
Position::TopLeft Position::TopCenter Position::TopRight Position::BottomLeft Position::BottomCenter Position::BottomRight