sugarcraft / sugar-dash
Dashboard TUI library — column grid, constraint layout, ratio grid, data grid, tree, modal, status bar, tabs, plot/canvas, and module/plugin system. Ports patterns from bubble-grid, bubbletea-tilelayout, go-tealeaves, bubbleboxer, lattice, Homedash, and termui.
dev-master
2026-05-13 15:08 UTC
Requires
- php: ^8.3
- sugarcraft/candy-core: dev-master
- sugarcraft/candy-sprinkles: dev-master
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is not auto-updated.
Last update: 2026-05-13 17:04:30 UTC
README
A comprehensive TUI grid rendering library for PHP 8.3+, ported from the Charmbracelet ecosystem (bubbletea, bubble-grid, lipgloss). Provides 200+ components for building rich terminal user interfaces.
Installation
composer require sugarcraft/sugar-dash
Core Concepts
Interfaces & Contracts
| Type | Description | Key Methods |
|---|---|---|
Item |
Anything that can be placed in a StackedGrid and rendered as a string | render(): string |
Sizer |
An Item that knows its own dimensions (extends Item) | setSize(int $width, int $height): Sizer, render(): string |
Configuration Classes
| Type | Description | Key Properties |
|---|---|---|
Options |
Grid-level configuration options | $fitScreen: bool (default: true) |
ItemOptions |
Per-item placement options within StackedGrid | $column: int (0-based), $expandVertical: bool |
ItemWithOptions |
Internal pairing of Item + ItemOptions | $item: Item, $options: ItemOptions |
Layout Enums
| Type | Values |
|---|---|
LayoutDirection |
Horizontal, Vertical |
SplitDirection |
Horizontal, Vertical |
AlignItems |
Start, End, FlexStart, FlexEnd, Center, Stretch, Baseline |
FlexDirection |
Row, Column, RowReverse, ColumnReverse |
FlexWrap |
NoWrap, Wrap, WrapReverse |
HAlign |
Left, Right, Center |
VAlign |
Top, Middle, Bottom |
JustifyContent |
Start, End, FlexStart, FlexEnd, Center, SpaceBetween, SpaceAround, SpaceEvenly |
FlowchartNodeType |
Process, Decision, StartEnd, InputOutput, Connector, Data |
EdgeStyle |
Solid, Dashed, Dotted, Bold |
NetworkShape |
Circle, Square, Diamond, Hexagon, Star |
WaterfallBarType |
Positive, Negative, Total, Subtotal |
Layout & Structural Components
Layout Containers
Border & Frame Components
Spacing & Layout Helpers
Data Visualization (Charts)
Chart Components
Form & Input Components
Feedback & Status Components
Navigation Components
Layout Helper Components
Text Components
Diagram & Visualization Components
Event Types
| Type | Description | Key Properties |
|---|---|---|
Event |
Base event class | |
EventHandler |
Event handler callback | |
EventDispatcher |
Event dispatcher | |
FocusEvent |
Focus event | |
KeyEvent |
Keyboard event | |
MouseEvent |
Mouse event | |
PasteEvent |
Paste event | |
ResizeEvent |
Resize event | |
Focus |
Focus state management | |
Key |
Key representation | |
KeyAction |
Key action | |
KeyMap |
Key mapping | |
State |
Application state |
Theme & Styling
| Type | Description | Key Methods |
|---|---|---|
Theme |
Theme management with pre-defined themes | dark(), dracula(), oneDark(), githubDark(), light(), foreground(), background(), primary(), bar(), text() |
Usage Example
use SugarCraft\Dash\Grid\{StackedGrid, Frame, VStack, Text, Panel, Options, ItemOptions}; // Create a stacked grid layout $grid = new StackedGrid(new Options(fitScreen: true)); // Add items to columns $grid->addItem( Frame::new( VStack::centered( Text::new('Welcome to SugarDash'), Text::new('Build beautiful TUIs') ) )->withPadding(1), new ItemOptions(column: 0, expandVertical: true) ); // Add a panel to the second column $grid->addItem( Panel::titled( Text::new('This is a panel'), 'Dashboard' ), new ItemOptions(column: 1) ); // Set size and render $grid->setSize(80, 24); echo $grid->render();
Testing
cd sugar-dash && composer install && vendor/bin/phpunit
GIF Demos
License
MIT License - See LICENSE file for details.





































































































































