SugarDashboard
Dashboard TUI library — column grid, constraint layout, ratio grid, data grid, tree, modal, status bar, tabs, plot/canvas, and a module/plugin system
Build dashboard-style terminal UIs with a column grid, constraint layout, ratio grid, data grid, tree views, modals, status bars, tabs, and plot/canvas rendering. Compose complex layouts from reusable components, and extend the whole system through the module/plugin layer. All motion is frame-driven — the library renders synchronously and the host supplies every frame, so a reduced-motion presentation is always reachable by holding the frames still.
Install
composer require sugarcraft/sugar-dashboard
Quickstart
use SugarCraft\Dashboard\Layout\Grid\{StackedGrid, Options, ItemOptions};
use SugarCraft\Dashboard\Components\Card\{Card, Text};
$grid = (new StackedGrid(new Options(fitScreen: true)))
->withItem(Card::titled(Text::new('CPU 42%'), 'Load'), new ItemOptions(column: 0))
->withItem(Card::titled(Text::new('3 alerts'), 'Alerts'), new ItemOptions(column: 1, expandVertical: true));
// Every with*() / setSize() returns a sized COPY — keep the result.
$grid = $grid->setSize(100, 24);
echo $grid->render(); // two bordered cards side by side; below 90 columns they stack
What's in the box
graph_symbols table, in braille / block / block2 / tty families, with invert, no-zero, max-value scaling, gradient coloring and the graph_bg underlay.Meter::withGradient($stops, positionWise: true) renders btop's one-row ■ bar — each cell colored at its own position on a 101-stop ramp, meter_bg tail, invert, memoized per shape.Gradient101::expand() (btop's integer ramp law), GradientStore named ramps (at('cpu', 73)), and value-driven BrailleCanvas::withGradient().ProcRowComposer renders a btop process-list row (pid … mem, 5×1 cpu mini-graph on graph_bg, cpu%) with DistanceFade shading; ProcGraphTracker manages per-pid graphs.btop-style graphs & meters
Ported from aristocratos/btop for candy-top; color and quantization laws are byte-faithful to btop. Run php examples/dual-sample-graph.php for every family.
use SugarCraft\Core\Util\Color;
use SugarCraft\Dashboard\Plot\Braille\DualSampleGraph;
use SugarCraft\Dashboard\Plot\Chart\Meter;
$stops = [Color::hex('#80d0a3'), Color::hex('#dcd179'), Color::hex('#d45454')];
echo DualSampleGraph::new(12, 3)
->withGradient($stops)
->withData(5, 12, 30, 55, 80, 95, 70, 45, 20, 10, 35, 60)
->render(), "\n";
echo Meter::new(0.62)->withWidth(20)->withGradient($stops, positionWise: true)->render(), "\n";
Showcase examples
View gif →
Source & demos
- Source on GitHub
- Full README
- Runnable examples
- Originally inspired by the Go Charm ecosystem; SugarCraft is developed as a native PHP project.
Concepts
The library renders synchronously. Nothing animates on its own: the host calls render() for every frame, so a static frame is always available and motion is the host's choice.
Grids and components are immutable. withItem() and setSize() return a changed copy, and the receiver keeps its old state. Keep the returned value, as the Quickstart and Troubleshooting examples do.
API reference
| Class | Method | Description |
|---|---|---|
| Layout\Grid\StackedGrid | __construct(Options = new Options()) | Column grid; columns stack vertically below the narrow breakpoint (90 cells) |
| Layout\Grid\StackedGrid | addItem(Item, ItemOptions = new ItemOptions()) | Add an item to a column |
| Layout\Grid\StackedGrid | setSize(width, height) / render() / withTheme(Theme) | Size, render to an ANSI string, theme |
| Layout\Grid\Options / ItemOptions | new Options(fitScreen: bool) / new ItemOptions(column: int, expandVertical: bool) | Grid and per-item options |
| Components\Card\Card | static titled(Item|string, string $title) | Bordered card with a title |
| Layout\Frame | static new(Item) / withTitle() / withBorder() / withPadding() | Framed panel |
| Plot\Gradient101 | static expand(list<Color> $stops) | btop's 101-entry ramp (index = percent), truncating integer law |
| Plot\Braille\BrailleCanvas | withGradient(stops, ?scale) / withValue(v) / withoutGradient() / gradient() / value() | Null-color dots take the ramp color at the current value |
| Plot\Braille\DualSampleGraph | static new(width, height, family, invert, noZero, maxValue, offset) | btop Draw::Graph; families FAMILY_BRAILLE / FAMILY_BLOCK / FAMILY_BLOCK2 / FAMILY_TTY |
| Plot\Braille\DualSampleGraph | push(...$v) / withData(...$v) / withGradient(stops) / withUnderlay(Color) / render(?profile) | Append or replace history, color, underlay, render |
| Plot\Braille\DualSampleGraph | static underlay(family, cells, Color) | Bare btop graph_bg strip (⣀ ▄ 🬭 ░) |
| Plot\Chart\Meter | withGradient(stops, positionWise) / withGlyph() / withInvert() / withMeterBg() | btop Draw::Meter position-colored bar; memoStats() / resetMemo() |
| Foundation\NetAutoScale | static new(sync) / offer(down, up) / downloadMax() / uploadMax() / maxFor(dir) / counters(dir) / forceRescale() / rescaleNow() / rescalePending() | btop net-graph ceiling hysteresis; the $sync / $rescaled result flags are public readonly |
| Foundation\GradientStore | static fromStops(array) / static ramp(start, ?mid, ?end) / withGradient(name, start, ?mid, ?end) / at(name, percent) / gradient(name) / has(name) / names() | Named 101-entry ramps (btop Theme::g) |
| Plot\DistanceFade | ramp() / distance() / fadeIndex() / fadeColor() / metricPosition() / metricColor() / flatMetricColor() / metricValues() | btop proc-list distance fade |
| Plot\ProcRow\ProcRowComposer | static new(width) / withColumns() / withPalette() / withProcColors() / withProcGradient() / withFamily() / row(ProcRow, row, selected, selectMax, ?graph, followed, ?profile) | One btop process-list row; ProcRow, ProcColumns, ProcRowPalette, ProcGraphTracker supply data, layout, colors and mini-graphs |
Configuration
The defaults below are the values the classes ship with.
Options::$fitScreen: bool, defaulttrue. Option ofLayout\Grid\Options. Whether columns fit the screen width. Widths under 90 cells collapse to one full-width column before this option is read.ItemOptions(column:, expandVertical:): int, bool, defaultcolumn0 andexpandVerticalfalse. Places an item in a column and lets it take the spare height.- Narrow breakpoint: fixed at 90 cells in
StackedGrid. Below this width it stacks every item into one column.StackedGrid::render()callsBreakpoint::narrow()with no threshold, so the threshold is not configurable on the grid. The second argument,Breakpoint::narrow($width, $threshold), is a parameter only of the standalone helper. DualSampleGraph::new(..., $family): string, defaultFAMILY_BRAILLE. Symbol family:braille,block,block2ortty.DualSampleGraph::new(..., $invert, $noZero, $maxValue): bool, bool, int, defaultfalse,false,0. Flips the graph, hides zero samples, and sets the scale ceiling.Meter::withGradient($stops, positionWise:): list of colors, bool, default no gradient. Colors each cell by its position on the ramp whenpositionWiseis true.
Keys
Keys\KeyMap binds keys to actions on a component's content. on() registers a key, optionally with Ctrl, Alt or Shift, and off() removes it. has() and registeredKeys() report what is bound. A key bound twice keeps its first action, and the later one is logged and ignored.
Each action is a callable that takes the Key and returns the Foundation\Item that replaces the content. Return $content to keep the content as it is; returning null throws a TypeError when the key is pressed.
use SugarCraft\Dashboard\Keys\KeyMap;
$keys = KeyMap::new($content)
->on('r', fn () => $content)
->on('q', fn () => $content, ctrl: true);
Keys\KeyRegistry is a separate, process-wide table. It stores each binding with a description and a category, so status bars and help screens can list them. register(), get(), byCategory(), categories() and match() read and write that table, and reset() empties it.
Theming
Foundation\Theme has five presets: dark(), light(), dracula(), oneDark() and githubDark(). Pass one to StackedGrid::withTheme(), which applies it to every theme-aware item in the grid. Items that do not implement Foundation\Drawable are passed through unchanged and keep their own theme.
use SugarCraft\Dashboard\Foundation\Theme;
$grid = $grid->withTheme(Theme::dracula());
Examples
examples/ holds 155 PHP files. Most are one component each, named after it (for example meter.php, modal.php, stackedGrid.php and gridLayout.php), and the dashboard-*.php files are full layouts. The headline examples are:
dashboard-live.php: The canonical interactive dashboard, driven by aProgramevent loop.dashboard-showcase.php: A production-style server dashboard with gauges, charts, avatars and a timeline in a multi-column layout.dual-sample-graph.php: The same CPU history through each symbol family, an inverted graph and a one-row meter.plot-braille.php: Scatter and line modes ofPlot, drawn with braille dots from identical data.run-all.php: Batch runner that executes the component examples and reports each one's result.generate-all.php: Generator that writes one example file per visual component.
Testing
cd sugar-dashboard
composer install
vendor/bin/phpunit
The suite is plain PHPUnit 10 with the root vendor/autoload.php bootstrap. It does not use sugar-testing.
Only methods declared in sugar-dashboard/src, or inherited from a parent declared there, are listed. A type that extends a class outside that tree, such as \RuntimeException, does not show the methods of that class.
SugarCraft\Dashboard\Components\Calendar
Calendar final class
A simple calendar component.
| Method | Summary |
|---|---|
__construct(private readonly int $year, private readonly int $month, private readonly int $startDayOfWeek = 0, private readonly ?int $highlightDay = null, private readonly array $markedDays = [], private readonly ?Color $headerColor = null, private readonly ?Color $todayColor = null, private readonly ?Color $markerColor = null) | |
static now(): self | Create a calendar for the current month. |
static of(int $year, int $month): self | Create a calendar for a specific year and month. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this calendar. |
innerSize(): array | Calculate the natural dimensions of this calendar. |
render(): string | Render the calendar. |
withStartDayOfWeek(int $day): self | Set the start day of week (0 = Sunday, 1 = Monday, etc). |
withHighlightDay(?int $day): self | Set the highlighted day (e.g., today). |
withMarkedDays(array $days): self | Set marked days (e.g., events). |
withHeaderColor(?Color $color): self | Set the header color. |
withTodayColor(?Color $color): self | Set the today color. |
withMarkerColor(?Color $color): self | Set the color used for the marker glyph on marked days (finding sugar-dashboard-163: the markerColor the ctor accepts and render consults had no wither, so the promoted-only color trio was half-documented). |
HeatmapCalendar final class
A calendar heatmap component (GitHub-style contributions).
| Method | Summary |
|---|---|
__construct(private readonly array $data, private readonly bool $showLabels = true, private readonly bool $showMonthLabels = false, private readonly bool $showDayLabels = true, private readonly ?Color $lowColor = null, private readonly ?Color $highColor = null, private readonly string $emptyChar = '·') | |
static new(array $data): self | Create a new calendar heatmap with default styling. |
static sample(int $weeks = 20, float $baseValue = 0.3): self | Create sample data for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this heatmap. |
render(): string | Render the calendar heatmap. |
innerSize(): array | Calculate the natural dimensions of this heatmap. |
dataDimensions(): array | Get the dimensions of the data grid. |
getDataDimensions(): array | BC forwarder for the pre-rename accessor name. |
totalValue(): float | Get the total value across all cells. |
getTotalValue(): float | BC forwarder for the pre-rename accessor name. |
averageValue(): float | Get the average value across all cells. |
getAverageValue(): float | BC forwarder for the pre-rename accessor name. |
withLabels(bool $show): self | Show or hide labels. |
withMonthLabels(bool $show): self | Show or hide month labels. |
withDayLabels(bool $show): self | Show or hide day labels. |
withLowColor(?Color $color): self | Set the low (cold) color. |
withHighColor(?Color $color): self | Set the high (hot) color. |
withEmptyChar(string $char): self | Set the empty cell character. |
ListComponent final class
A scrollable list component with item selection.
| Method | Summary |
|---|---|
__construct(private readonly array $items, private readonly int $selected = 0, private readonly ?\Closure $filter = null, private readonly bool $showCursor = true, private readonly string $style = self::Bullet, private readonly HAlign $itemAlign = HAlign::Left) | |
static new(array $items): self | Create a new list with the given items. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this list. |
render(): string | Render the list with selection cursor. |
innerSize(): array | Calculate the natural dimensions of this list when rendered. |
withItems(array $items): self | Set the items for this list. |
withSelected(int $selected): self | Set the selected index. |
withFilter(?\Closure $filter): self | Set a filter predicate for items. |
withShowCursor(bool $showCursor): self | Show or hide the cursor indicator. |
withStyle(string $style): self | Set the list style (bullet, number, arrow, plain). |
withItemAlign(HAlign $align): self | Set the item alignment within the list width. |
SugarCraft\Dashboard\Components\Card
Accordion final class
An accordion component that displays collapsible sections.
| Method | Summary |
|---|---|
__construct(array $sections) | |
static new(array $sections): self | Create a new accordion with the given sections. |
static fromPairs(array $pairs): self | Create an accordion from key-value pairs. |
setSize(int $width, int $height): Sizer | Set the size of this accordion. |
innerSize(): array | Get the inner dimensions of this accordion. |
withHeaderColor(Color $color): self | Set the header color. |
withIcons(string $collapsed, string $expanded): self | Set custom icons for collapsed/expanded states. |
withShowBorder(bool $show): self | Toggle border visibility. |
withSections(array $sections): self | Update sections. |
withOpenSection(int $index): self | Open a specific section by index. |
render(): string | Render the accordion. |
ActivityEvent final readonly class
An event in an activity feed.
| Method | Summary |
|---|---|
__construct(public string $actor, public string $action, public string $target, public string $type = 'default', public ?string $timestamp = null) |
ActivityFeed final class
An activity feed component for displaying a stream of events.
| Method | Summary |
|---|---|
__construct(private readonly array $events = [], private readonly bool $showIcons = true, private readonly bool $showTimestamps = true, private readonly bool $showAvatars = false, private readonly ?Color $iconColor = null, private readonly ?Color $timestampColor = null, private readonly ?Color $textColor = null, private readonly int $maxItems = 10) | |
static new(array $events = []): self | Create a new activity feed. |
static sample(): self | Create a sample activity feed for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this feed. |
render(): string | Render the activity feed. |
innerSize(): array | Calculate the natural dimensions of this feed. |
withEvents(array $events): self | Set the events. |
withShowIcons(bool $show): self | Show or hide icons. |
withShowTimestamps(bool $show): self | Show or hide timestamps. |
withMaxItems(int $max): self | Set the maximum number of items to display. |
Badge final class
A badge/tag component for displaying labels and statuses.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly ?Color $bgColor = null, private readonly ?Color $textColor = null, private readonly string $style = self::StyleSolid, private readonly string $size = self::SizeMd, private readonly ?string $icon = null) | |
static new(string $text): self | Create a new badge. |
static success(string $text): self | Create a success badge. |
static warning(string $text): self | Create a warning badge. |
static error(string $text): self | Create an error badge. |
static danger(string $text): self | Create a danger badge. |
static info(string $text): self | Create an info badge. |
static bool(?bool $value, string $yes = 'Yes', string $no = 'No', string $unknown = 'Unknown'): self | Create a boolean badge: true → success (Yes), false → error (No), null → a subtle "Unknown" badge. |
static tristate(?bool $value): self | Create a tri-state checkbox glyph badge: true → "[x]" (green), false → "[ ]" (subdued), null → "[~]" (amber). Rendered as the bare glyph (subtle style) so it can sit inline in a toggle list. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this badge. |
innerSize(): array | Calculate the natural dimensions of this badge. |
render(): string | Render the badge. |
withBgColor(?Color $color): self | Set the background color. |
withTextColor(?Color $color): self | Set the text color. |
withStyle(string $style): self | Set the style. |
withSize(string $size): self | Set the size. |
withIcon(?string $icon): self | Set the icon. |
withTheme(Theme $theme): self | Apply a theme to this badge, using the theme's primary color. |
rect(): Rect | |
setRect(Rect $rect): self | |
draw(Buffer $buffer): void |
BadgeGroup final class
A group of badges displayed in a row.
| Method | Summary |
|---|---|
__construct(array $badges = [], private readonly int $gap = 1, private readonly bool $wrap = false) | |
static fromLabels(array $labels): self | Create a new badge group from a list of labels. |
static success(array $labels): self | Create a styled badge group with success badges. |
static warning(array $labels): self | Create a styled badge group with warning badges. |
static danger(array $labels): self | Create a styled badge group with danger badges. |
static info(array $labels): self | Create a styled badge group with info badges. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this badge group. |
render(): string | Render the badge group as a string. |
innerSize(): array | Calculate the natural dimensions of this badge group. |
withBadges(array $badges): self | Set the badges in this group. |
withAppended(Badge $badge): self | Add a badge to this group. |
withGap(int $gap): self | Set the gap between badges. |
withWrap(bool $wrap): self | Set the wrap behavior. |
BorderText final class
Text with ASCII-art style border characters.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item|string $content, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly string $style = 'single', private readonly int $topPadding = 0, private readonly int $bottomPadding = 0) | |
static new(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a new border text component. |
static withBorders(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create with a top and bottom border. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this component. |
render(): string | Render the bordered text. |
innerSize(): array | Calculate the natural dimensions. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withStyle(string $style): self | Set the border style. |
withPadding(int $top, int $bottom): self | Set the top and bottom padding. |
withContent(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Set the content. |
BoxDrawing final class
Box drawing frame generator using Unicode box-drawing characters.
| Method | Summary |
|---|---|
__construct(private readonly ?string $title = null, private readonly ?string $subtitle = null, private readonly ?Color $borderColor = null, private readonly ?Color $bgColor = null, private readonly string $style = 'single', private readonly bool $showTopBorder = true, private readonly bool $showBottomBorder = true, private readonly bool $showLeftBorder = true, private readonly bool $showRightBorder = true, private readonly bool $showTitleBar = false, private readonly bool $showSubtitleBar = false) | |
static new(?string $title = null): self | Create a new box drawing component. |
static titled(string $title): self | Create a box with a title. |
static double(?string $title = null): self | Create a double-line box. |
static rounded(?string $title = null): self | Create a rounded box. |
static bold(?string $title = null): self | Create a bold box. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this component. |
render(): string | Render the box drawing. |
innerSize(): array | Calculate the natural dimensions. |
withTitle(?string $title): self | Set the title. |
withSubtitle(?string $subtitle): self | Set the subtitle. |
withBorderColor(?Color $color): self | Set the border color. |
withBgColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
withBorders(?bool $top = null, ?bool $bottom = null, ?bool $left = null, ?bool $right = null): self | Show/hide specific borders. |
Bullet final class
A horizontal bullet chart component.
| Method | Summary |
|---|---|
__construct(private readonly float $actual, private readonly float $target, private readonly ?int $widthConstraint = null, private readonly bool $showTarget = true, private readonly bool $showComparative = false, private readonly ?float $comparative = null, private readonly ?Color $actualColor = null, private readonly ?Color $targetColor = null, private readonly ?Color $comparativeColor = null, private readonly ?Color $backgroundColor = null, private readonly string $filledChar = '█', private readonly string $emptyChar = '░', private readonly string $targetChar = '│', private readonly string $comparativeChar = '─') | |
static new(float $actual, float $target): self | Create a new bullet chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this bullet chart. |
render(): string | Render the bullet chart as a string. |
innerSize(): array | Calculate the natural dimensions of this bullet chart. |
withActual(float $actual): self | Set the actual value. |
withTarget(float $target): self | Set the target value. |
withWidth(int $width): self | Set the width constraint. |
withShowTarget(bool $show): self | Show or hide the target marker. |
withShowComparative(bool $show): self | Show or hide the comparative measure. |
withComparative(?float $value): self | Set the comparative value. |
withActualColor(?Color $color): self | Set the actual value color. |
withTargetColor(?Color $color): self | Set the target color. |
withComparativeColor(?Color $color): self | Set the comparative color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withChars(string $filled, string $empty): self | Set custom characters for filled and empty portions. |
CTA final class
A call-to-action button component.
| Method | Summary |
|---|---|
__construct(private readonly string $label = 'Get Started', private readonly string $description = '', private readonly ?Color $bgColor = null, private readonly ?Color $textColor = null, private readonly ?Color $borderColor = null, private readonly string $borderChar = '═', private readonly string $style = 'rounded', private readonly bool $showArrow = true) | |
static new(string $label, string $description = ''): self | Create a new CTA button with default styling. |
static primary(string $label, string $description = ''): self | Create a primary CTA button. |
static success(string $label, string $description = ''): self | Create a success CTA button. |
static danger(string $label, string $description = ''): self | Create a danger/warning CTA button. |
static outline(string $label, string $description = ''): self | Create an outline style CTA button. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this CTA. |
render(): string | Render the CTA as a string. |
innerSize(): array | Calculate the natural dimensions of this CTA. |
withLabel(string $label): self | Set the button label. |
withDescription(string $description): self | Set the description text. |
withBgColor(?Color $color): self | Set the background color. |
withTextColor(?Color $color): self | Set the text color. |
withBorderColor(?Color $color): self | Set the border color. |
withBorderChar(string $char): self | Set the border character. |
withStyle(string $style): self | Set the button style. |
withShowArrow(bool $show): self | Show or hide the arrow. |
Card final class
A card / container component with optional header and footer.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item|string $content, private readonly ?string $title = null, private readonly \SugarCraft\Dashboard\Foundation\Item|string|null $footer = null, private readonly ?Color $borderColor = null, private readonly ?Color $titleColor = null, private readonly string $style = 'single', private readonly int $padding = 1) | |
static new(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a new card with default styling. |
static titled(\SugarCraft\Dashboard\Foundation\Item|string $content, string $title): self | Create a card with a title (factory method). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this card. |
render(): string | Render the card as a string. |
innerSize(): array | Calculate the natural dimensions of this card. |
withContent(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Set the card content. |
withTitle(?string $title): self | Set the card title. |
withFooter(\SugarCraft\Dashboard\Foundation\Item|string|null $footer): self | Set the card footer. |
withBorderColor(?Color $color): self | Set the border color. |
withTitleColor(?Color $color): self | Set the title color. |
withStyle(string $style): self | Set the border style. |
withPadding(int $padding): self | Set the content padding. |
withTheme(Theme $theme): self | Apply a theme to this card, using the theme's primary color for border and title. |
rect(): Rect | |
setRect(Rect $rect): self | |
draw(Buffer $buffer): void |
Chip final class
A chip component for compact, selectable items.
| Method | Summary |
|---|---|
__construct(private readonly string $label, private readonly ?Color $foregroundColor = null, private readonly ?Color $backgroundColor = null, private readonly bool $selected = false, private readonly bool $deletable = false, private readonly string $deleteIcon = '×') | |
static new(string $label): self | Create a new chip with default styling. |
static primary(string $label): self | Create a primary-style chip. |
static success(string $label): self | Create a success-style chip. |
static warning(string $label): self | Create a warning-style chip. |
static danger(string $label): self | Create a danger-style chip. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chip. |
render(): string | Render the chip as a string. |
innerSize(): array | Calculate the natural dimensions of this chip. |
withLabel(string $label): self | Set the chip label. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withSelected(bool $selected): self | Set the selected state. |
withDeletable(bool $deletable): self | Set the deletable state. |
withDeleteIcon(string $icon): self | Set the delete icon character. |
ChipGroup final class
A group of chips displayed in a row.
| Method | Summary |
|---|---|
__construct(array $chips = [], private readonly int $gap = 1, private readonly bool $wrap = false) | |
static fromLabels(array $labels): self | Create a new chip group from a list of labels. |
static primary(array $labels): self | Create a styled chip group with primary chips. |
static success(array $labels): self | Create a styled chip group with success chips. |
static warning(array $labels): self | Create a styled chip group with warning chips. |
static danger(array $labels): self | Create a styled chip group with danger chips. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chip group. |
render(): string | Render the chip group as a string. |
innerSize(): array | Calculate the natural dimensions of this chip group. |
withChips(array $chips): self | Set the chips in this group. |
withAppended(Chip $chip): self | Add a chip to this group. |
withGap(int $gap): self | Set the gap between chips. |
withWrap(bool $wrap): self | Set the wrap behavior. |
Code final class
A code block / snippet display component.
| Method | Summary |
|---|---|
__construct(private readonly string $code, private readonly ?string $language = null, private readonly ?int $maxWidth = null, private readonly bool $wordWrap = true, private readonly HAlign $horizontalAlign = HAlign::Left, private readonly ?Color $backgroundColor = null, private readonly ?Color $textColor = null, private readonly ?Color $borderColor = null, private readonly ?Color $languageColor = null) | |
static new(string $code, ?string $language = null): self | Create a new code block with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this code block. |
render(): string | Render the code block as a string. |
innerSize(): array | Calculate the natural dimensions of this code block. |
withLanguage(?string $language): self | Set the language label. |
withMaxWidth(?int $maxWidth): self | Set the maximum width for word-wrapping. |
withWordWrap(bool $wordWrap): self | Enable or disable word-wrapping. |
withHorizontalAlign(HAlign $align): self | Set the horizontal alignment. |
withBackgroundColor(?Color $color): self | Set the background color. |
withTextColor(?Color $color): self | Set the text color. |
withBorderColor(?Color $color): self | Set the border color. |
withLanguageColor(?Color $color): self | Set the language label color. |
withCode(string $code): self | Set new code content. |
Comment final class
A comment/note display component.
| Method | Summary |
|---|---|
__construct(private readonly string $author, private readonly string $body, private readonly ?string $timestamp = null, private readonly ?Avatar $avatar = null, private readonly bool $isReply = false, private readonly bool $isEdited = false, private readonly ?Color $headerColor = null) | |
static new(string $author, string $body): self | Create a new comment. |
static reply(string $author, string $body): self | Create a reply comment. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this comment. |
render(): string | Render the comment as a string. |
innerSize(): array | Calculate the natural dimensions of this comment. |
withAuthor(string $author): self | Set the author name. |
withBody(string $body): self | Set the comment body. |
withTimestamp(?string $timestamp): self | Set the timestamp. |
withAvatar(?Avatar $avatar): self | Set the avatar. |
withIsReply(bool $isReply): self | Set the reply flag. |
withIsEdited(bool $isEdited): self | Set the edited flag. |
withHeaderColor(?Color $color): self | Set the header color. |
Cover final class
A full coverage layout component.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly HAlign $horizontalAlign = HAlign::Center, private readonly VAlign $verticalAlign = VAlign::Middle) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new cover layout with the given content. |
static topLeft(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a cover layout aligned to the top-left corner. |
static topRight(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a cover layout aligned to the top-right corner. |
static bottomLeft(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a cover layout aligned to the bottom-left corner. |
static bottomRight(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a cover layout aligned to the bottom-right corner. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this cover layout. |
render(): string | Render the cover layout - content fills the entire space. |
innerSize(): array | Calculate the natural dimensions of this layout. |
withAlignment(HAlign $horizontalAlign): self | Set the horizontal alignment. |
withVerticalAlign(VAlign $verticalAlign): self | Set the vertical alignment. |
withContent(\SugarCraft\Dashboard\Foundation\Item $content): self | Set the content. |
DefinitionList final class
A definition list: aligned label : value rows with a placeholder for missing values.
| Method | Summary |
|---|---|
__construct(private readonly array $rows = [], private readonly string $separator = ' : ', private readonly string $placeholder = '—', private readonly ?Color $labelColor = null, private readonly ?Color $valueColor = null, private readonly ?Color $placeholderColor = null) | |
static new(): self | Create an empty definition list with default styling. |
static fromMap(array $items): self | Create a definition list from a label => value map. |
row(string $label, ?string $value): self | Append a label/value row. A null value renders as the placeholder. |
withRows(array $rows): self | Replace all rows. |
withSeparator(string $separator): self | Set the label/value separator (default " : "). |
withPlaceholder(string $placeholder): self | Set the placeholder shown for null values (default "—"). |
withLabelColor(?Color $color): self | Set the label color. |
withValueColor(?Color $color): self | Set the value color. |
withPlaceholderColor(?Color $color): self | Set the color used for the null placeholder. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this list. |
innerSize(): array | Calculate the natural dimensions of this list. |
render(): string | Render the definition list, one row per line. |
Diff final class
A text diff display component.
| Method | Summary |
|---|---|
__construct(private readonly string $oldText, private readonly string $newText, private readonly bool $showLineNumbers = true, private readonly bool $showContext = true, private readonly int $contextLines = 3, private readonly ?Color $addedColor = null, private readonly ?Color $removedColor = null, private readonly ?Color $unchangedColor = null) | |
static new(string $oldText, string $newText): self | Create a new diff with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this diff. |
render(): string | Render the diff. |
innerSize(): array | Calculate the natural dimensions of this diff. |
stats(): array | Get statistics about the diff. |
getStats(): array | BC forwarder for the pre-rename accessor name. |
withLineNumbers(bool $show): self | Show or hide line numbers. |
withContext(bool $show): self | Show or hide context lines. |
withContextLines(int $count): self | Set the context line count. |
withAddedColor(?Color $color): self | Set the color for added lines. |
withRemovedColor(?Color $color): self | Set the color for removed lines. |
Divider final class
A divider line component.
| Method | Summary |
|---|---|
__construct(private readonly ?string $label = null, private readonly string $style = self::StyleSolid, private readonly ?Color $color = null, private readonly bool $horizontal = true, private readonly int $thickness = 1) | |
static new(?string $label = null): self | Create a new divider. |
static h(?string $label = null): self | Create a horizontal divider. |
static v(?string $label = null): self | Create a vertical divider. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this divider. |
innerSize(): array | Calculate the natural dimensions of this divider. |
render(): string | Render the divider. |
withStyle(string $style): self | Set the style. |
withColor(?Color $color): self | Set the color. |
withLabel(?string $label): self | Set the label. |
withHorizontal(bool $horizontal): self | Set horizontal orientation. |
withThickness(int $thickness): self | Set the thickness. |
Features final class
A features grid display component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly int $columns = 3, private readonly ?Color $iconColor = null, private readonly ?Color $titleColor = null, private readonly ?Color $descriptionColor = null, private readonly ?Color $borderColor = null, private readonly string $borderChar = '│') | |
static new(array $features): self | Create a new features grid with default styling. |
static compact(array $features): self | Create a compact features grid with 2 columns. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this features grid. |
render(): string | Render the features grid as a string. |
innerSize(): array | Calculate the natural dimensions of this features grid. |
withItems(array $items): self | Set the feature items. |
withColumns(int $columns): self | Set the number of columns. |
withIconColor(?Color $color): self | Set the icon color. |
withTitleColor(?Color $color): self | Set the title color. |
withDescriptionColor(?Color $color): self | Set the description color. |
withBorderColor(?Color $color): self | Set the border color. |
withBorderChar(string $char): self | Set the border character. |
Footer final class
A page footer component.
| Method | Summary |
|---|---|
__construct(private readonly string $content = '', HAlign|string $align = HAlign::Left, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly ?Color $bgColor = null, private readonly string $borderPosition = 'top') | |
static new(string $content = ''): self | Create a new footer with default styling. |
static copyright(string $holder = '', ?int $year = null): self | Create a footer with copyright notice. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this footer. |
render(): string | Render the footer as a string. |
innerSize(): array | Calculate the natural dimensions of this footer. |
withContent(string $content): self | Set the footer content. |
withAlign(HAlign|string $align): self | Set the text alignment (HAlign case; legacy strings accepted with a deprecation notice). |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withBgColor(?Color $color): self | Set the background color. |
withBorderPosition(string $position): self | Set the border position. |
Header final class
A page header component for displaying titles and subtitles.
| Method | Summary |
|---|---|
__construct(private readonly string $title = '', private readonly string $subtitle = '', HAlign|string $alignment = HAlign::Left, private readonly ?Color $titleColor = null, private readonly ?Color $subtitleColor = null, private readonly ?Color $borderColor = null, private readonly bool $showDivider = false) | |
static new(string $title = ''): self | Create a new header with default styling. |
static centered(string $title): self | Create a centered header. |
static hero(string $title, string $subtitle = ''): self | Create a large hero header with title and subtitle. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this header. |
render(): string | Render the header as a string. |
innerSize(): array | Calculate the natural dimensions of this header. |
withTitle(string $title): self | Set the header title. |
withSubtitle(string $subtitle): self | Set the header subtitle. |
withAlignment(HAlign|string $alignment): self | Set the alignment (HAlign case; legacy strings accepted with a deprecation notice). |
withTitleColor(?Color $color): self | Set the title color. |
withSubtitleColor(?Color $color): self | Set the subtitle color. |
withBorderColor(?Color $color): self | Set the border/divider color. |
withDivider(bool $show = true): self | Show a divider line below the header. |
Highlight final class
A syntax highlighting component for code display.
| Method | Summary |
|---|---|
__construct(private readonly string $code, private readonly string $language = self::LANG_TEXT, private readonly bool $lineNumbers = false, private readonly string $theme = self::THEME_DEFAULT, private readonly ?array $highlightedLines = null, private readonly int $tabWidth = 4) | |
static new(string $code = ''): self | Create a new highlight component with default settings. |
static php(string $code): self | Create a new highlight component with PHP code. |
static js(string $code): self | Create a new highlight component with JavaScript code. |
static python(string $code): self | Create a new highlight component with Python code. |
static bash(string $code): self | Create a new highlight component with Bash code. |
static json(string $code): self | Create a new highlight component with JSON. |
static monokai(string $code, string $language = self::LANG_TEXT): self | Create with Monokai theme. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this highlight component. |
render(): string | Render the highlighted code as a string. |
innerSize(): array | Calculate the natural dimensions of this highlight component. |
withCode(string $code): self | Set the code content. |
withLanguage(string $language): self | Set the language. |
withLineNumbers(bool $show): self | Set line numbers visibility. |
withTheme(string $theme): self | Set the color theme. |
withHighlightedLines(?array $lines): self | Set highlighted lines. |
withTabWidth(int $width): self | Set the tab width. |
Jumbotron final class
A hero/jumbotron section component.
| Method | Summary |
|---|---|
__construct(private readonly string $title = '', private readonly string $subtitle = '', private readonly string $buttonText = '', private readonly string $alignment = 'center', private readonly ?Color $titleColor = null, private readonly ?Color $subtitleColor = null, private readonly ?Color $buttonColor = null, private readonly ?Color $borderColor = null, private readonly bool $showBorder = true, private readonly bool $showShadow = false) | |
static new(string $title, string $subtitle = ''): self | Create a new jumbotron with default styling. |
static withButton(string $title, string $subtitle, string $buttonText): self | Create a jumbotron with a call-to-action button. |
static minimal(string $title, string $subtitle = ''): self | Create a minimal jumbotron without borders. |
static left(string $title, string $subtitle = ''): self | Create a left-aligned jumbotron. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this jumbotron. |
render(): string | Render the jumbotron as a string. |
innerSize(): array | Calculate the natural dimensions of this jumbotron. |
withTitle(string $title): self | Set the title. |
withSubtitle(string $subtitle): self | Set the subtitle. |
withButtonText(string $buttonText): self | Set the button text. |
withAlignment(string $alignment): self | Set the alignment. |
withTitleColor(?Color $color): self | Set the title color. |
withSubtitleColor(?Color $color): self | Set the subtitle color. |
withButtonColor(?Color $color): self | Set the button color. |
withBorderColor(?Color $color): self | Set the border color. |
withBorder(bool $show): self | Toggle border visibility. |
withShadow(bool $show): self | Toggle shadow effect. |
Kbd final class
A keyboard key display component.
| Method | Summary |
|---|---|
__construct(private readonly array $keys, private readonly ?Color $bgColor = null, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly bool $showShadow = true, private readonly bool $rounded = true) | |
static new(array $keys): self | Create a new key display. |
static single(string $key): self | Create a single key display. |
static combo(string ...$keys): self | Create a key combination display. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this key display. |
innerSize(): array | Calculate the natural dimensions of this key display. |
render(): string | Render the key display. |
withBgColor(?Color $color): self | Set the background color. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withShowShadow(bool $show): self | Show or hide shadow. |
withRounded(bool $rounded): self | Set rounded corners. |
Label final class
A form label component.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly bool $required = false, private readonly ?string $helpText = null, private readonly ?Color $color = null, private readonly string $requiredIndicator = ' *') | |
static new(string $text): self | Create a new label with default styling. |
static required(string $text): self | Create a required label. |
static withHelp(string $text, string $helpText): self | Create a label with help text. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this label. |
render(): string | Render the label as a string. |
innerSize(): array | Calculate the natural dimensions of this label. |
withText(string $text): self | Set the label text. |
withRequired(bool $required): self | Set the required state. |
withHelpText(?string $helpText): self | Set the help text. |
withColor(?Color $color): self | Set the label color. |
withRequiredIndicator(string $indicator): self | Set the required indicator text. |
Leaderboard final class
A leaderboard component for displaying ranked items.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly string $rankStyle = 'number', private readonly int $topHighlight = 3, private readonly bool $showValue = true, private readonly bool $showTrend = false, private readonly ?Color $highlightColor = null, private readonly ?Color $valueColor = null, private readonly string $valueFormat = 'number') | |
static new(array $items = []): self | Create a new leaderboard. |
static sample(): self | Create a sample leaderboard for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this leaderboard. |
render(): string | Render the leaderboard. |
innerSize(): array | Calculate the natural dimensions of this leaderboard. |
withRankStyle(string $style): self | Set the rank style. |
withTopHighlight(int $count): self | Set the top highlight count. |
withValueFormat(string $format): self | Set the value format. |
withShowValue(bool $show): self | Show or hide values. |
withShowTrend(bool $show): self | Show or hide trend indicators. |
withHighlightColor(?Color $color): self | Set the highlight color for top items. |
withValueColor(?Color $color): self | Set the value color. |
Markdown final class
A markdown rendering component for text display.
| Method | Summary |
|---|---|
__construct(private readonly string $content, private readonly string $theme = self::THEME_DEFAULT, private readonly bool $enableLinks = true, private readonly bool $enableCodeHighlighting = true) | |
static new(string $content): self | Create a new markdown component with default theme. |
static monokai(string $content): self | Create with Monokai theme. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this markdown component. |
render(): string | Render the markdown as a string. |
innerSize(): array | Calculate the natural dimensions of this markdown component. |
withContent(string $content): self | Set the markdown content. |
withTheme(string $theme): self | Set the color theme. |
withEnableLinks(bool $enable): self | Set link rendering. |
withEnableCodeHighlighting(bool $enable): self | Set code highlighting. |
Metric final class
A single metric/number display component.
| Method | Summary |
|---|---|
__construct(private readonly float $value, private readonly ?string $label = null, private readonly ?int $widthConstraint = null, private readonly MetricTrend $trend = MetricTrend::Neutral, private readonly ?int $decimals = null, private readonly bool $showTrend = true, private readonly ?Color $valueColor = null, private readonly ?Color $labelColor = null, private readonly ?Color $trendColor = null, private readonly string $trendSpacing = ' ', private readonly HAlign $horizontalAlign = HAlign::Center) | |
static new(float $value, ?string $label = null): self | Create a new metric with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this metric. |
render(): string | Render the metric as a string. |
innerSize(): array | Calculate the natural dimensions of this metric. |
withValue(float $value): self | Set a new value. |
withLabel(?string $label): self | Set the label. |
withWidth(int $width): self | Set the width constraint. |
withTrend(MetricTrend $trend): self | Set the trend direction. |
withDecimals(?int $decimals): self | Set the number of decimal places. |
withShowTrend(bool $show): self | Show or hide the trend indicator. |
withValueColor(?Color $color): self | Set the value color. |
withLabelColor(?Color $color): self | Set the label color. |
withTrendColor(?Color $color): self | Set the trend color. |
withTrendSpacing(string $spacing): self | Set the spacing between trend symbol and value. |
withHorizontalAlign(HAlign $align): self | Set the horizontal alignment. |
MetricCard final readonly class
A metric card for the metrics grid.
| Method | Summary |
|---|---|
__construct(public string $label, public ?string $value = null, public ?string $trendValue = null, public ?string $trend = null, public ?Color $color = null) | |
static fromNumber(string $label, float $number, int $decimalPlaces = 0): self | Create a card from a number value. |
static percent(string $label, float $value): self | Create a percentage card. |
static currency(string $label, float $value, string $symbol = '$'): self | Create a currency card. |
MetricTrend enum
Trend direction for metrics.
Cases: Up · Down · Neutral
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
symbol(): string | Get the symbol for this trend. |
defaultColor(): Color | Get the default color for this trend. |
static fromDelta(float $delta, float $threshold = 0.0): self | Determine trend from a delta value. |
MetricsGrid final class
A metrics grid component for displaying a grid of stat cards.
| Method | Summary |
|---|---|
__construct(private readonly array $metrics = [], private readonly int $columns = 3, private readonly bool $showTrends = true, private readonly bool $showLabels = true, private readonly bool $compact = false, private readonly ?Color $borderColor = null, private readonly ?Color $valueColor = null, private readonly ?Color $labelColor = null) | |
static new(array $metrics = []): self | Create a new metrics grid. |
static sample(): self | Create a sample metrics grid for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this grid. |
render(): string | Render the metrics grid. |
innerSize(): array | Calculate the natural dimensions of this grid. |
withMetrics(array $metrics): self | Set the metrics. |
withColumns(int $columns): self | Set the number of columns. |
withShowTrends(bool $show): self | Show or hide trends. |
withShowLabels(bool $show): self | Show or hide labels. |
withCompact(bool $compact): self | Set compact mode. |
Paragraph final class
A paragraph component with styled line spacing and margins.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly ?int $maxWidth = null, private readonly bool $trim = true, private readonly HAlign $horizontalAlign = HAlign::Left, private readonly float $leading = 1.0, private readonly int $marginTop = 0, private readonly int $marginBottom = 0, private readonly VAlign $verticalAlign = VAlign::Top) | |
static new(string $text): self | Create a new paragraph with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this paragraph. |
render(): string | Render the paragraph with styling applied. |
innerSize(): array | Calculate the natural dimensions of this paragraph when rendered. |
withMaxWidth(int $maxWidth): self | Set a maximum width for word-wrapping. |
withTrim(bool $trim): self | Enable or disable whitespace trimming. |
withHorizontalAlign(HAlign $align): self | Set the horizontal alignment. |
withLeading(float $leading): self | Set the leading (line spacing multiplier). |
withMarginTop(int $margin): self | Set the top margin (number of blank lines before content). |
withMarginBottom(int $margin): self | Set the bottom margin (number of blank lines after content). |
withVerticalAlign(VAlign $align): self | Set the vertical alignment within allocated height. |
withText(string $text): self | Set new text content. |
Pricing final class
A pricing table component.
| Method | Summary |
|---|---|
__construct(private readonly array $plans = [], private readonly ?Color $headerColor = null, private readonly ?Color $priceColor = null, private readonly ?Color $borderColor = null, private readonly ?Color $highlightColor = null, private readonly ?Color $featureColor = null, private readonly bool $showBorders = true) | |
static new(array $plans): self | Create a new pricing table with default styling. |
static compact(array $plans): self | Create a compact pricing display. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this pricing table. |
render(): string | Render the pricing table as a string. |
innerSize(): array | Calculate the natural dimensions of this pricing table. |
withPlans(array $plans): self | Set the pricing plans. |
withHeaderColor(?Color $color): self | Set the header color. |
withPriceColor(?Color $color): self | Set the price color. |
withBorderColor(?Color $color): self | Set the border color. |
withHighlightColor(?Color $color): self | Set the highlight color (for recommended plan). |
withFeatureColor(?Color $color): self | Set the feature text color. |
withBorders(bool $show): self | Toggle border visibility. |
Profile final class
A user profile card component.
| Method | Summary |
|---|---|
__construct(private readonly string $name = '', private readonly string $role = '', private readonly string $bio = '', private readonly ?string $avatar = null, private readonly ?string $email = null, private readonly ?string $location = null, private readonly ?Color $avatarBgColor = null, private readonly ?Color $nameColor = null, private readonly ?Color $roleColor = null, private readonly ?Color $bioColor = null, private readonly ?Color $borderColor = null, private readonly string $layout = 'vertical') | |
static new(string $name, string $role, string $bio = '', ?string $avatar = null): self | Create a new profile card with default styling. |
static horizontal(string $name, string $role, string $bio = '', ?string $avatar = null): self | Create a horizontal layout profile card. |
static compact(string $name, string $role, ?string $avatar = null): self | Create a compact profile card. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this profile. |
render(): string | Render the profile card as a string. |
innerSize(): array | Calculate the natural dimensions of this profile. |
withName(string $name): self | Set the name. |
withRole(string $role): self | Set the role. |
withBio(string $bio): self | Set the bio. |
withAvatar(?string $avatar): self | Set the avatar. |
withEmail(?string $email): self | Set the email. |
withLocation(?string $location): self | Set the location. |
withAvatarBgColor(?Color $color): self | Set the avatar background color. |
withNameColor(?Color $color): self | Set the name color. |
withRoleColor(?Color $color): self | Set the role color. |
withBioColor(?Color $color): self | Set the bio color. |
withBorderColor(?Color $color): self | Set the border color. |
withLayout(string $layout): self | Set the layout. |
Stat final class
A single stat display component showing a label and value.
| Method | Summary |
|---|---|
__construct(private readonly ?string $label, private readonly ?string $value, private readonly ?string $subLabel = null, private readonly ?Color $valueColor = null, private readonly ?Color $labelColor = null, private readonly ?string $trend = null, private readonly HAlign $align = HAlign::Left, private readonly int $decimalPlaces = 0) | |
static new(?string $label = null, ?string $value = null): self | Create a new stat display. |
static number(?string $label, float $value, int $decimalPlaces = 0): self | Create a stat from a number. |
static percent(?string $label, float $value): self | Create a percentage stat. |
static currency(?string $label, float $value, string $symbol = '$'): self | Create a currency stat. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stat. |
innerSize(): array | Calculate the natural dimensions of this stat. |
render(): string | Render the stat display. |
withLabel(?string $label): self | Set the label. |
withValue(?string $value): self | Set the value. |
withSubLabel(?string $subLabel): self | Set the sub-label. |
withValueColor(?Color $color): self | Set the value color. |
withLabelColor(?Color $color): self | Set the label color. |
withTrend(?string $trend): self | Set the trend indicator. |
withAlign(HAlign $align): self | Set the alignment. |
withDecimalPlaces(int $places): self | Set decimal places for number formatting. |
Stats final class
A statistics display component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly ?Color $labelColor = null, private readonly ?Color $valueColor = null, private readonly ?Color $separatorColor = null, private readonly string $separator = '│', private readonly string $alignment = 'left') | |
static new(array $stats): self | Create a new stats row with default styling. |
static horizontal(array $stats): self | Create a horizontal divider-style stats row. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stats row. |
render(): string | Render the stats row as a string. |
innerSize(): array | Calculate the natural dimensions of this stats row. |
withItems(array $items): self | Set the stats items. |
withLabelColor(?Color $color): self | Set the label color. |
withValueColor(?Color $color): self | Set the value color. |
withSeparatorColor(?Color $color): self | Set the separator color. |
withSeparator(string $separator): self | Set the separator character. |
withAlignment(string $alignment): self | Set the alignment. |
Tag final class
A tag / chip component for displaying labels and metadata.
| Method | Summary |
|---|---|
__construct(private readonly string $label, private readonly ?Color $foregroundColor = null, private readonly ?Color $backgroundColor = null, private readonly string $style = 'solid', private readonly string $icon = '') | |
static new(string $label): self | Create a new tag with default styling. |
static success(string $label): self | Create a success-style tag. |
static warning(string $label): self | Create a warning-style tag. |
static danger(string $label): self | Create a danger-style tag. |
static info(string $label): self | Create an info-style tag. |
static soft(string $label, Color $backgroundColor): self | Create a soft-style tag (lighter background). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this tag. |
render(): string | Render the tag as a string. |
innerSize(): array | Calculate the natural dimensions of this tag. |
withLabel(string $label): self | Set the tag label. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the tag style. |
withIcon(string $icon): self | Set the icon prefix. |
Testimonial final class
A testimonial quote display component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly ?Color $quoteColor = null, private readonly ?Color $authorColor = null, private readonly ?Color $roleColor = null, private readonly ?Color $accentColor = null, private readonly string $openQuote = '「', private readonly string $closeQuote = '」') | |
static new(array $testimonials): self | Create a new testimonial with default styling. |
static single(array $testimonial): self | Create a single testimonial with centered styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this testimonial. |
render(): string | Render the testimonial as a string. |
innerSize(): array | Calculate the natural dimensions of this testimonial. |
withItems(array $items): self | Set the testimonial items. |
withQuoteColor(?Color $color): self | Set the quote text color. |
withAuthorColor(?Color $color): self | Set the author name color. |
withRoleColor(?Color $color): self | Set the role/company color. |
withAccentColor(?Color $color): self | Set the accent/border color. |
withQuoteChars(string $open, string $close): self | Set the quote characters. |
Text final class
Word-wrapped text content component.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly ?int $maxWidth = null, private readonly bool $trim = true, private readonly HAlign $horizontalAlign = HAlign::Left) | |
static new(string $text): self | Create a new text component. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this text. |
render(): string | Render the text, word-wrapped to the allocated width. |
innerSize(): array | Calculate the natural dimensions of this text when rendered. |
withMaxWidth(int $maxWidth): self | Set a maximum width for word-wrapping. |
withTrim(bool $trim): self | Enable or disable whitespace trimming. |
withHorizontalAlign(HAlign $align): self | Set the horizontal alignment. |
withText(string $text): self | Set new text content. |
Transformer final class
Text case transformation component.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly string $transform = self::Upper) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new transformer with uppercase transformation. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this transformer. |
render(): string | Render the transformed text. |
innerSize(): array | Calculate the natural dimensions of this transformer when rendered. |
withUpper(): self | Set uppercase transformation (all characters uppercase). |
withLower(): self | Set lowercase transformation (all characters lowercase). |
withTitle(): self | Set title case transformation (first letter uppercase, rest lowercase). |
withUpperFirst(): self | Set upper-first transformation (first char of text uppercase, rest lowercase). |
withUpperWords(): self | Set upper-words transformation (first char of each word uppercase, rest lowercase). |
SugarCraft\Dashboard\Components\Feedback
Alert final class
A non-modal alert feedback component.
| Method | Summary |
|---|---|
__construct(private readonly string $message = '', private readonly string $level = self::Info, private readonly ?string $title = null, private readonly ?Color $color = null, private readonly ?string $borderChar = null) | |
static new(string $message = ''): self | Create a new alert with the given message. |
static info(string $message): self | Create a new info alert. |
static success(string $message): self | Create a new success alert. |
static warning(string $message): self | Create a new warning alert. |
static error(string $message): self | Create a new error alert. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this alert. |
render(): string | Render the alert as a string. |
innerSize(): array | Calculate the natural dimensions of this alert. |
withMessage(string $message): self | Set the alert message. |
withLevel(string $level): self | Set the alert level. |
withTitle(?string $title): self | Set the alert title. |
withColor(?Color $color): self | Set the alert color. |
withBorderColor(?Color $color): self | Set the border color. |
withBorderChar(string $char): self | Set the border character. |
withBackgroundColor(?Color $color): self | Set the background color. |
EmptyState final class
An empty state placeholder component.
| Method | Summary |
|---|---|
__construct(private readonly string $icon = '📭', private readonly string $title = 'Nothing here yet', private readonly ?string $description = null, private readonly ?string $action = null, private readonly ?Color $iconColor = null, private readonly ?Color $titleColor = null, private readonly ?Color $descriptionColor = null) | |
static new(): self | Create a new empty state with default message. |
static noResults(): self | Create an empty state for no results. |
static error(): self | Create an empty state for errors. |
static noData(): self | Create an empty state for no data. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this empty state. |
render(): string | Render the empty state as a string. |
innerSize(): array | Calculate the natural dimensions of this empty state. |
withIcon(string $icon): self | Set the icon. |
withTitle(string $title): self | Set the title. |
withDescription(?string $description): self | Set the description. |
withAction(?string $action): self | Set the action hint. |
withIconColor(?Color $color): self | Set the icon color. |
withTitleColor(?Color $color): self | Set the title color. |
withDescriptionColor(?Color $color): self | Set the description color. |
LoadingText final class
An animated loading text component with cycling dots.
| Method | Summary |
|---|---|
__construct(private readonly string $text = 'Loading', private readonly string $style = self::Dots, private readonly ?Color $color = null, private readonly int $interval = 300) | |
static new(string $text = 'Loading'): self | Create a new loading text with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this loading text. |
render(): string | Render the loading text at the current frame. |
currentFrame(): string | Get the current animation frame based on time. |
getCurrentFrame(): string | BC forwarder for the pre-rename accessor name. |
frameAt(int $index): string | Get the frame at a specific index (for deterministic testing). |
getFrameAt(int $index): string | BC forwarder for the pre-rename accessor name. |
innerSize(): array | Calculate the natural dimensions of this loading text. |
style(): string | Get the animation style. |
getStyle(): string | BC forwarder for the pre-rename accessor name. |
interval(): int | Get the animation interval in milliseconds. |
getInterval(): int | BC forwarder for the pre-rename accessor name. |
withText(string $text): self | Set the loading text. |
withStyle(string $style): self | Set the animation style. |
withColor(?Color $color): self | Set the text color. |
withInterval(int $interval): self | Set the animation interval in milliseconds. |
Skeleton final class
A loading skeleton component.
| Method | Summary |
|---|---|
__construct(private readonly int $lines = 3, private readonly ?Color $backgroundColor = null, private readonly ?Color $foregroundColor = null, array $lineWidths = [], private readonly string $fillChar = '█', private readonly string $emptyChar = ' ') | |
static new(int $lines = 3): self | Create a new skeleton with default settings. |
static text(int $lines = 3): self | Create a text-like skeleton. |
static avatar(): self | Create an avatar skeleton. |
static card(): self | Create a card skeleton. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this skeleton. |
render(): string | Render the skeleton as a string. |
innerSize(): array | Calculate the natural dimensions of this skeleton. |
withLines(int $lines): self | Set the number of lines. |
withLineWidths(array $widths): self | Set specific line widths. |
withBackgroundColor(?Color $color): self | Set the background color. |
withForegroundColor(?Color $color): self | Set the foreground (fill) color. |
withFillChar(string $char): self | Set the fill character. |
withEmptyChar(string $char): self | Set the empty character. |
Spinner final class
A loading spinner component that displays cycling animation frames.
| Method | Summary |
|---|---|
__construct(private readonly array $frames = self::DEFAULT_FRAMES, int $interval = 80, private readonly ?Color $color = null, private readonly string $message = '') | |
static new(): self | Create a new spinner with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this spinner. |
render(): string | Render the spinner at the current frame. |
currentFrame(): string | Get the current frame character. |
getCurrentFrame(): string | BC forwarder for the pre-rename accessor name. |
frameAt(int $index): string | Get the frame at a specific index (for testing/ deterministic output). |
getFrameAt(int $index): string | BC forwarder for the pre-rename accessor name. |
innerSize(): array | Calculate the natural dimensions of this spinner. |
frameCount(): int | Get the number of frames in the spinner. |
getFrameCount(): int | BC forwarder for the pre-rename accessor name. |
withFrames(array $frames): self | Set custom spinner frames. |
withInterval(int $interval): self | Set the spin interval in milliseconds. |
withColor(?Color $color): self | Set the spinner color. |
withMessage(string $message): self | Set the message displayed alongside the spinner. |
SugarCraft\Dashboard\Components\Form
Checkbox final class
A checkbox group component.
| Method | Summary |
|---|---|
__construct(private readonly array $options, private readonly int $selectedIndex = 0, private readonly bool $multiSelect = true, private readonly ?Color $checkedColor = null, private readonly ?Color $uncheckedColor = null, private readonly string $checkedChar = '◉', private readonly string $uncheckedChar = '○') | |
static new(array $options): self | Create a new checkbox group with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this checkbox group. |
render(): string | Render the checkbox group. |
innerSize(): array | Calculate the natural dimensions of this checkbox group. |
withSelectedIndex(int $index): self | Set the selected/focused option index. |
withOptionChecked(int $index, bool $checked): self | Toggle an option's checked state. |
withAllChecked(bool $checked): self | Set all options' checked state. |
withMultiSelect(bool $multiSelect): self | Set multi-select mode. |
withCheckedColor(?Color $color): self | Set the color for checked items. |
withUncheckedColor(?Color $color): self | Set the color for unchecked items. |
withChars(string $checked, string $unchecked): self | Set custom characters for checked and unchecked states. |
CommandPalette final class
A command palette component (Cmd+K style).
| Method | Summary |
|---|---|
__construct(private readonly array $commands, private readonly string $query = '', private readonly int $selectedIndex = 0, private readonly ?Color $paletteColor = null, private readonly ?Color $selectedColor = null, private readonly ?Color $queryColor = null, private readonly ?Color $shortcutColor = null, private readonly string $placeholder = 'Type a command...', private readonly string $borderChar = '─', private readonly string $selectedChar = '▶') | |
static new(array $commands): self | Create a new command palette with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this command palette. |
filteredCommands(): array | Get filtered commands based on the current query. |
getFilteredCommands(): array | BC forwarder for the pre-rename accessor name. |
render(): string | Render the command palette component. |
innerSize(): array | Calculate the natural dimensions of this command palette. |
withQuery(string $query): self | Set the search query. |
withSelectedIndex(int $index): self | Set the selected command index. |
withCommands(array $commands): self | Set the commands. |
withPaletteColor(?Color $color): self | Set the palette background color. |
withSelectedColor(?Color $color): self | Set the selected item highlight color. |
withQueryColor(?Color $color): self | Set the query text color. |
withShortcutColor(?Color $color): self | Set the shortcut text color. |
withPlaceholder(string $placeholder): self | Set the placeholder text. |
withBorderChar(string $char): self | Set custom border character. |
withSelectedChar(string $char): self | Set custom selected item character. |
Cursor final class
A cursor component that renders a cursor character at a fixed position.
| Method | Summary |
|---|---|
__construct(private readonly string $style = self::Block, private readonly ?Color $color = null, private readonly bool $visible = true) | |
static new(): self | Create a new cursor with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this cursor. |
cursorChar(): string | Get the cursor character based on the current style. |
getCursorChar(): string | BC forwarder for the pre-rename accessor name. |
render(): string | Render the cursor character. |
innerSize(): array | Calculate the natural dimensions of this cursor. |
withStyle(string $style): self | Set the cursor style (block, underline, bar). |
withColor(?Color $color): self | Set the cursor color. |
withVisible(bool $visible): self | Set cursor visibility (useful for blinking cursor implementations). |
CursorState enum
Cursor blinking states.
Cases: Visible · Hidden · Blink
PHP also provides cases().
Editor final class
A multi-line text editor component with cursor support.
| Method | Summary |
|---|---|
__construct(private readonly ?string $content = null, private readonly bool $showLineNumbers = true, private readonly bool $wordWrap = false, private readonly bool $readOnly = false, private readonly bool $showCursor = true, private readonly CursorState $cursorState = CursorState::Blink, private readonly ?Color $textColor = null, private readonly ?Color $lineNumberColor = null, private readonly ?Color $cursorColor = null, private readonly ?Color $selectionColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $borderColor = null, private readonly string $style = 'single') | |
static new(?string $content = null): self | Create a new editor with default styling. |
static forFile(?string $filepath = null): self | Create an editor for a file. |
content(): string | Get the content as a string. |
getContent(): string | BC forwarder for the pre-rename accessor name. |
line(int $index): string | Get a specific line. |
getLine(int $index): string | BC forwarder for the pre-rename accessor name. |
lineCount(): int | Get the number of lines. |
getLineCount(): int | BC forwarder for the pre-rename accessor name. |
cursorPosition(): array | Get the cursor position. |
getCursorPosition(): array | BC forwarder for the pre-rename accessor name. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this editor. |
render(): string | Render the editor as a string. |
innerSize(): array | Calculate the natural dimensions of this editor. |
withContent(?string $content): self | Set the content. |
withLineNumbers(bool $show): self | Show or hide line numbers. |
withWordWrap(bool $wrap): self | Enable or disable word wrap. |
withReadOnly(bool $readOnly): self | Set read-only mode. |
withShowCursor(bool $show): self | Show or hide cursor. |
withTextColor(?Color $color): self | Set the text color. |
withStyle(string $style): self | Set the border style. |
Input final class
A text input field component.
| Method | Summary |
|---|---|
__construct(private readonly ?string $value = null, private readonly ?string $placeholder = null, private readonly ?string $label = null, private readonly ?string $error = null, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly ?Color $placeholderColor = null, private readonly ?Color $backgroundColor = null, private readonly bool $masked = false, private readonly string $style = 'single') | |
static new(?string $value = null): self | Create a new input with default styling. |
static labeled(?string $value, string $label): self | Create an input with a label. |
static password(?string $value = null): self | Create a password input. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this input. |
render(): string | Render the input as a string. |
innerSize(): array | Calculate the natural dimensions of this input. |
withValue(?string $value): self | Set the input value. |
withPlaceholder(?string $placeholder): self | Set the placeholder text. |
withLabel(?string $label): self | Set the label text. |
withError(?string $error): self | Set the error message. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withPlaceholderColor(?Color $color): self | Set the placeholder color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withMasked(bool $masked): self | Set the masked state (for passwords). |
withStyle(string $style): self | Set the border style. |
withWidth(int $width): self | Set the input width. |
Rating final class
A star rating component.
| Method | Summary |
|---|---|
__construct(private readonly int $maxStars = 5, private readonly float $value = 0.0, private readonly ?Color $filledColor = null, private readonly ?Color $emptyColor = null, private readonly string $filledChar = '★', private readonly string $emptyChar = '☆') | |
static new(int $maxStars = 5, float $value = 0.0): self | Create a new rating with default styling. |
static of(float $value, int $maxStars = 5): self | Create a rating with a specific value. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this rating. |
render(): string | Render the rating as a string. |
innerSize(): array | Calculate the natural dimensions of this rating. |
withMaxStars(int $maxStars): self | Set the maximum number of stars. |
withValue(float $value): self | Set the rating value. |
withFilledColor(?Color $color): self | Set the filled star color. |
withEmptyColor(?Color $color): self | Set the empty star color. |
withChars(string $filled, string $empty): self | Set custom star characters. |
Slider final class
A slider / progress control component.
| Method | Summary |
|---|---|
__construct(private readonly float $value, private readonly float $min = 0.0, private readonly float $max = 100.0, private readonly bool $vertical = false, private readonly ?Color $trackColor = null, private readonly ?Color $thumbColor = null, private readonly bool $showValue = true, private readonly string $thumbChar = '●', private readonly string $trackChar = '─') | |
static new(float $value, float $min = 0.0, float $max = 100.0): self | Create a new horizontal slider with default styling. |
static vertical(float $value, float $min = 0.0, float $max = 100.0): self | Create a vertical slider. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this slider. |
render(): string | Render the slider as a string. |
innerSize(): array | Calculate the natural dimensions of this slider. |
withValue(float $value): self | Set the current value. |
withMin(float $min): self | Set the minimum value. |
withMax(float $max): self | Set the maximum value. |
withRange(float $min, float $max): self | Set the value range. |
withShowValue(bool $show): self | Show or hide the value label. |
withTrackColor(?Color $color): self | Set the track color. |
withThumbColor(?Color $color): self | Set the thumb color. |
withChars(string $thumb, string $track): self | Set custom thumb and track characters. |
withVertical(bool $vertical): self | Make the slider vertical. |
SwitchComponent final class
An on/off switch component with slider-style display.
| Method | Summary |
|---|---|
__construct(private readonly bool $on = false, private readonly ?Color $onColor = null, private readonly ?Color $offColor = null, private readonly ?Color $textColor = null) | |
static new(bool $on = false): self | Create a new switch with default styling. |
static on(): self | Create an "on" switch. |
static off(): self | Create an "off" switch. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this switch. |
render(): string | Render the switch as a string. |
innerSize(): array | Calculate the natural dimensions of this switch. |
withOn(bool $on): self | Set the on/off state. |
withOnColor(?Color $color): self | Set the "on" color. |
withOffColor(?Color $color): self | Set the "off" color. |
withTextColor(?Color $color): self | Set the text/bracket color. |
Textarea final class
A multi-line text area input component.
| Method | Summary |
|---|---|
__construct(private readonly ?string $value = null, private readonly ?string $placeholder = null, private readonly ?string $label = null, private readonly ?string $error = null, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly ?Color $placeholderColor = null, private readonly ?Color $backgroundColor = null, private readonly int $rows = 5, private readonly ?int $maxRows = null, private readonly string $style = 'single') | |
static new(?string $value = null, int $rows = 5): self | Create a new textarea with default styling. |
static labeled(?string $value, string $label, int $rows = 5): self | Create a textarea with a label. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this textarea. |
render(): string | Render the textarea as a string. |
innerSize(): array | Calculate the natural dimensions of this textarea. |
withValue(?string $value): self | Set the textarea value. |
withPlaceholder(?string $placeholder): self | Set the placeholder text. |
withLabel(?string $label): self | Set the label text. |
withError(?string $error): self | Set the error message. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withPlaceholderColor(?Color $color): self | Set the placeholder color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withRows(int $rows): self | Set the number of rows. |
withMaxRows(?int $maxRows): self | Set the maximum number of rows. |
withStyle(string $style): self | Set the border style. |
Toggle final class
A toggle switch component.
| Method | Summary |
|---|---|
__construct(private readonly bool $on = false, private readonly ?string $onLabel = null, private readonly ?string $offLabel = null, private readonly ?Color $onColor = null, private readonly ?Color $offColor = null, private readonly ?Color $trackColor = null) | |
static new(bool $on = false): self | Create a new toggle with default styling. |
static on(): self | Create an "on" toggle. |
static off(): self | Create an "off" toggle. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this toggle. |
render(): string | Render the toggle as a string. |
innerSize(): array | Calculate the natural dimensions of this toggle. |
withOn(bool $on): self | Set the on/off state. |
withLabels(string $on, string $off): self | Set custom labels. |
withOnColor(?Color $color): self | Set the "on" color. |
withOffColor(?Color $color): self | Set the "off" color. |
withTrackColor(?Color $color): self | Set the track background color. |
SugarCraft\Dashboard\Components\GridTable
BorderChars final class
Box-drawing characters for table borders.
| Method | Summary |
|---|---|
__construct(public readonly string $topLeft, public readonly string $top, public readonly string $topRight, public readonly string $left, public readonly string $bottomLeft, public readonly string $bottom, public readonly string $bottomRight, public readonly string $right, public readonly string $topMid, public readonly string $bottomMid, public readonly string $center, public readonly string $leftJunction = '┣', public readonly string $rightJunction = '┫', public readonly string $topJunction = '┳', public readonly string $bottomJunction = '┻', public readonly string $innerJunction = '╋', public readonly string $innerDivider = '┃', public readonly string $freezeDivider = '║', public readonly string $freezeTopJunction = '╥', public readonly string $freezeBottomJunction = '╨', public readonly string $freezeInnerJunction = '╫') | |
static new(): self | Get default heavy border characters. |
static rounded(): self | Get rounded thin border characters. |
static borderless(): self | Get borderless characters (empty strings). |
static minimal(): self | Get minimal border characters. |
BorderConfig final class
Border configuration for each region of the grid.
| Method | Summary |
|---|---|
__construct(public readonly bool $showOuter = true, public readonly bool $showHeader = true, public readonly bool $showInner = true, public readonly bool $showFooter = false, public readonly ?BorderChars $chars = null) | |
static new(): self | Create default heavy border configuration. |
static rounded(): self | Create rounded thin border configuration. |
static borderless(): self | Create borderless configuration. |
static minimal(): self | Create minimal border configuration (header only). |
withOuter(bool $show): self | |
withHeader(bool $show): self | |
withInner(bool $show): self | |
withFooter(bool $show): self | |
withChars(BorderChars $chars): self |
BorderRegion enum
Border regions of the table.
Cases: Outer · Header · Inner · Footer
PHP also provides cases().
Calc final class
Calculation utilities for grid layout.
| Method | Summary |
|---|---|
static gcd(int $a, int $b): int | Greatest common divisor using Euclidean algorithm. |
static calculateColumnWidths(array $rows, array $columns, int $availableWidth): array | Calculate column widths to fill available width. |
static truncate(string $str, int $maxWidth): string | Truncate a string to at most $maxWidth display cells, ending in an ellipsis when it is cut. Never splits a grapheme cluster. |
Cell final class
Cell value object for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly mixed $value = null, private readonly ?string $format = null) | |
static new(mixed $value = null, ?string $format = null): self | |
value(): mixed | |
getValue(): mixed | BC forwarder for the pre-rename accessor name. |
format(): ?string | |
getFormat(): ?string | BC forwarder for the pre-rename accessor name. |
toString(): string |
Column final class
A column definition for the grid.
Not listed: the methods of SugarCraft\Core\Concerns\Mutable, a trait declared outside src/.
| Method | Summary |
|---|---|
static new(string $key, string $label, ?int $minWidth = null, ?int $maxWidth = null, bool $sortable = false, bool $filterable = false, ?callable $renderer = null): self | |
withMinWidth(int $width): self | Create a column with minimum width constraint. |
withMaxWidth(int $width): self | Create a column with maximum width constraint. |
sortable(): self | Create a sortable column. |
filterable(): self | Create a filterable column. |
withRenderer(callable $renderer): self | Create a column with a custom renderer. |
Filter final class
Filter state and logic for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly array $filters = []) | |
static none(): self | |
static fromArray(array $filters): self | |
filters(): array | |
getFilters(): array | BC forwarder for the pre-rename accessor name. |
filter(string $column): ?string | |
getFilter(string $column): ?string | BC forwarder for the pre-rename accessor name. |
hasFilter(string $column): bool | |
isActive(): bool | The single activity truth: a filter entry counts only when its value is non-empty, matching self::hasFilter() polarity exactly. Storing '' via withFilter() is a neutral entry — kept for transport, never treated as active. |
withFilter(string $column, string $value): self | |
withoutFilter(string $column): self | |
clear(): self |
Footer final class
Table footer for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly ?array $summaryColumns = null, private readonly bool $showRowCount = true) | |
static new(?array $summaryColumns = null, bool $showRowCount = true): self | |
static none(): self | |
summaryColumns(): ?array | |
getSummaryColumns(): ?array | BC forwarder for the pre-rename accessor name. |
shouldShowRowCount(): bool | |
render(): string | |
withSummaryColumns(?array $summaryColumns): self | |
withShowRowCount(bool $show): self |
GridTable final class
A full-featured data grid with sort, filter, pagination, and column freezing.
| Method | Summary |
|---|---|
__construct(array $columns = [], array $rows = [], ?SortState $sortState = null, ?BorderConfig $borderConfig = null) | |
static new(array $columns, array $rows = []): self | Create a new GridTable with columns and rows. |
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this grid. |
width(): ?int | Get current width. |
getWidth(): ?int | BC forwarder for the pre-rename accessor name. |
height(): ?int | Get current height. |
getHeight(): ?int | BC forwarder for the pre-rename accessor name. |
withColumns(array $columns): self | Return a new GridTable with the given columns. |
withRows(array $rows): self | Return a new GridTable with the given rows. |
withPerPage(int $perPage): self | Return a new GridTable showing at most N rows per page. |
sort(Column $column): self | Return a new GridTable with sort applied to the given column. |
filter(string $filterText): self | Return a new GridTable with the given filter applied. |
page(int $page): self | Return a new GridTable with the given page set. |
scrollTo(int $index): self | Return a new GridTable scrolled to the given row index. |
freezeColumns(int $count): self | Return a new GridTable with N left columns frozen. |
render(): string | Render the grid as a string. |
sortState(): SortState | |
getSortState(): SortState | BC forwarder for the pre-rename accessor name. |
filterText(): string | |
getFilterText(): string | BC forwarder for the pre-rename accessor name. |
pagination(): Pagination | |
getPagination(): Pagination | BC forwarder for the pre-rename accessor name. |
frozenColumns(): int | |
getFrozenColumns(): int | BC forwarder for the pre-rename accessor name. |
Header final class
Table header for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly array $columns = [], private readonly bool $showSortIndicators = true, private readonly ?string $sortedColumn = null) | |
static new(array $columns = [], bool $showSortIndicators = true, ?string $sortedColumn = null): self | |
columns(): array | |
getColumns(): array | BC forwarder for the pre-rename accessor name. |
hasSortIndicators(): bool | |
sortedColumn(): ?string | |
getSortedColumn(): ?string | BC forwarder for the pre-rename accessor name. |
render(): string | |
withSortedColumn(?string $column): self |
Overflow final class
| Method | Summary |
|---|---|
__construct(private readonly OverflowMode $horizontal = OverflowMode::Truncate, private readonly OverflowMode $vertical = OverflowMode::Wrap) | |
static new(OverflowMode $horizontal = OverflowMode::Truncate, OverflowMode $vertical = OverflowMode::Wrap): self | |
static truncate(): self | |
static wrap(): self | |
static ellipsis(): self | |
horizontal(): OverflowMode | |
getHorizontal(): OverflowMode | BC forwarder for the pre-rename accessor name. |
vertical(): OverflowMode | |
getVertical(): OverflowMode | BC forwarder for the pre-rename accessor name. |
OverflowMode enum
Overflow handling for data grid tables.
Cases: Truncate · Wrap · Ellipsis
PHP also provides cases().
Pagination final class
Pagination state for the grid.
| Method | Summary |
|---|---|
__construct(public readonly int $page = 1, public readonly int $perPage = 20, public readonly int $totalRows = 0) | |
totalPages(): int | Total number of pages. |
offset(): int | Zero-based offset for the current page. |
clampPage(int $page): int | Clamp page to valid range. |
withPage(int $page): self | Create a new pagination with updated page. |
withPerPage(int $perPage): self | Create a new pagination with updated perPage. |
normalized(): self | Return this window with the page clamped into range for its own totalRows and perPage floored at 1. render() needs a window clamped against the filtered reality, which set-time clamping alone cannot provide (D-51, finding 044). |
withTotalRows(int $totalRows): self | Create a new pagination with updated totalRows. |
Row final class
A data row with cells indexed by column key.
| Method | Summary |
|---|---|
__construct(public readonly array $cells = []) | |
get(string $key): mixed | Get cell value by key. |
has(string $key): bool | Check if row has a cell with the given key. |
Scrolling final class
Scrolling configuration for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly bool $enabled = false, private readonly int $visibleRows = 10, private readonly int $rowHeight = 1) | |
static new(bool $enabled = false, int $visibleRows = 10, int $rowHeight = 1): self | |
static disabled(): self | |
isEnabled(): bool | |
visibleRows(): int | |
getVisibleRows(): int | BC forwarder for the pre-rename accessor name. |
rowHeight(): int | |
getRowHeight(): int | BC forwarder for the pre-rename accessor name. |
totalHeight(): int | |
getTotalHeight(): int | BC forwarder for the pre-rename accessor name. |
withEnabled(bool $enabled): self | |
withVisibleRows(int $visibleRows): self |
Sort final class
Sort state and logic for data grid tables.
| Method | Summary |
|---|---|
__construct(private readonly ?string $column = null, private readonly SortDirection $direction = SortDirection::Asc) | |
static none(): self | |
static asc(string $column): self | |
static desc(string $column): self | |
column(): ?string | |
getColumn(): ?string | BC forwarder for the pre-rename accessor name. |
direction(): SortDirection | |
getDirection(): SortDirection | BC forwarder for the pre-rename accessor name. |
isSorted(): bool | |
toggleDirection(): self |
SortDirection enum
Sort direction for grid columns.
Cases: Asc · Desc
PHP also provides cases().
SortState final class
Current sort state of the grid.
| Method | Summary |
|---|---|
__construct(public readonly ?string $key = null, public readonly SortDirection $direction = SortDirection::Asc) | |
toggle(?string $key): self | Toggle direction if same key, otherwise reset to Asc. |
isSortedBy(string $key): bool |
SugarCraft\Dashboard\Components\Media
ASCIIBanner final class
ASCII art banner generator.
| Method | Summary |
|---|---|
__construct(private readonly string $title, private readonly ?string $subtitle = null, private readonly ?Color $borderColor = null, private readonly ?Color $textColor = null, private readonly string $style = 'classic', private readonly int $padding = 1) | |
static new(string $title): self | Create a new ASCII banner. |
static withTitleAndSubtitle(string $title, string $subtitle): self | Create a banner with a title and subtitle. |
static classic(string $title): self | Create a classic ASCII banner. |
static double(string $title): self | Create a double-line banner. |
static block(string $title): self | Create a block-style banner. |
static stars(string $title): self | Create a star-decorated banner. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this banner. |
render(): string | Render the banner. |
innerSize(): array | Calculate the natural dimensions. |
withSubtitle(?string $subtitle): self | Set the subtitle. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withStyle(string $style): self | Set the banner style. |
withPadding(int $padding): self | Set the padding. |
Audio final class
An audio player component with waveform visualization.
| Method | Summary |
|---|---|
__construct(private readonly ?int $maxLength = null, private readonly bool $showWaveform = true, private readonly WaveformStyle $waveformStyle = WaveformStyle::Bars, private readonly ?Color $waveformColor = null, private readonly ?Color $progressColor = null, private readonly ?Color $trackColor = null, private readonly ?Color $textColor = null, private readonly ?string $title = null, private readonly ?string $artist = null, private readonly string $style = 'rounded') | |
static new(): self | Create a new audio player with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this audio player. |
withWaveformData(array $data): self | Set the waveform data for visualization. |
withPosition(int $seconds): self | Set the current playback position. |
withDuration(int $seconds): self | Set the duration. |
withPlaying(bool $playing): self | Set playing state. |
withVolume(int $level): self | Set volume. |
render(): string | Render the audio player as a string. |
innerSize(): array | Calculate the natural dimensions of this audio player. |
withWaveformStyle(WaveformStyle $style): self | Set the waveform style. |
withWaveformColor(?Color $color): self | Set the waveform color. |
withProgressColor(?Color $color): self | Set the progress color. |
withTrackColor(?Color $color): self | Set the track color. |
withTextColor(?Color $color): self | Set the text color. |
withTitle(?string $title): self | Set the title. |
withArtist(?string $artist): self | Set the artist. |
withStyle(string $style): self | Set the border style. |
Avatar final class
A user avatar component with fallback support.
| Method | Summary |
|---|---|
__construct(private readonly ?string $imageUrl = null, private readonly ?string $name = null, private readonly int $size = self::SIZE_MEDIUM, private readonly ?Color $backgroundColor = null, private readonly ?Color $foregroundColor = null, private readonly ?string $status = null) | |
static fromName(string $name): self | Create a new avatar with a name (displays initials as fallback). |
static withImage(string $imageUrl, ?string $name = null): self | Create a new avatar with an image URL. |
static small(string $name): self | Create a small avatar. |
static large(string $name): self | Create a large avatar. |
static sizeToPixels(int $size): int | Get the pixel width for a size constant. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this avatar. |
render(): string | Render the avatar as a string. |
innerSize(): array | Calculate the natural dimensions of this avatar. |
withImageUrl(?string $url): self | Set the image URL. |
withName(?string $name): self | Set the name (used for initials fallback). |
withSize(int $size): self | Set the avatar size. |
withBackgroundColor(?Color $color): self | Set the background color. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withStatus(?string $status): self | Set the status indicator. |
AvatarGroup final class
A group of avatars displayed in a row.
| Method | Summary |
|---|---|
__construct(private readonly array $avatars = [], private readonly int $overlap = 2, private readonly ?int $maxDisplay = null, private readonly ?string $overflowIndicator = null, private readonly ?Color $overflowBackgroundColor = null, private readonly ?Color $overflowForegroundColor = null) | |
static fromNames(array $names): self | Create a new avatar group from a list of names. |
static compact(array $names, int $maxDisplay = 4): self | Create a compact avatar group showing max N avatars. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this avatar group. |
render(): string | Render the avatar group as a string. |
innerSize(): array | Calculate the natural dimensions of this avatar group. |
withAvatars(array $avatars): self | Set the avatars in this group. |
withAppended(Avatar $avatar): self | Add an avatar to this group. |
withOverlap(int $overlap): self | Set the overlap amount between avatars. |
withMaxDisplay(?int $maxDisplay): self | Set the maximum number of avatars to display. |
withOverflowIndicator(?string $indicator): self | Set the overflow indicator text. |
withOverflowColors(?Color $background, ?Color $foreground): self | Set the overflow indicator colors. |
Barcode final class
A barcode display component.
| Method | Summary |
|---|---|
__construct(private readonly string $content, private readonly int $height = 3, private readonly bool $showText = true, private readonly ?Color $barColor = null) | |
static new(string $content): self | Create a new barcode with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this barcode. |
render(): string | Render the barcode. |
innerSize(): array | Calculate the natural dimensions of this barcode. |
withHeight(int $height): self | Set the barcode height (in character rows). |
withShowText(bool $show): self | Show or hide the text label. |
withBarColor(?Color $color): self | Set the bar color. |
withContent(string $content): self | Set new content. |
ControlsStyle enum
Video player controls display mode.
Cases: Auto · Always · Hidden
PHP also provides cases(), from() and tryFrom().
Emoji final class
An emoji display component.
| Method | Summary |
|---|---|
__construct(private readonly string $emoji, private readonly ?string $label = null, private readonly int $size = self::SIZE_MEDIUM, private readonly ?Color $tintColor = null, private readonly bool $showLabel = false) | |
static thumbsUp(?string $label = null): self | Create a thumbs up emoji. |
static thumbsDown(?string $label = null): self | Create a thumbs down emoji. |
static clap(?string $label = null): self | Create a clap emoji. |
static fire(?string $label = null): self | Create a fire emoji. |
static rocket(?string $label = null): self | Create a rocket emoji. |
static star(?string $label = null): self | Create a star emoji. |
static sparkle(?string $label = null): self | Create a sparkle emoji. |
static check(?string $label = null): self | Create a check mark emoji. |
static x(?string $label = null): self | Create an X mark emoji. |
static warning(?string $label = null): self | Create a warning emoji. |
static info(?string $label = null): self | Create a info emoji. |
static question(?string $label = null): self | Create a question mark emoji. |
static exclamation(?string $label = null): self | Create an exclamation emoji. |
static lightbulb(?string $label = null): self | Create a light bulb emoji. |
static trophy(?string $label = null): self | Create a trophy emoji. |
static medal(?string $label = null): self | Create a medal emoji. |
static smile(?string $label = null): self | Create a smiley face emoji. |
static sad(?string $label = null): self | Create a sad face emoji. |
static heart(?string $label = null): self | Create a heart emoji. |
static brokenHeart(?string $label = null): self | Create a broken heart emoji. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this emoji. |
render(): string | Render the emoji as a string. |
innerSize(): array | Calculate the natural dimensions of this emoji. |
withEmoji(string $emoji): self | Set the emoji. |
withLabel(?string $label): self | Set the label. |
withSize(int $size): self | Set the size. |
withTintColor(?Color $color): self | Set the tint color. |
withShowLabel(bool $show): self | Set whether to show the label. |
FigletText final class
Figlet-style large text using ASCII art characters.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly ?Color $textColor = null, private readonly string $font = 'standard') | |
static new(string $text): self | Create a new figlet text component. |
static shadow(string $text): self | Create with shadow font style. |
static small(string $text): self | Create with small font style. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this component. |
render(): string | Render the figlet text. |
innerSize(): array | Calculate the natural dimensions. |
withTextColor(?Color $color): self | Set the text color. |
withFont(string $font): self | Set the font style. |
Icon final class
An icon display component.
| Method | Summary |
|---|---|
__construct(private readonly string $glyph, private readonly ?string $label = null, private readonly int $size = 1, private readonly ?Color $color = null, private readonly ?Color $labelColor = null) | |
static file(?string $name = null): self | Create a file icon. |
static folder(?string $name = null): self | Create a folder icon. |
static gear(?string $label = null): self | Create a gear/settings icon. |
static heart(?string $label = null): self | Create a heart icon. |
static star(?string $label = null): self | Create a star icon. |
static check(?string $label = null): self | Create a checkmark icon. |
static cross(?string $label = null): self | Create an X/cross icon. |
static info(?string $label = null): self | Create an info icon. |
static warning(?string $label = null): self | Create a warning/alert icon. |
static error(?string $label = null): self | Create an error icon. |
static home(?string $label = null): self | Create a home icon. |
static search(?string $label = null): self | Create a search icon. |
static music(?string $label = null): self | Create a music note icon. |
static play(?string $label = null): self | Create a play icon. |
static pause(?string $label = null): self | Create a pause icon. |
static stop(?string $label = null): self | Create a stop icon. |
static arrowUp(?string $label = null): self | Create an up arrow icon. |
static arrowDown(?string $label = null): self | Create a down arrow icon. |
static arrowLeft(?string $label = null): self | Create a left arrow icon. |
static arrowRight(?string $label = null): self | Create a right arrow icon. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this icon. |
render(): string | Render the icon as a string. |
innerSize(): array | Calculate the natural dimensions of this icon. |
withGlyph(string $glyph): self | Set the glyph. |
withLabel(?string $label): self | Set the label. |
withSize(int $size): self | Set the size (scaling factor). |
withColor(?Color $color): self | Set the icon color. |
withLabelColor(?Color $color): self | Set the label color. |
Image final class
An image display component with fallback support.
| Method | Summary |
|---|---|
__construct(private readonly ?string $url = null, private readonly ?string $alt = null, private readonly ?int $maxWidth = null, private readonly ?int $maxHeight = null, private readonly string $format = self::FORMAT_BOX, private readonly ?Color $borderColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $altColor = null) | |
static fromUrl(string $url, ?string $alt = null): self | Create a new image with a URL. |
static placeholder(?string $alt = null): self | Create a placeholder image (no actual image URL). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this image. |
render(): string | Render the image as a string. |
innerSize(): array | Calculate the natural dimensions of this image. |
withUrl(?string $url): self | Set the image URL. |
withAlt(?string $alt): self | Set the alt text. |
withMaxWidth(?int $maxWidth): self | Set the maximum width. |
withMaxHeight(?int $maxHeight): self | Set the maximum height. |
withFormat(string $format): self | Set the format. |
withBorderColor(?Color $color): self | Set the border color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withAltColor(?Color $color): self | Set the alt text color. |
Marquee final class
A scrolling marquee text component.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly int $speed = 1, private readonly bool $leftToRight = true, private readonly ?Color $textColor = null, private readonly bool $fadeEdges = true, private readonly int $offset = 0) | |
static new(string $text): self | Create a new marquee with the given text. |
static fast(string $text): self | Create a fast marquee. |
static slow(string $text): self | Create a slow marquee. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this marquee. |
innerSize(): array | Calculate the natural dimensions of this marquee. |
render(?int $frame = null): string | Render the marquee at a specific frame. |
nextFrame(): self | Advance the marquee to the next frame. |
withSpeed(int $speed): self | Set the scroll speed. |
withDirection(bool $leftToRight): self | Set scroll direction. |
withTextColor(?Color $color): self | Set the text color. |
withFadeEdges(bool $fade): self | Enable or disable edge fading. |
Pictogram final class
A pictogram chart using icons/symbols to represent values.
| Method | Summary |
|---|---|
__construct(private readonly array $items, private readonly string $icon = '■', private readonly int $iconWidth = 1, private readonly int $maxIcons = 10, private readonly bool $showLabels = true, private readonly bool $showValues = true, private readonly bool $stacked = false) | |
static new(array $items): self | Create a new pictogram with the given data. |
static circles(array $items): self | Create a pictogram with filled circles. |
static stars(array $items): self | Create a pictogram with stars. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this pictogram. |
innerSize(): array | Calculate the natural dimensions of this pictogram. |
render(): string | Render the pictogram. |
withIcon(string $icon): self | Set the icon character. |
withMaxIcons(int $max): self | Set the maximum number of icons per row. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withStacked(bool $stacked): self | Enable stacked mode. |
Picture final class
A picture display component with fallback support.
| Method | Summary |
|---|---|
__construct(private readonly ?string $url = null, private readonly ?string $alt = null, private readonly ?string $caption = null, private readonly int $widthHint = 20, private readonly int $heightHint = 10, private readonly string $fallbackType = self::FALLBACK_PLACEHOLDER, private readonly ?string $fallbackValue = null, private readonly ?Color $borderColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $captionColor = null) | |
static fromUrl(string $url, ?string $alt = null): self | Create a picture with an image URL. |
static withInitials(string $name, ?string $url = null): self | Create a picture with initials fallback (like Avatar). |
static withIcon(string $icon, ?string $url = null): self | Create a picture with icon fallback. |
static withEmoji(string $emoji, ?string $url = null): self | Create a picture with emoji fallback. |
static placeholder(): self | Create a placeholder picture (no image URL). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this picture. |
render(): string | Render the picture as a string. |
innerSize(): array | Calculate the natural dimensions of this picture. |
withUrl(?string $url): self | Set the image URL. |
withAlt(?string $alt): self | Set the alt text. |
withCaption(?string $caption): self | Set the caption. |
withWidthHint(int $width): self | Set the width hint. |
withHeightHint(int $height): self | Set the height hint. |
withFallbackType(string $type): self | Set the fallback type. |
withFallbackValue(?string $value): self | Set the fallback value. |
withBorderColor(?Color $color): self | Set the border color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withCaptionColor(?Color $color): self | Set the caption color. |
PlaybackState enum
Video playback state.
Cases: Stopped · Playing · Paused · Buffering
PHP also provides cases(), from() and tryFrom().
QRCode final class
A QR code display component.
| Method | Summary |
|---|---|
__construct(private readonly string $content, private readonly int $size = 8, private readonly bool $bordered = true, private readonly ?Color $filledColor = null, private readonly ?Color $emptyColor = null) | |
static new(string $content): self | Create a new QR code with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this QR code. |
render(): string | Render the QR code. |
innerSize(): array | Calculate the natural dimensions of this QR code. |
withSize(int $size): self | Set the QR code size (grid dimensions). |
withBordered(bool $bordered): self | Show or hide the border. |
withFilledColor(?Color $color): self | Set the color for filled cells. |
withEmptyColor(?Color $color): self | Set the color for empty cells. |
withContent(string $content): self | Set new content. |
Shadow final class
A shadow effect that wraps any Item.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly string $style = self::Normal, private readonly ?Color $color = null, private readonly int $xOffset = 1, private readonly int $yOffset = 1) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new shadow with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this shadow. |
render(): string | Render the content with shadow effect. |
innerSize(): array | Calculate the natural dimensions of this shadow component. |
withStyle(string $style): self | Set the shadow style (normal, heavy, none). |
withColor(?Color $color): self | Set the shadow color. |
withXOffset(int $offset): self | Set the horizontal offset (how far shadow extends right). |
withYOffset(int $offset): self | Set the vertical offset (how far shadow extends down). |
withOffset(int $x, int $y): self | Set both x and y offset. |
withHeavy(): self | Set a heavy shadow style. |
withNoShadow(): self | Disable the shadow effect. |
Video final class
A video player component with playback controls and progress bar.
| Method | Summary |
|---|---|
__construct(private readonly ?int $maxLength = null, private readonly bool $showControls = true, private readonly ControlsStyle $controlsStyle = ControlsStyle::Auto, private readonly ?Color $progressColor = null, private readonly ?Color $bufferColor = null, private readonly ?Color $trackColor = null, private readonly ?Color $textColor = null, private readonly ?Color $backgroundColor = null, private readonly ?string $source = null, private readonly string $style = 'rounded') | |
static new(): self | Create a new video player with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this video player. |
progressWidth(): int | Get the progress bar width. |
getProgressWidth(): int | BC forwarder for the pre-rename accessor name. |
render(): string | Render the video player as a string. |
innerSize(): array | Calculate the natural dimensions of this video player. |
withShowControls(bool $show): self | Set the controls visibility. |
withControlsStyle(ControlsStyle $style): self | Set the controls style. |
withProgressColor(?Color $color): self | Set the progress bar color. |
withTrackColor(?Color $color): self | Set the track color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withSource(?string $source): self | Set the video source. |
withStyle(string $style): self | Set the border style. |
WaveformStyle enum
Waveform visualization style.
Cases: Bars · Line · Blocks · Dots
PHP also provides cases(), from() and tryFrom().
SugarCraft\Dashboard\Components\Modal
Alert final class
An alert / message box component.
| Method | Summary |
|---|---|
__construct(private readonly string $message, private readonly ?string $title = null, private readonly ?Color $borderColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $foregroundColor = null, private readonly string $borderChar = '│', private readonly string $icon = '') | |
static new(string $message): self | Create a new alert with default styling. |
static info(string $message): self | Create an info-style alert. |
static warning(string $message): self | Create a warning-style alert. |
static error(string $message): self | Create an error/danger-style alert. |
static success(string $message): self | Create a success-style alert. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this alert. |
render(): string | Render the alert as a string. |
innerSize(): array | Calculate the natural dimensions of this alert. |
withMessage(string $message): self | Set the alert message. |
withTitle(?string $title): self | Set the alert title. |
withBorderColor(?Color $color): self | Set the border color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withBorderChar(string $char): self | Set the border character. |
withIcon(string $icon): self | Set the icon prefix. |
ConfirmModal final class
A confirmation modal dialog.
| Method | Summary |
|---|---|
__construct(private readonly string $message, private readonly string $confirmLabel = 'Confirm', private readonly string $cancelLabel = 'Cancel', private readonly bool $isDanger = false) | |
setSize(int $width, int $height): static | Findings sugar-dashboard-069/173 (D-70): the dialog answers the same SizedItem channel layout hosts measure. Framed chrome - and with it a navigable cursor surface - arrives with the composition design (173 deferral, disclosed); this ships the sizing contract. |
innerSize(): array | |
static new(string $message): self | |
static danger(string $message): self | |
static ok(string $message): self | |
static yesNo(string $message): self | |
render(): string |
Drawer final class
A slide-out drawer panel component.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item|string $content, private readonly string $position = self::POSITION_LEFT, private readonly ?int $size = null, private readonly ?string $title = null, private readonly ?Color $borderColor = null, private readonly string $style = 'single', private readonly \SugarCraft\Dashboard\Foundation\Item|string|null $footer = null) | |
static new(\SugarCraft\Dashboard\Foundation\Item|string $content, string $position = self::POSITION_LEFT): self | Create a new drawer with default styling. |
static left(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a left-positioned drawer. |
static right(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a right-positioned drawer. |
static top(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a top-positioned drawer. |
static bottom(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a bottom-positioned drawer. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this drawer. |
render(): string | Render the drawer as a string. |
innerSize(): array | Calculate the natural dimensions of this drawer. |
withContent(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Set the drawer content. |
withPosition(string $position): self | Set the drawer position. |
withSize(?int $size): self | Set the drawer size (width for left/right, height for top/bottom). |
withTitle(?string $title): self | Set the drawer title. |
withBorderColor(?Color $color): self | Set the border color. |
withStyle(string $style): self | Set the border style. |
withFooter(\SugarCraft\Dashboard\Foundation\Item|string|null $footer): self | Set the drawer footer. |
ListModal final class
A modal dialog that displays a list of items.
| Method | Summary |
|---|---|
__construct(array $items = [], private readonly ?string $title = null, private mixed $onEdit = null, private mixed $onDelete = null) | |
static new(array $items, ?string $title = null): self | |
withSelectedIndex(?int $index): self | |
withOnEdit(callable $onEdit): self | |
withOnDelete(callable $onDelete): self | |
setSize(int $width, int $height): Sizer | |
innerSize(): array | |
render(): string | Render the list, honoring the allocated box (finding sugar-dashboard- 064: setSize used to be stored and never read). |
Modal final class
A modal dialog overlay component.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item|string $content, private readonly ?string $title = null, private readonly ?Color $borderColor = null, private readonly ?Color $bgColor = null, private readonly string $style = 'single', private readonly bool $showClose = true, private readonly string $closeLabel = '×') | |
static new(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a new modal with default styling. |
static titled(\SugarCraft\Dashboard\Foundation\Item|string $content, string $title): self | Create a modal with a title. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this modal. |
render(): string | Render the modal as a string. |
innerSize(): array | Calculate the natural dimensions of this modal. |
withContent(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Set the modal content. |
withTitle(?string $title): self | Set the modal title. |
withBorderColor(?Color $color): self | Set the border color. |
withBgColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
withShowClose(bool $show): self | Show or hide the close button. |
withCloseLabel(string $label): self | Set the close button label. |
MultiselectModal final class
A modal dialog for selecting multiple items from a list.
| Method | Summary |
|---|---|
__construct(array $options = [], array $selectedIndices = [], private readonly ?string $title = null) | |
static new(array $options, ?string $title = null): self | |
withSelectedIndices(array $indices): self | |
toggle(int $index): self | |
setSize(int $width, int $height): static | |
innerSize(): array | |
render(): string |
Notification final class
A notification component for displaying alert messages.
| Method | Summary |
|---|---|
__construct(private readonly string $message = '', private readonly string $title = '', private readonly ?Color $borderColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $titleColor = null, private readonly ?Color $messageColor = null, private readonly string $icon = '') | |
static new(string $message = ''): self | Create a new notification with default styling. |
static success(string $message): self | Create a success notification. |
static warning(string $message): self | Create a warning notification. |
static error(string $message): self | Create an error/danger notification. |
static info(string $message): self | Create an info notification. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this notification. |
render(): string | Render the notification as a string. |
innerSize(): array | Calculate the natural dimensions of this notification. |
withMessage(string $message): self | Set the notification message. |
withTitle(string $title): self | Set the notification title. |
withBorderColor(?Color $color): self | Set the border color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withTitleColor(?Color $color): self | Set the title color. |
withMessageColor(?Color $color): self | Set the message color. |
withIcon(string $icon): self | Set the icon. |
Popover final class
A popover component that displays content in a bordered box.
| Method | Summary |
|---|---|
__construct(private readonly string $title = '', private readonly string $content = '', private readonly ?Color $borderColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $titleColor = null, private readonly bool $showArrow = true) | |
static new(string $title = '', string $content = ''): self | Create a new popover with default styling. |
static info(string $title, string $content): self | Create an informational popover. |
static warning(string $title, string $content): self | Create a warning popover. |
static danger(string $title, string $content): self | Create a danger popover. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this popover. |
render(): string | Render the popover as a string. |
innerSize(): array | Calculate the natural dimensions of this popover. |
withTitle(string $title): self | Set the popover title. |
withContent(string $content): self | Set the popover content. |
withBorderColor(?Color $color): self | Set the border color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withTitleColor(?Color $color): self | Set the title color. |
withShowArrow(bool $show): self | Show or hide the arrow. |
ProgressModal final class
A modal dialog that shows a progress bar.
| Method | Summary |
|---|---|
__construct(private readonly int $current, private readonly int $total, private readonly ?string $label = null) | |
setSize(int $width, int $height): static | Finding sugar-dashboard-182 (D-70 design leg): the modal answers the SizedItem channel; the painted row is clipped to the allocation. The crash leg (negative bar paint) landed already via D-66; there is no with* surface on this class - factories stay the plain builders. |
innerSize(): array | |
static new(int $current, int $total, ?string $label = null): self | |
render(): string |
Wizard final class
A multi-step wizard component.
| Method | Summary |
|---|---|
__construct(array $steps = [], private readonly int $currentStep = 0, private readonly ?Color $completedColor = null, private readonly ?Color $currentColor = null, private readonly ?Color $upcomingColor = null, private readonly string $completedChar = '✓', private readonly string $currentChar = '●', private readonly string $upcomingChar = '○', private readonly string $connectorChar = '─') | |
static fromSteps(array $stepTitles): self | Create a new wizard with the given step titles. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this wizard. |
render(): string | Render the wizard as a string. |
innerSize(): array | Calculate the natural dimensions of this wizard. |
withSteps(array $steps): self | Set the wizard steps. |
addStep(WizardStep $step): self | Add a step to the wizard. |
withCurrentStep(int $step): self | Set the current step index. |
withCompletedColor(?Color $color): self | Set the completed color. |
withCurrentColor(?Color $color): self | Set the current step color. |
withUpcomingColor(?Color $color): self | Set the upcoming step color. |
withCompletedChar(string $char): self | Set the completed character. |
withCurrentChar(string $char): self | Set the current character. |
withUpcomingChar(string $char): self | Set the upcoming character. |
withConnectorChar(string $char): self | Set the connector character. |
WizardStep final readonly class
A step in a wizard.
| Method | Summary |
|---|---|
__construct(public string $title, public ?string $description = null) | |
static new(string $title, ?string $description = null): self | Create a new wizard step. |
SugarCraft\Dashboard\Components\Modal\Msg
AnsweredDeleteMsg final readonly class
Represents a delete action on an item (used by ListModal, MultiselectModal).
| Method | Summary |
|---|---|
__construct(public readonly mixed $item, public readonly int $index) |
AnsweredEditMsg final readonly class
Represents an edit action on an item (used by ListModal, MultiselectModal).
| Method | Summary |
|---|---|
__construct(public readonly mixed $item, public readonly int $index) |
AnsweredNoMsg final readonly class
Represents a negative answer (No / Cancel).
AnsweredYesMsg final readonly class
Represents an affirmative answer (OK / Yes / Confirm).
ClosedMsg final readonly class
Represents the modal being closed (cancelled).
Msg abstract readonly class
Base class for modal message types (TEA-style).
SugarCraft\Dashboard\Components\Nav
Breadcrumb final class
A breadcrumb navigation component.
| Method | Summary |
|---|---|
__construct(private readonly array $items, private readonly string $separator = '›', private readonly ?Color $separatorColor = null, private readonly ?Color $itemColor = null, private readonly ?Color $activeColor = null, private readonly int $activeIndex = -1) | |
static new(array $items): self | Create a new breadcrumb with default styling. |
static fromPath(string $path, string $separator = '/'): self | Create a breadcrumb from a path string (e.g., "Home / Category / Item"). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this breadcrumb. |
render(): string | Render the breadcrumb as a string. |
innerSize(): array | Calculate the natural dimensions of this breadcrumb. |
withItems(array $items): self | Set new breadcrumb items. |
withSeparator(string $separator): self | Set the separator character. |
withSeparatorColor(?Color $color): self | Set the separator color. |
withItemColor(?Color $color): self | Set the item (inactive) color. |
withActiveColor(?Color $color): self | Set the active item color. |
withActiveIndex(int $index): self | Set the active item index (-1 for last item). |
Ladder final class
A ladder diagram for displaying process steps and timeline.
| Method | Summary |
|---|---|
__construct(private readonly array $steps, private readonly bool $horizontal = false, private readonly ?Color $completeColor = null, private readonly ?Color $currentColor = null, private readonly ?Color $pendingColor = null) | |
static new(array $steps): self | Create a new ladder diagram. |
static horizontal(array $steps): self | Create a horizontal ladder. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this ladder. |
innerSize(): array | Calculate the natural dimensions of this ladder. |
render(): string | Render the ladder diagram. |
withHorizontal(bool $horizontal): self | Set horizontal orientation. |
withCompleteColor(?Color $color): self | Set complete color. |
withCurrentColor(?Color $color): self | Set current color. |
withPendingColor(?Color $color): self | Set pending color. |
Menu final class
A horizontal menu bar component with dropdown submenus.
| Method | Summary |
|---|---|
__construct(private readonly array $items, private readonly int $selectedIndex = 0, private readonly int $submenuIndex = 0, private readonly bool $submenuOpen = false, private readonly ?Color $barColor = null, private readonly ?Color $itemColor = null, private readonly ?Color $activeItemColor = null, private readonly ?Color $submenuColor = null) | |
static new(array $items): self | Create a new menu with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this menu. |
render(): string | Render the menu component. |
innerSize(): array | Calculate the natural dimensions of this menu. |
withSelectedIndex(int $index): self | Set the selected top-level item index. |
withSubmenuIndex(int $index): self | Set the submenu item index. |
withSubmenuOpen(bool $open): self | Set whether the submenu is open. |
withItems(array $items): self | Set the menu items. |
withBarColor(?Color $color): self | Set the bar color. |
withItemColor(?Color $color): self | Set the item color. |
withActiveItemColor(?Color $color): self | Set the active item highlight color. |
withSubmenuColor(?Color $color): self | Set the submenu color. |
Navbar final class
A horizontal navigation bar component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly ?string $brand = null, private readonly ?Color $borderColor = null, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly ?Color $bgColor = null) | |
static new(array $items = []): self | Create a new navbar with default styling. |
static brand(string $brand, array $items = []): self | Create a navbar with a brand name. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this navbar. |
render(): string | Render the navbar as a string. |
innerSize(): array | Calculate the natural dimensions of this navbar. |
withItems(array $items): self | Set the navbar items. |
withBrand(?string $brand): self | Set the brand name. |
withBorderColor(?Color $color): self | Set the border color. |
withActiveColor(?Color $color): self | Set the active item color. |
withInactiveColor(?Color $color): self | Set the inactive item color. |
withBgColor(?Color $color): self | Set the background color. |
withActiveItem(int $index): self | Mark an item as active by index. |
Pagination final class
A pagination control component.
| Method | Summary |
|---|---|
__construct(private readonly int $currentPage, private readonly int $totalPages, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly bool $showFirstLast = true, private readonly bool $showPrevNext = true, private readonly string $prevLabel = '‹', private readonly string $nextLabel = '›') | |
static new(int $currentPage, int $totalPages): self | Create a new pagination with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this pagination. |
render(): string | Render the pagination as a string. |
innerSize(): array | Calculate the natural dimensions of this pagination. |
withCurrentPage(int $page): self | Set the current page. |
withTotalPages(int $total): self | Set the total pages. |
withActiveColor(?Color $color): self | Set the active page color. |
withInactiveColor(?Color $color): self | Set the inactive page color. |
withShowFirstLast(bool $show): self | Show or hide first/last buttons. |
withShowPrevNext(bool $show): self | Show or hide prev/next buttons. |
withPrevLabel(string $label): self | Set the previous button label. |
withNextLabel(string $label): self | Set the next button label. |
PaginationSimple final class
A simple pagination control component.
| Method | Summary |
|---|---|
__construct(private readonly int $currentPage, private readonly int $totalPages, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly string $prevLabel = '‹', private readonly string $nextLabel = '›') | |
static new(int $currentPage, int $totalPages): self | Create a new simple pagination with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this pagination. |
render(): string | Render the pagination as a string. |
innerSize(): array | Calculate the natural dimensions of this pagination. |
withCurrentPage(int $page): self | Set the current page. |
withTotalPages(int $total): self | Set the total pages. |
withActiveColor(?Color $color): self | Set the active page color. |
withInactiveColor(?Color $color): self | Set the inactive page color. |
withPrevLabel(string $label): self | Set the previous button label. |
withNextLabel(string $label): self | Set the next button label. |
Scrollbar final class
A scrollbar component for terminal content.
| Method | Summary |
|---|---|
__construct(private readonly float $position = 0.0, private readonly float $viewportRatio = 0.3, private readonly int $heightConstraint = 10, private readonly ?Color $thumbColor = null, private readonly ?Color $trackColor = null, private readonly bool $showArrows = true, private readonly string $thumbChar = '█', private readonly string $trackChar = '│', private readonly string $arrowUp = '▲', private readonly string $arrowDown = '▼') | |
static new(float $position, float $viewportRatio = 0.3): self | Create a new scrollbar with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this scrollbar. |
render(): string | Render the scrollbar as a string. |
innerSize(): array | Calculate the natural dimensions of this scrollbar. |
withPosition(float $position): self | Set the scroll position (0.0 to 1.0). |
withViewportRatio(float $ratio): self | Set the viewport ratio (how much of the content is visible, 0.1 to 1.0). |
withHeight(int $height): self | Set the height constraint. |
withThumbColor(?Color $color): self | Set the thumb color. |
withTrackColor(?Color $color): self | Set the track color. |
withShowArrows(bool $show): self | Show or hide arrow buttons. |
withChars(string $thumb, string $track): self | Set custom thumb and track characters. |
withArrows(string $up, string $down): self | Set custom arrow characters. |
Sequence final class
A sequence diagram component for visualizing object interactions.
| Method | Summary |
|---|---|
__construct(private ?Color $lifelineColor = null, private ?Color $messageColor = null, private ?Color $textColor = null, private ?Color $activationColor = null, private string $style_ = 'rounded') | |
static new(): self | Create a new sequence diagram with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this sequence diagram. |
withParticipant(SequenceParticipant $participant): self | Add a participant to the diagram. |
addParticipant(string $id, string $label, ?Color $color = null): self | Add a participant by parameters. |
withParticipants(array $participants): self | Add all participants at once. |
withMessage(SequenceMessage $message): self | Add a message to the diagram. |
addMessage(string $id, string $from, string $to, string $label, ?Color $color = null): self | Add a message by parameters. |
addReply(string $id, string $from, string $to, string $label, ?Color $color = null): self | Add a reply message. |
withMessages(array $messages): self | Add all messages at once. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowActivations(bool $show): self | Show or hide activations. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the sequence diagram as a string. |
innerSize(): array | Calculate the natural dimensions of this sequence diagram. |
withLifelineColor(?Color $color): self | Set the lifeline color. |
withMessageColor(?Color $color): self | Set the message color. |
withTextColor(?Color $color): self | Set the text color. |
withActivationColor(?Color $color): self | Set the activation color. |
withBorderStyle(string $style): self | Set the border style. |
SequenceMessage final class
A message sent between participants in a sequence diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $from, public readonly string $to, public readonly string $label, public readonly bool $isReply = false, public readonly ?Color $color = null) | |
static reply(string $id, string $from, string $to, string $label, ?Color $color = null): self | Create a reply message. |
SequenceParticipant final class
A participant (object/actor) in a sequence diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly ?Color $color = null) | |
static actor(string $id, string $label): self | Create an actor participant. |
static object(string $id, string $label): self | Create an object participant. |
Stepper final class
A stepper / step indicator component for multi-step wizards.
| Method | Summary |
|---|---|
__construct(private readonly array $steps, private readonly bool $showNumbers = true, private readonly ?Color $completedColor = null, private readonly ?Color $activeColor = null, private readonly ?Color $pendingColor = null, private readonly ?Color $connectorColor = null) | |
static new(array $steps): self | Create a new stepper with default styling. |
static fromLabels(array $stepLabels, int $currentStep = 0): self | Create a stepper with specific step labels and current step index. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stepper. |
render(): string | Render the stepper as a string. |
innerSize(): array | Calculate the natural dimensions of this stepper. |
withSteps(array $steps): self | Set the steps. |
withActiveStep(int $step): self | Set the current active step. |
withShowNumbers(bool $show): self | Show or hide step numbers. |
withCompletedColor(?Color $color): self | Set the completed step color. |
withActiveColor(?Color $color): self | Set the active step color. |
withPendingColor(?Color $color): self | Set the pending step color. |
withConnectorColor(?Color $color): self | Set the connector color. |
SugarCraft\Dashboard\Components\Select
AutoPositionHelper final class
Determines optimal overlay position based on available space. Mirrors teafields position.go auto-positioning logic.
| Method | Summary |
|---|---|
static vertical(int|string $anchorRectY, int $anchorHeight, int $availableHeight): OverlayPosition | Given anchorRect (y, height) and availableHeight, returns OverlayPosition::Top or OverlayPosition::Bottom depending on which has more room. |
ColorPicker final class
A color picker component with preset color swatches.
| Method | Summary |
|---|---|
__construct(private readonly array $palette = [], private readonly ?int $selectedIndex = 0, private readonly bool $showHex = true, private readonly int $columns = 4, private readonly ?Color $selectedColor = null, private readonly ?Color $hoverColor = null) | |
static new(?int $selectedIndex = null): self | Create a new color picker with default palette. |
static fromPalette(array $hexColors, ?int $selectedIndex = null): self | Create with a custom palette. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this color picker. |
render(): string | Render the color picker as a string. |
innerSize(): array | Calculate the natural dimensions of this color picker. |
withSelectedIndex(int $index): self | Set the selected color index. |
withShowHex(bool $show): self | Set whether to show hex code. |
withColumns(int $cols): self | Set the number of columns. |
withSelectedColor(?Color $color): self | Set the selected color highlight style. |
withHoverColor(?Color $color): self | Set the hover color style. |
withPalette(array $palette): self | Set a new palette. |
ComboBox final class
A combobox component with search filtering.
| Method | Summary |
|---|---|
__construct(private readonly string $placeholder = 'Search...', private readonly array $options = [], private readonly string $query = '', private readonly int $selectedIndex = 0, private readonly ?Color $inputColor = null, private readonly ?Color $matchColor = null, private readonly ?Color $selectedColor = null) | |
static new(string $placeholder = 'Search...', array $options = []): self | Create a new combobox with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this combobox. |
render(): string | Render the combobox as a string. |
innerSize(): array | Calculate the natural dimensions of this combobox. |
withPlaceholder(string $placeholder): self | Set the placeholder text. |
withOptions(array $options): self | Set the options. |
withQuery(string $query): self | Set the search query. |
withSelectedIndex(int $index): self | Set the selected result index. |
withInputColor(?Color $color): self | Set the input color. |
withMatchColor(?Color $color): self | Set the match highlight color. |
withSelectedColor(?Color $color): self | Set the selected item color. |
DatePicker final class
A date picker component.
| Method | Summary |
|---|---|
__construct(private readonly int $year = 0, private readonly int $month = 0, private readonly int $selectedDay = 0, private readonly int $startDayOfWeek = self::DAYS_SUNDAY, private readonly ?Color $headerColor = null, private readonly ?Color $selectedColor = null, private readonly ?Color $todayColor = null, private readonly ?Color $weekendColor = null) | |
static new(int $year, int $month, ?int $selectedDay = null): self | Create a new date picker with default styling. |
static today(): self | Create for current month. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this date picker. |
render(): string | Render the date picker as a string. |
innerSize(): array | Calculate the natural dimensions of this date picker. |
withDate(int $year, int $month): self | Set the year and month. |
withSelectedDay(int $day): self | Set the selected day. |
withPreviousMonth(): self | Navigate to the previous month. |
withNextMonth(): self | Navigate to the next month. |
withStartDayOfWeek(int $day): self | Set the starting day of week. |
withHeaderColor(?Color $color): self | Set the header color. |
withSelectedColor(?Color $color): self | Set the selected day color. |
withTodayColor(?Color $color): self | Set the today highlight color. |
withWeekendColor(?Color $color): self | Set the weekend day color. |
Dropdown final class
A dropdown menu component.
| Method | Summary |
|---|---|
__construct(private readonly string $label, private readonly array $items, private readonly bool $expanded = false, private readonly int $selectedIndex = 0, private readonly ?Color $triggerColor = null, private readonly ?Color $menuColor = null, private readonly ?Color $selectedItemColor = null, private readonly string $expandIcon = '▾', private readonly string $collapseIcon = '▸') | |
static new(string $label, array $items): self | Create a new dropdown with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this dropdown. |
render(): string | Render the dropdown component. |
innerSize(): array | Calculate the natural dimensions of this dropdown. |
withLabel(string $label): self | Set the dropdown label. |
withItems(array $items): self | Set the dropdown items. |
withExpanded(bool $expanded): self | Set the expanded state. |
withSelectedIndex(int $index): self | Set the selected item index. |
withTriggerColor(?Color $color): self | Set the trigger color. |
withMenuColor(?Color $color): self | Set the menu color. |
withSelectedItemColor(?Color $color): self | Set the selected item highlight color. |
withIcons(string $expand, string $collapse): self | Set custom expand/collapse icons. |
Option final class
Represents a single option in a select dropdown.
| Method | Summary |
|---|---|
__construct(public readonly string $label, public readonly ?string $value = null, public readonly ?string $icon = null, public readonly bool $disabled = false) | |
static fromArray(array $data): self | Create an option from an array. |
toArray(): array | Convert to array representation. |
OverlayPosition enum
Positioning options for overlay components like dropdowns, tooltips, and modals.
Cases: Top · Bottom · Left · Right · TopStart · TopEnd · BottomStart · BottomEnd · LeftStart · LeftEnd · RightStart · RightEnd · Center
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
opposite(): self | Get the opposite position. |
isHorizontal(): bool | Check if this is a horizontal position. |
isVertical(): bool | Check if this is a vertical position. |
Radio final class
A radio button group component.
| Method | Summary |
|---|---|
__construct(private readonly array $options, private readonly int $selectedIndex = 0, private readonly ?Color $selectedColor = null, private readonly ?Color $unselectedColor = null, private readonly string $selectedChar = '◉', private readonly string $unselectedChar = '○') | |
static new(array $options): self | Create a new radio group with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this radio group. |
render(): string | Render the radio group. |
innerSize(): array | Calculate the natural dimensions of this radio group. |
withSelectedIndex(int $index): self | Set the selected option index. |
withOptions(array $options): self | Set new options. |
withSelectedColor(?Color $color): self | Set the color for selected items. |
withUnselectedColor(?Color $color): self | Set the color for unselected items. |
withChars(string $selected, string $unselected): self | Set custom characters for selected and unselected states. |
Select final class
A dropdown select component.
| Method | Summary |
|---|---|
__construct(private readonly array $options, private readonly int $selectedIndex = 0, private readonly ?Color $selectedColor = null, private readonly ?Color $unselectedColor = null, private readonly string $selectedChar = '▶', private readonly string $unselectedChar = '○') | |
static new(array $options): self | Create a new select component with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this select component. |
render(): string | Render the select component. |
innerSize(): array | Calculate the natural dimensions of this select component. |
withSelectedIndex(int $index): self | Set the selected option index. |
withOptions(array $options): self | Set new options. |
withSelectedColor(?Color $color): self | Set the color for selected items. |
withUnselectedColor(?Color $color): self | Set the color for unselected items. |
withChars(string $selected, string $unselected): self | Set custom characters for selected and unselected states. |
SugarCraft\Dashboard\Components\StatusBar
MenuItem final class
A menu item for use in status bar menus.
| Method | Summary |
|---|---|
__construct(private readonly string $label, private readonly ?string $shortcut = null, private readonly ?\SugarCraft\Dashboard\Components\StatusBar\StatusIndicator $indicator = null) | |
static new(string $label): self | |
render(): string |
SeparatorKind enum
Separator kinds for status bar menus.
Cases: Line · Dotted · Dashed · Double
PHP also provides cases(), from() and tryFrom().
StatusBar final class
A horizontal status bar with multiple segments.
| Method | Summary |
|---|---|
__construct(private readonly string $left = '', private readonly string $center = '', private readonly string $right = '', private readonly ?Color $foreground = null, private readonly ?Color $background = null, private readonly string $leftBorder = '', private readonly string $rightBorder = '') | |
static new(): self | Create a new status bar with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this status bar. |
render(): string | Render the status bar as a string. |
innerSize(): array | Calculate the natural dimensions of this status bar. |
withLeft(string $left): self | Set the left segment content. |
withCenter(string $center): self | Set the center segment content. |
withRight(string $right): self | Set the right segment content. |
withSegments(string $left, string $center, string $right): self | Set all segment contents at once. |
withForeground(?Color $color): self | Set the foreground color. |
withBackground(?Color $color): self | Set the background color. |
withBorders(string $left, string $right): self | Set border characters for left and right sides. |
StatusIndicator final class
A status indicator dot/light component.
| Method | Summary |
|---|---|
__construct(private readonly string $status = self::Online, private readonly ?Color $color = null, private readonly bool $pulse = false, private readonly int $size = 1) | |
static new(string $status = self::Online): self | Create a new status indicator with default styling. |
static online(): self | Create an online/success status indicator. |
static offline(): self | Create an offline status indicator. |
static warning(): self | Create a warning status indicator. |
static error(): self | Create an error status indicator. |
static info(): self | Create an info status indicator. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this indicator. |
render(?float $now = null): string | Render the status indicator. |
symbol(): string | Get the symbol character for the indicator. |
getSymbol(): string | BC forwarder for the pre-rename accessor name. |
status(): string | Get the current status type. |
getStatus(): string | BC forwarder for the pre-rename accessor name. |
innerSize(): array | Calculate the natural dimensions of this indicator. |
withStatus(string $status): self | Set the status type. |
withColor(?Color $color): self | Set the indicator color. |
withPulse(bool $pulse): self | Enable or disable pulse animation. |
withSize(int $size): self | Set the size (number of indicator characters). |
SugarCraft\Dashboard\Components\System
Clock final class
A digital clock display component.
| Method | Summary |
|---|---|
__construct(private readonly bool $use24Hour = false, private readonly bool $showSeconds = true, private readonly bool $showDate = false, private readonly ?Color $color = null) | |
static new(): self | Create a new clock with default styling (24-hour with seconds). |
static twentyFourHour(): self | Create a 24-hour format clock. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this clock. |
render(?int $now = null): string | Render the clock showing current time. |
innerSize(): array | Calculate the natural dimensions of this clock. |
with24Hour(bool $use24Hour): self | Use 24-hour format instead of 12-hour. |
withSeconds(bool $show): self | Show or hide seconds. |
withDate(bool $show): self | Show or hide the date. |
withColor(?Color $color): self | Set the clock color. |
Console final class
A styled console output component.
| Method | Summary |
|---|---|
__construct(array $entries = [], private readonly ?int $maxEntries = null, private readonly bool $showTimestamps = false, private readonly bool $wordWrap = true, private readonly ?ConsoleStream $minStream = null, private readonly bool $showPrefix = true, private readonly ?int $timestampWidth = null, private readonly ?Color $timestampColor = null, private readonly ?Color $prefixColor = null) | |
static new(): self | Create a new console with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this console. |
render(): string | Render the console as a string. |
innerSize(): array | Calculate the natural dimensions of this console. |
withEntries(array $entries): self | Add console entries. |
withEntry(ConsoleEntry $entry): self | Add a single console entry. |
withMaxEntries(?int $max): self | Set the maximum number of entries to display. |
withTimestamps(bool $show): self | Show or hide timestamps. |
withWordWrap(bool $wordWrap): self | Enable or disable word-wrapping. |
withMinStream(?ConsoleStream $stream): self | Set the minimum stream level to display. |
withShowPrefix(bool $show): self | Show or hide stream prefixes. |
withTimestampWidth(?int $width): self | Set the timestamp column width. |
withTimestampColor(?Color $color): self | Set the timestamp color. |
withPrefixColor(?Color $color): self | Set the prefix color. |
ConsoleEntry final readonly class
| Method | Summary |
|---|---|
__construct(public string $message, public ConsoleStream $stream = ConsoleStream::Stdout, public ?Color $color = null) | |
static new(string $message, ConsoleStream $stream = ConsoleStream::Stdout, ?Color $color = null): self | |
static info(string $message): self | |
static success(string $message): self | |
static warning(string $message): self | |
static error(string $message): self | |
static debug(string $message): self | |
static raw(string $message): self |
ConsoleStream enum
Cases: Stdout · Stderr · Info · Success · Warning · Error · Debug · Raw
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
defaultColor(): Color | |
prefix(): string | |
isError(): bool | |
sortOrder(): int |
HexDump final class
A hexadecimal dump display component.
| Method | Summary |
|---|---|
__construct(private readonly string $data, private readonly int $bytesPerLine = self::BYTES_PER_LINE_16, private readonly ?Color $offsetColor = null, private readonly ?Color $hexColor = null, private readonly ?Color $asciiColor = null, private readonly ?Color $nonPrintableColor = null, private readonly bool $uppercase = true) | |
static new(string $data): self | Create a new hex dump with default styling (Catppuccin Mocha theme). |
static compact(string $data): self | Create a hex dump with 8 bytes per line (compact). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this hex dump. |
render(): string | Render the hex dump as a string. |
innerSize(): array | Calculate the natural dimensions of this hex dump. |
withBytesPerLine(int $bytesPerLine): self | Set the bytes per line (8 or 16). |
withOffsetColor(?Color $color): self | Set the offset column color. |
withHexColor(?Color $color): self | Set the hex bytes color. |
withAsciiColor(?Color $color): self | Set the ASCII column color. |
withNonPrintableColor(?Color $color): self | Set the non-printable character color. |
withUppercase(bool $uppercase): self | Set uppercase or lowercase hex output. |
withData(string $data): self | Set new data content. |
Log final class
A log viewer component with severity level filtering and display.
| Method | Summary |
|---|---|
__construct(array $entries = [], private readonly ?int $maxEntries = null, private readonly ?LogLevel $minLevel = null, private readonly bool $showTimestamps = true, private readonly bool $wordWrap = true, private readonly ?int $timestampWidth = null, private readonly ?Color $timestampColor = null) | |
static new(): self | Create a new log viewer with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this log viewer. |
render(): string | Render the log viewer as a string. |
innerSize(): array | Calculate the natural dimensions of this log viewer. |
withEntries(array $entries): self | Add log entries to the viewer. |
withEntry(LogEntry $entry): self | Add a single log entry. |
withMaxEntries(?int $max): self | Set the maximum number of entries to keep. |
withMinLevel(?LogLevel $level): self | Set the minimum log level to display. |
withTimestamps(bool $show): self | Show or hide timestamps. |
withWordWrap(bool $wordWrap): self | Enable or disable word-wrapping. |
withTimestampWidth(?int $width): self | Set the timestamp column width. |
withTimestampColor(?Color $color): self | Set the timestamp color. |
LogEntry final readonly class
A log entry with timestamp, level, and message.
| Method | Summary |
|---|---|
__construct(public string $timestamp, public LogLevel $level, public string $message) | |
static new(string $message, LogLevel $level = LogLevel::Info, ?string $timestamp = null): self | Create a new log entry. |
LogLevel enum
Log entry severity levels.
Cases: Debug · Info · Warn · Error · Fatal
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
defaultColor(): Color | Get the default color for this severity level. |
sortOrder(): int | Get the sort order for this level (lower = more severe). |
LogViewer final class
A scrollable log viewer component with severity-based colors.
| Method | Summary |
|---|---|
__construct(array $entries, private readonly bool $showTimestamps = false, private readonly bool $showSeverityPrefix = true, private readonly bool $scrollToBottom = true, private readonly int $visibleLines = 10) | |
static new(array $entries): self | Create a new log viewer with the given entries. |
static fromMessages(array $messages): self | Create a log viewer from a simple list of messages (all info level). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this log viewer. |
render(): string | Render the log viewer. |
innerSize(): array | Calculate the natural dimensions of this log viewer. |
entryCount(): int | Get the number of entries. |
getEntryCount(): int | BC forwarder for the pre-rename accessor name. |
withEntries(array $entries): self | Set the log entries. |
withEntry(array $entry): self | Add a new entry to the log. |
withShowTimestamps(bool $show): self | Show or hide timestamps. |
withShowSeverityPrefix(bool $show): self | Show or hide severity prefix. |
withScrollToBottom(bool $bottom): self | Set scroll behavior (true = bottom, false = top). |
withVisibleLines(int $lines): self | Set the number of visible lines. |
NProgress final class
A YouTube-style thin progress bar component.
| Method | Summary |
|---|---|
__construct(private readonly float $ratio = 0.0, private readonly ?Color $color = null, private readonly ?Color $trackColor = null, private readonly bool $showPercentage = false) | |
static new(float $ratio = 0.0): self | Create a new nprogress bar with default styling. |
static loading(): self | Create a loading-state nprogress (indeterminate). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this progress bar. |
render(): string | Render the progress bar as a string. |
innerSize(): array | Calculate the natural dimensions of this progress bar. |
withRatio(float $ratio): self | Set the progress ratio (0.0 to 1.0). |
withColor(?Color $color): self | Set the bar color. |
withTrackColor(?Color $color): self | Set the track (background) color. |
withShowPercentage(bool $show): self | Show or hide the percentage text. |
withTheme(Theme $theme): self | Apply a theme to this progress bar, using the theme's primary color for the bar and background for the track. |
ProgressBar final class
A simple horizontal progress bar component.
| Method | Summary |
|---|---|
__construct(private readonly float $ratio, private readonly ?int $widthConstraint = null, private readonly bool $showPercentage = true, private readonly ?Color $filledColor = null, private readonly ?Color $emptyColor = null, private readonly string $filledChar = '█', private readonly string $emptyChar = '░', private readonly bool $labelAfter = true) | |
static new(float $ratio): self | Create a new progress bar with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this progress bar. |
render(): string | Render the progress bar as a string. |
innerSize(): array | Calculate the natural dimensions of this progress bar. |
withWidth(int $width): self | Set the width constraint (number of bar characters). |
withPercentage(bool $show): self | Show or hide the percentage label. |
withFilledColor(?Color $color): self | Set the color for the filled portion. |
withEmptyColor(?Color $color): self | Set the color for the empty portion. |
withChars(string $filled, string $empty): self | Set custom characters for filled and empty portions. |
withRatio(float $ratio): self | Set a new ratio value. |
withLabelAfter(bool $after): self | Set whether label appears after or before the bar. |
ProgressList final class
A list component with progress indicators for each item.
| Method | Summary |
|---|---|
__construct(private readonly array $items, private readonly bool $showProgressBars = true, private readonly bool $showPercentages = true, private readonly int $progressBarWidth = 20, private readonly HAlign $labelAlign = HAlign::Left) | |
static new(array $items): self | Create a new progress list with the given items. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this list. |
render(): string | Render the progress list. |
innerSize(): array | Calculate the natural dimensions of this list. |
withItems(array $items): self | Set the items for this list. |
withShowProgressBars(bool $show): self | Show or hide progress bars. |
withShowPercentages(bool $show): self | Show or hide percentages. |
withProgressBarWidth(int $width): self | Set the progress bar width. |
withLabelAlign(HAlign $align): self | Set the label alignment. |
PromptStyle enum
Terminal prompt styles.
Cases: Bash · Pwsh · PS · Simple
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
prompt(string $cwd = '~'): string | Get the prompt string for this style. |
Stopwatch final class
A stopwatch component.
| Method | Summary |
|---|---|
__construct(private readonly int $elapsedMilliseconds = 0, private readonly bool $showMilliseconds = true, private readonly bool $isRunning = false, private readonly ?Color $color = null) | |
static new(): self | Create a new stopped stopwatch at zero. |
static start(): self | Create a running stopwatch. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stopwatch. |
render(): string | Render the stopwatch display. |
innerSize(): array | Calculate the natural dimensions of this stopwatch. |
elapsedSeconds(): int | Get the elapsed time in seconds. |
getElapsedSeconds(): int | BC forwarder for the pre-rename accessor name. |
elapsedMilliseconds(): int | Get the elapsed milliseconds. |
getElapsedMilliseconds(): int | BC forwarder for the pre-rename accessor name. |
withElapsedMillis(int $milliseconds): self | Set the elapsed time in MILLISECONDS. |
withElapsed(int $milliseconds): self | Set the elapsed time in milliseconds. |
withRunning(bool $isRunning): self | Set the running state. |
withMilliseconds(bool $show): self | Show or hide milliseconds. |
withColor(?Color $color): self | Set the stopwatch color. |
Terminal final class
A terminal emulator component with command history and scrollback.
| Method | Summary |
|---|---|
__construct(private readonly ?int $maxHistory = null, private readonly ?int $maxOutput = null, private readonly bool $showPrompt = true, private readonly PromptStyle $promptStyle = PromptStyle::Bash, private readonly ?string $customPrompt = null, private readonly ?Color $promptColor = null, private readonly ?Color $inputColor = null, private readonly ?Color $outputColor = null, private readonly ?Color $errorColor = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $borderColor = null, private readonly string $style = 'rounded') | |
static new(): self | Create a new terminal with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this terminal. |
prompt(): string | Get the prompt string. |
getPrompt(): string | BC forwarder for the pre-rename accessor name. |
input(): string | Get the current input. |
getInput(): string | BC forwarder for the pre-rename accessor name. |
history(): array | Get the command history. |
getHistory(): array | BC forwarder for the pre-rename accessor name. |
output(): array | Get the output lines. |
getOutput(): array | BC forwarder for the pre-rename accessor name. |
type(string $input): self | Type a command into the terminal. |
submit(): self | Submit the current command. |
withOutput(string $text, bool $isError = false): self | Add output text. |
withBlankLine(): self | Add a blank line to output. |
historyUp(): self | Navigate history up (previous command). |
historyDown(): self | Navigate history down (next command). |
clearScreen(): self | Clear the screen (adds clear command to output). |
clearInput(): self | Clear the input line. |
render(): string | Render the terminal as a string. |
innerSize(): array | Calculate the natural dimensions of this terminal. |
withPromptStyle(PromptStyle $style): self | Set the prompt style. |
withCustomPrompt(?string $prompt): self | Set a custom prompt string. |
withShowPrompt(bool $show): self | Show or hide the prompt. |
withMaxHistory(?int $max): self | Set the maximum history size. |
withMaxOutput(?int $max): self | Set the maximum output size. |
withPromptColor(?Color $color): self | Set the prompt color. |
withInputColor(?Color $color): self | Set the input color. |
withOutputColor(?Color $color): self | Set the output color. |
withStyle(string $style): self | Set the border style. |
Timer final class
A countdown timer component.
| Method | Summary |
|---|---|
__construct(private readonly int $totalSeconds, private readonly int $elapsedSeconds = 0, private readonly bool $isRunning = false, private readonly ?Color $color = null, private readonly ?Color $warningColor = null, private readonly int $warningThreshold = 60) | |
static new(int $seconds): self | Create a new timer with the specified duration. |
static fromMinutes(int $minutes): self | Create a timer from minutes. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this timer. |
render(): string | Render the timer display. |
innerSize(): array | Calculate the natural dimensions of this timer. |
remainingSeconds(): int | Get the remaining seconds. |
getRemainingSeconds(): int | BC forwarder for the pre-rename accessor name. |
isExpired(): bool | Check if timer has expired. |
withElapsedSeconds(int $seconds): self | Set the elapsed time in SECONDS (for ticking). |
withElapsed(int $seconds): self | Set the elapsed time in seconds. |
withRunning(bool $isRunning): self | Set the running state. |
withColor(?Color $color): self | Set the timer color. |
withWarningColor(?Color $color): self | Set the warning color (used when time is running low). |
withWarningThreshold(int $seconds): self | Set the warning threshold in seconds. |
SugarCraft\Dashboard\Components\Table
TableBordered final class
A table component with box-drawing character borders.
| Method | Summary |
|---|---|
__construct(private readonly array $columns, private readonly array $rows, private readonly ?Color $borderColor = null, private readonly ?Color $headerColor = null, private readonly ?Color $headerBackgroundColor = null, private readonly bool $showHeader = true) | |
static new(array $columns, array $rows = []): self | Create a new bordered table with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this table. |
render(): string | Render the table as a string. |
innerSize(): array | Calculate the natural dimensions of this table. |
withColumns(array $columns): self | Set the column definitions. |
withRows(array $rows): self | Set the data rows. |
withAddedRow(array $row): self | Add a data row. |
withBorderColor(?Color $color): self | Set the border color. |
withHeaderColor(?Color $color): self | Set the header text color. |
withHeaderBackgroundColor(?Color $color): self | Set the header background color. |
withShowHeader(bool $show): self | Show or hide the header row. |
TableChart final class
A data table component with customizable columns, rows, and styling.
| Method | Summary |
|---|---|
__construct(private readonly array $columnHeaders = [], private readonly array $rows = [], private readonly ?array $columnWidths = null, private readonly ?array $columnAlignments = null, private readonly bool $showHeader = true, private readonly bool $zebraStriping = true, private readonly ?Color $headerColor = null, private readonly ?Color $borderColor = null, private readonly ?Color $zebraColor = null, private readonly string $borderStyle = 'rounded') | |
static new(array $columnHeaders, array $rows = []): self | Create a new table chart. |
static sample(): self | Create a sample table for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this table. |
render(): string | Render the table. |
innerSize(): array | Calculate the natural dimensions of this table. |
withRows(array $rows): self | Set the rows. |
withShowHeader(bool $show): self | Set the header visibility. |
withZebraStriping(bool $zebra): self | Set zebra striping. |
withBorderStyle(string $style): self | Set the border style. |
withHeaderColor(?Color $color): self | Set the header color. |
TableZebra final class
A table component with alternating row colors (zebra striping).
| Method | Summary |
|---|---|
__construct(private readonly array $columns, private readonly array $rows, private readonly ?Color $oddRowColor = null, private readonly ?Color $evenRowColor = null, private readonly ?Color $headerColor = null, private readonly ?Color $headerBackgroundColor = null, private readonly bool $showHeader = true, private readonly bool $showSeparators = false) | |
static new(array $columns, array $rows = []): self | Create a new zebra-striped table with default styling (Catppuccin Mocha). |
static plain(array $columns, array $rows = []): self | Create a zebra table with no row colors (plain). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this table. |
render(): string | Render the table as a string. |
innerSize(): array | Calculate the natural dimensions of this table. |
withColumns(array $columns): self | Set the column definitions. |
withRows(array $rows): self | Set the data rows. |
withAddedRow(array $row): self | Add a data row. |
withOddRowColor(?Color $color): self | Set the odd row background color. |
withEvenRowColor(?Color $color): self | Set the even row background color. |
withHeaderColor(?Color $color): self | Set the header text color. |
withHeaderBackgroundColor(?Color $color): self | Set the header background color. |
withShowHeader(bool $show): self | Show or hide the header row. |
withShowSeparators(bool $show): self | Show or hide row separators. |
SugarCraft\Dashboard\Components\Tabs
TabPane final class
A pane container for tab content.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly ?Color $borderColor = null, private readonly string $borderChar = '│', private readonly bool $padded = true) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new tab pane with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this tab pane. |
render(): string | Render the tab pane. |
innerSize(): array | Calculate the natural dimensions of this tab pane. |
withBorderColor(?Color $color): self | Set the border color. |
withBorderChar(string $char): self | Set the border character. |
withPadded(bool $padded): self | Set the padded flag. |
Tabs final class
A tabbed interface component.
| Method | Summary |
|---|---|
__construct(private readonly array $tabs, private readonly int $selectedIndex = 0, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly string $separator = '│', private readonly string $activeChar = '─') | |
static new(array $tabs): self | Create a new tabs component with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for these tabs. |
render(): string | Render the tabs component. |
innerSize(): array | Calculate the natural dimensions of these tabs. |
withSelectedIndex(int $index): self | Set the selected tab index. |
withActiveColor(?Color $color): self | Set the color for the active tab. |
withInactiveColor(?Color $color): self | Set the color for inactive tabs. |
withSeparator(string $separator): self | Set the separator character between tabs. |
withActiveChar(string $char): self | Set the character used for active tab underline. |
withTabs(array $tabs): self | Set new tabs content. |
TabsVertical final class
A vertical tabs component.
| Method | Summary |
|---|---|
__construct(private readonly array $tabs, private readonly int $selectedIndex = 0, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly string $separator = '│', private readonly int $labelWidth = 12) | |
static new(array $tabs): self | Create a new vertical tabs component with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for these vertical tabs. |
render(): string | Render the vertical tabs component. |
innerSize(): array | Calculate the natural dimensions of these vertical tabs. |
withSelectedIndex(int $index): self | Set the selected tab index. |
withActiveColor(?Color $color): self | Set the color for the active tab. |
withInactiveColor(?Color $color): self | Set the color for inactive tabs. |
withSeparator(string $separator): self | Set the separator character between labels and content. |
withLabelWidth(int $width): self | Set the width reserved for tab labels. |
withTabs(array $tabs): self | Set new tabs content. |
SugarCraft\Dashboard\Components\Toast
Hint final class
A hint / caption text component.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly ?Color $color = null, private readonly string $style = 'normal', private readonly string $icon = '') | |
static new(string $text): self | Create a new hint with default styling. |
static muted(string $text): self | Create a muted/secondary hint. |
static italic(string $text): self | Create an italic hint. |
static info(string $text): self | Create an info-style hint. |
static success(string $text): self | Create a success-style hint. |
static warning(string $text): self | Create a warning-style hint. |
static danger(string $text): self | Create a danger-style hint. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this hint. |
render(): string | Render the hint as a string. |
innerSize(): array | Calculate the natural dimensions of this hint. |
withText(string $text): self | Set the hint text. |
withColor(?Color $color): self | Set the hint color. |
withStyle(string $style): self | Set the hint style. |
withIcon(string $icon): self | Set the icon prefix. |
Level enum
Log levels for toast notifications.
Cases: Info · Warning · Error · Success
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
icon(): string | Get the default icon for this level. |
isError(): bool | Check if this level represents an error condition. |
isHighlighted(): bool | Check if this level should be highlighted. |
NoticePosition enum
Positioning options for toast notifications on screen.
Cases: TopLeft · TopCenter · TopRight · BottomLeft · BottomCenter · BottomRight · CenterLeft · CenterRight · Center · Anchor
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
vertical(): string | Get the vertical alignment for this position. |
horizontal(): string | Get the horizontal alignment for this position. |
isCorner(): bool | Check if this is a corner position. |
isCenter(): bool | Check if this is a center position. |
isAnchor(): bool | Check if this is an anchor position (positioned relative to an element). |
toToastPosition(): ToastPosition | Map onto the sugar-toast ToastPosition used by the shared engine. |
Notification final class
A single notification DTO held by NotificationQueue.
| Method | Summary |
|---|---|
__construct(public readonly string $message, public readonly Level $level = Level::Info, public readonly ?string $title = null) | |
static info(string $message, ?string $title = null): self | |
static warning(string $message, ?string $title = null): self | |
static error(string $message, ?string $title = null): self | |
static success(string $message, ?string $title = null): self |
NotificationQueue final class
Dual-ring notification queue per Homedash pattern.
| Method | Summary |
|---|---|
__construct(int $maxItems = 20, int $maxHistory = 50) | |
static new(): self | |
push(Notification $notification): self | Push a notification onto the items ring. |
dismiss(): self | Dismiss the head of the items ring, moving it to history. |
current(): ?Notification | Return the head of the items ring, or null if empty. |
recent(int $n): array | Return the last $n notifications from history, newest-first. |
all(): array | Return all active items. |
history(): array | Return all history items, oldest-first. |
count(): int | Return the number of active items. |
historyCount(): int | Return the number of history items. |
isEmpty(): bool | Check if the items ring is empty. |
hasHistory(): bool | Check if history has any entries. |
withMaxItems(int $maxItems): self | New instance carrying both rings under a different items cap. |
withMaxHistory(int $maxHistory): self | New instance carrying both rings under a different history cap. |
Toast final class
A toast / notification component.
| Method | Summary |
|---|---|
__construct(private readonly string $message, private readonly ?string $title = null, private readonly ?Color $backgroundColor = null, private readonly ?Color $foregroundColor = null, private readonly ?Color $borderColor = null, private readonly string $icon = '', private readonly int $maxWidth = 60, private readonly ToastType $type = ToastType::Info) | |
static fromNotification(Notification $notification): self | Bridge a Notification DTO into a styled Toast. |
static fromQueue(NotificationQueue $queue): ?self | Bridge a NotificationQueue, rendering its current head as a toast. |
static typeForLevel(Level $level): ToastType | Map a sugar-dashboard Level onto the sugar-toast ToastType. |
static new(string $message): self | Create a new toast with default styling. |
static info(string $message): self | Create an info-style toast. |
static success(string $message): self | Create a success-style toast. |
static warning(string $message): self | Create a warning-style toast. |
static error(string $message): self | Create an error-style toast. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this toast. |
render(): string | Render the toast as a string via the sugar-toast engine. |
innerSize(): array | Calculate the natural dimensions of this toast. |
withMessage(string $message): self | Set the toast message. |
withTitle(?string $title): self | Set the toast title. |
withBackgroundColor(?Color $color): self | Set the background color. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withBorderColor(?Color $color): self | Set the border color. |
withIcon(string $icon): self | Set the icon. |
withMaxWidth(int $maxWidth): self | Set the maximum width. |
Tooltip final class
A tooltip component.
| Method | Summary |
|---|---|
__construct(private readonly string $text, private readonly string $position = 'top', private readonly ?Color $backgroundColor = null, private readonly ?Color $foregroundColor = null, private readonly ?Color $borderColor = null) | |
static new(string $text): self | Create a new tooltip with default styling. |
static dark(string $text): self | Create a tooltip with a dark background. |
static info(string $text): self | Create a tooltip with an info style. |
static warning(string $text): self | Create a tooltip with a warning style. |
static danger(string $text): self | Create a tooltip with a danger/error style. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this tooltip. |
render(): string | Render the tooltip as a string. |
innerSize(): array | Calculate the natural dimensions of this tooltip. |
withText(string $text): self | Set the tooltip text. |
withPosition(string $position): self | Set the position of the tooltip indicator. |
withBackgroundColor(?Color $color): self | Set the background color. |
withForegroundColor(?Color $color): self | Set the foreground (text) color. |
withBorderColor(?Color $color): self | Set the border color. |
SugarCraft\Dashboard\Components\Tree
ArrayTreeProvider final class
Basic tree data provider implementation.
| Method | Summary |
|---|---|
__construct(array $nodes, array $childrenMap, array $rootIds = []) | |
roots(): array | |
children(string $nodeId): array | |
node(string $nodeId): ?TreeNode | |
hasChildren(string $nodeId): bool | |
depth(string $nodeId): int | |
totalValue(): float |
BranchPattern enum
Branch line patterns.
Cases: Solid · Dashed · Dotted · Double
PHP also provides cases(), from() and tryFrom().
BranchStyle final class
Style options for tree branches.
| Method | Summary |
|---|---|
__construct(public readonly ?Color $color = null, public readonly BranchPattern $pattern = BranchPattern::Solid, public readonly int $width = 1, public readonly bool $showArrow = true) | |
static solid(?Color $color = null): self | Create a solid branch style. |
static dashed(?Color $color = null): self | Create a dashed branch style. |
static dotted(?Color $color = null): self | Create a dotted branch style. |
static double(?Color $color = null): self | Create a double-line branch style. |
withColor(?Color $color): self | Create a copy with a different color. |
withPattern(BranchPattern $pattern): self | Create a copy with a different pattern. |
withWidth(int $width): self | Create a copy with a different width. |
withArrow(bool $showArrow): self | Create a copy with or without arrow. |
lineChar(): string | Get the line character(s) for this branch style. |
getLineChar(): string | BC forwarder for the pre-rename accessor name. |
connectorChar(): string | Get the connector character for this branch style. |
getConnectorChar(): string | BC forwarder for the pre-rename accessor name. |
endConnectorChar(): string | Get the end connector character for this branch style. |
getEndConnectorChar(): string | BC forwarder for the pre-rename accessor name. |
ClassDiagram final class
A UML class diagram component for visualizing class structures.
| Method | Summary |
|---|---|
__construct(private ?Color $classColor = null, private ?Color $interfaceColor = null, private ?Color $abstractColor = null, private ?Color $relationColor = null, private ?Color $textColor = null, private string $style_ = 'rounded') | |
static new(): self | Create a new class diagram with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this class diagram. |
withClass(UMLClass $class): self | Add a class to the diagram. |
addClass(string $id, string $name, bool $isAbstract = false, bool $isInterface = false): self | Add a class by parameters. |
withClasses(array $classes): self | Set all classes at once. |
withRelation(ClassRelation $relation): self | Add a relation to the diagram. |
withInheritance(string $child, string $parent): self | Add an inheritance relation. |
withRelations(array $relations): self | Set all relations at once. |
withShowVisibility(bool $show): self | Show or hide visibility modifiers. |
withShowTypes(bool $show): self | Show or hide type annotations. |
withShowPackages(bool $show): self | Show or hide package names. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the class diagram as a string. |
innerSize(): array | Calculate the natural dimensions of this class diagram. |
withClassColor(?Color $color): self | Set the class color. |
withInterfaceColor(?Color $color): self | Set the interface color. |
withAbstractColor(?Color $color): self | Set the abstract class color. |
withRelationColor(?Color $color): self | Set the relation color. |
withTextColor(?Color $color): self | Set the text color. |
withBorderStyle(string $style): self | Set the border style. |
ClassMember final class
UML class member (attribute or method).
| Method | Summary |
|---|---|
__construct(public readonly Visibility $visibility, public readonly string $name, public readonly string $type = '', public readonly bool $isStatic = false, public readonly bool $isAbstract = false) | |
static public(string $name, string $type = ''): self | Create a public member. |
static private(string $name, string $type = ''): self | Create a private member. |
static protected(string $name, string $type = ''): self | Create a protected member. |
static static(self $member): self | Create a static member. |
render(): string | Render the member as a string. |
ClassRelation final class
A relationship between classes.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $from, public readonly string $to, public readonly string $type = 'association', public readonly string $label = '', public readonly ?Color $color = null) | |
static association(string $from, string $to, string $label = ''): self | Create an association relationship. |
static inheritance(string $from, string $to): self | Create an inheritance relationship. |
static implementation(string $from, string $to): self | Create an implementation relationship. |
static aggregation(string $from, string $to, string $label = ''): self | Create an aggregation relationship. |
static composition(string $from, string $to, string $label = ''): self | Create a composition relationship. |
static dependency(string $from, string $to, string $label = ''): self | Create a dependency relationship. |
ConnectionStyle enum
Connection line styles for mind map branches.
Cases: Straight · Curved · Rounded
PHP also provides cases(), from() and tryFrom().
Dendrogram final class
A Dendrogram component for hierarchical clustering visualization.
| Method | Summary |
|---|---|
__construct(private ?Color $nodeColor = null, private ?Color $lineColor = null, private ?Color $textColor = null, private ?Color $leafColor = null) | |
static new(): self | Create a new dendrogram with default styling. |
static sample(): self | Create a sample dendrogram for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this dendrogram. |
withRoot(DendrogramNode $root): self | Set the root node. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withHorizontal(bool $horizontal): self | Use horizontal orientation. |
withStyle(string $style): self | Set the border style. |
withNodeSize(int $width, int $height): self | Set node dimensions. |
render(): string | Render the dendrogram as a string. |
innerSize(): array | Calculate the natural dimensions of this dendrogram. |
withNodeColor(?Color $color): self | Set the node color. |
withLineColor(?Color $color): self | Set the line color. |
withTextColor(?Color $color): self | Set the text color. |
withLeafColor(?Color $color): self | Set the leaf color. |
DendrogramNode final class
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly float $value = 0.0, public readonly ?Color $color = null) | |
withChildren(array $children): self | |
withColor(?Color $color): self | |
totalValue(): float | |
getTotalValue(): float | BC forwarder for the pre-rename accessor name. |
depth(): int | |
getDepth(): int | BC forwarder for the pre-rename accessor name. |
DrilldownTree final class
A drill-down tree view component.
| Method | Summary |
|---|---|
__construct(private ?Color $nodeColor = null, private ?Color $selectedColor = null, private ?Color $textColor = null, private ?Color $lineColor = null, private string $style = 'rounded') | |
static new(TreeNode $root): self | Create a new drill-down tree with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this drill-down tree. |
withRoot(TreeNode $root): self | Set the root node. |
withPath(string $path): self | Set the current drill-down path. |
withShowValues(bool $show): self | Show or hide values. |
withShowIcons(bool $show): self | Show or hide icons. |
withExpanded(bool $expanded): self | Set expanded state. |
withOnEnter(callable $onEnter): self | Set the onEnter lifecycle hook. |
withOnExit(callable $onExit): self | Set the onExit lifecycle hook. |
pushNode(string $nodeId): self | Push a node onto the navigation stack and call onEnter. |
popNode(): self | Pop a node from the navigation stack and call onExit. |
navigationStack(): array | Get the current navigation stack. |
getNavigationStack(): array | BC forwarder for the pre-rename accessor name. |
breadcrumbItems(): array | Get breadcrumb items from the navigation stack. |
getBreadcrumbItems(): array | BC forwarder for the pre-rename accessor name. |
render(): string | Render the drill-down tree as a string. |
innerSize(): array | Calculate the natural dimensions of this drill-down tree. |
withNodeColor(?Color $color): self | Set the node color. |
withSelectedColor(?Color $color): self | Set the selected path color. |
withTextColor(?Color $color): self | Set the text color. |
withLineColor(?Color $color): self | Set the line color. |
withStyle(string $style): self | Set the border style. |
EdgeStyle enum
Cases: Solid · Dashed · Dotted · Double
PHP also provides cases(), from() and tryFrom().
Flowchart final class
A flowchart component for visualizing processes and decisions.
| Method | Summary |
|---|---|
__construct(private readonly ?int $maxNodes = null, private readonly ?Color $processColor = null, private readonly ?Color $decisionColor = null, private readonly ?Color $startEndColor = null, private readonly ?Color $ioColor = null, private readonly ?Color $arrowColor = null, private readonly ?Color $textColor = null, private readonly ?Color $backgroundColor = null, private readonly string $style = 'rounded') | |
static new(): self | Create a new flowchart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this flowchart. |
withNode(FlowchartNode $node): self | Add a node to the flowchart. |
addNode(string $id, string $label, FlowchartNodeType $type = FlowchartNodeType::Process): self | Add a node by parameters. |
withNodes(array $nodes): self | Set all nodes at once. |
withConnection(string $fromId, string $toId): self | Connect two nodes. |
withStartNode(string $nodeId): self | Set the start node ID. |
withShowArrows(bool $show): self | Show or hide arrows. |
withShowLabels(bool $show): self | Show or hide labels. |
withFlowDirection(string $direction): self | Set the flow direction. |
render(): string | Render the flowchart as a string. |
innerSize(): array | Calculate the natural dimensions of this flowchart. |
withProcessColor(?Color $color): self | Set the process color. |
withDecisionColor(?Color $color): self | Set the decision color. |
withStartEndColor(?Color $color): self | Set the start/end color. |
withIoColor(?Color $color): self | Set the I/O color. |
withArrowColor(?Color $color): self | Set the arrow color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
FlowchartNode final class
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly FlowchartNodeType $type = FlowchartNodeType::Process, public readonly ?Color $color = null) | |
withNext(string $nextId): self | |
static process(string $id, string $label): self | |
static decision(string $id, string $label): self | |
static startEnd(string $id, string $label): self | |
static inputOutput(string $id, string $label): self |
FlowchartNodeType enum
Cases: Process · Decision · StartEnd · InputOutput · Connector · Data
PHP also provides cases(), from() and tryFrom().
Gantt final class
A Gantt chart component for project scheduling visualization.
| Method | Summary |
|---|---|
__construct(private ?int $maxTasks = null, private ?Color $barColor = null, private ?Color $milestoneColor = null, private ?Color $gridColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new Gantt chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this Gantt chart. |
withTask(GanttTask $task): self | Add a task to the chart. |
addTask(string $name, int $startDay, int $duration, ?Color $color = null): self | Add a task by parameters. |
withTasks(array $tasks): self | Set all tasks at once. |
withTimeRange(int $startDay, int $totalDays): self | Set the project time range. |
withTimeScale(TimeScale $scale): self | Set the time scale. |
withShowProgress(bool $show): self | Show or hide progress. |
withShowToday(bool $show): self | Show or hide today marker. |
render(): string | Render the Gantt chart as a string. |
innerSize(): array | Calculate the natural dimensions of this Gantt chart. |
withBarColor(?Color $color): self | Set the bar color. |
withMilestoneColor(?Color $color): self | Set the milestone color. |
withGridColor(?Color $color): self | Set the grid color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
GanttTask final class
A Gantt chart task with start time and duration.
| Method | Summary |
|---|---|
__construct(public readonly string $name, public readonly int $startDay, public readonly int $duration, public readonly ?Color $color = null, public readonly ?float $progress = null, public readonly bool $milestone = false) | |
withProgress(float $progress): self | Create a copy with progress. |
asMilestone(): self | Create a milestone variant. |
MindMap final class
A mind map component for hierarchical data visualization.
| Method | Summary |
|---|---|
__construct(private ?int $maxDepth = null, private MindMapDirection $direction = MindMapDirection::LeftRight, private ConnectionStyle $connectionStyle = ConnectionStyle::Rounded, private ?Color $rootColor = null, private ?Color $nodeColor = null, private ?Color $lineColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new mind map with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this mind map. |
withRoot(MindMapNode $root): self | Set the root node. |
withRootText(string $text): self | Set the root node text. |
withChild(string $text, ?Color $color = null, ?string $icon = null): self | Add a child to the root node. |
withCollapsed(bool $collapsed): self | Set collapsed state. |
render(): string | Render the mind map as a string. |
innerSize(): array | Calculate the natural dimensions of this mind map. |
withDirection(MindMapDirection $direction): self | Set the layout direction. |
withConnectionStyle(ConnectionStyle $style): self | Set the connection style. |
withRootColor(?Color $color): self | Set the root node color. |
withNodeColor(?Color $color): self | Set the node color. |
withLineColor(?Color $color): self | Set the line color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
MindMapDirection enum
Layout direction for mind map branches.
Cases: LeftRight · RightLeft · TopBottom · BottomTop
PHP also provides cases(), from() and tryFrom().
MindMapNode final class
A mind map node with optional children.
| Method | Summary |
|---|---|
__construct(public readonly string $text, public readonly ?Color $color = null, public readonly ?string $icon = null) | |
withChild(MindMapNode $child): self | Add a child node. |
addChild(string $text, ?Color $color = null, ?string $icon = null): self | Create a new child node and add it. |
Network final class
A network diagram component for visualizing connected data.
| Method | Summary |
|---|---|
__construct(private ?int $maxNodes = null, private ?Color $nodeColor = null, private ?Color $edgeColor = null, private ?Color $labelColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new network diagram with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this network diagram. |
withNode(NetworkNode $node): self | Add a node to the network. |
addNode(string $id, string $label, NetworkShape $shape = NetworkShape::Circle): self | Add a node by parameters. |
withNodes(array $nodes): self | Set all nodes at once. |
withEdge(array $edge): self | Add an edge between nodes. |
addEdge(string $from, string $to, ?string $label = null): self | Add an edge by parameters. |
withEdges(array $edges): self | Set all edges at once. |
withShowLabels(bool $show): self | Show or hide node labels. |
withShowWeights(bool $show): self | Show or hide edge weights. |
withDirected(bool $directed): self | Set directed mode (arrowheads) or undirected. |
withLayoutAlgorithm(string $algorithm): self | Set the layout algorithm. |
render(): string | Render the network diagram as a string. |
innerSize(): array | Calculate the natural dimensions of this network diagram. |
withNodeColor(?Color $color): self | Set the node color. |
withEdgeColor(?Color $color): self | Set the edge color. |
withLabelColor(?Color $color): self | Set the label color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
NetworkNode final class
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly NetworkShape $shape = NetworkShape::Circle, public readonly ?Color $color = null, public readonly ?string $icon = null) | |
withConnection(string $nodeId): self |
NetworkShape enum
Cases: Circle · Square · Diamond · Hexagon · Star
PHP also provides cases(), from() and tryFrom().
OrgChart final class
An organizational chart component for hierarchy visualization.
| Method | Summary |
|---|---|
__construct(private ?int $maxDepth = null, private OrgChartStyle $style = OrgChartStyle::TopDown, private ?Color $rootColor = null, private ?Color $nodeColor = null, private ?Color $lineColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $borderStyle = 'rounded') | |
static new(): self | Create a new org chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this org chart. |
withRoot(OrgChartNode $root): self | Set the root node. |
withRootByName(string $name, ?string $title = null): self | Set the root node by name. |
withReport(string $name, ?string $title = null, ?string $department = null, ?Color $color = null): self | Add a direct report to the root. |
withCollapsed(bool $collapsed): self | Set collapsed state. |
render(): string | Render the org chart as a string. |
innerSize(): array | Calculate the natural dimensions of this org chart. |
withStyle(OrgChartStyle $style): self | Set the layout style. |
withRootColor(?Color $color): self | Set the root color. |
withNodeColor(?Color $color): self | Set the node color. |
withLineColor(?Color $color): self | Set the line color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withBorderStyle(string $style): self | Set the border style. |
OrgChartNode final class
An organizational chart node with optional reports.
| Method | Summary |
|---|---|
__construct(public readonly string $name, public readonly ?string $title = null, public readonly ?string $department = null, public readonly ?Color $color = null, public readonly ?string $avatar = null) | |
withReport(OrgChartNode $report): self | Add a direct report. |
withReportByName(string $name, ?string $title = null, ?string $department = null): self | Add a direct report by name. |
OrgChartStyle enum
Organizational chart layout style.
Cases: TopDown · LeftRight · Tree
PHP also provides cases(), from() and tryFrom().
PERT final class
A PERT (Program Evaluation and Review Technique) chart component.
| Method | Summary |
|---|---|
__construct(private ?Color $nodeColor = null, private ?Color $arrowColor = null, private ?Color $textColor = null, private ?Color $criticalColor = null, private ?Color $pendingColor = null, private ?Color $inProgressColor = null, private ?Color $completedColor = null, private ?Color $delayedColor = null) | |
static new(): self | Create a new PERT chart with default styling. |
static sample(): self | Create a sample PERT chart for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this PERT chart. |
withTasks(array $tasks): self | Set all tasks at once. |
withTask(PertTask $task): self | Add a task. |
addTask(string $id, string $name, int $duration, array $dependencies = []): self | Add a task by parameters. |
withShowDuration(bool $show): self | Show or hide duration. |
withShowStatus(bool $show): self | Show or hide status. |
withCriticalPath(bool $show): self | Show or hide critical path. |
withShowGrid(bool $show): self | Show or hide grid. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the PERT chart as a string. |
innerSize(): array | Calculate the natural dimensions of this PERT chart. |
withNodeColor(?Color $color): self | Set the node color. |
withArrowColor(?Color $color): self | Set the arrow color. |
withTextColor(?Color $color): self | Set the text color. |
withCriticalColor(?Color $color): self | Set the critical path color. |
PertStatus enum
Status of a PERT task.
Cases: Pending · InProgress · Completed · Delayed
PHP also provides cases(), from() and tryFrom().
PertTask final class
A task node in a PERT chart.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $name, public readonly int $duration, public readonly ?Color $color = null, public PertStatus $status = PertStatus::Pending) | |
withDependencies(array $dependencies): self | Create a copy with dependencies. |
withColor(?Color $color): self | Create a copy with a different color. |
withStatus(PertStatus $status): self | Create a copy with a different status. |
withDuration(int $duration): self | Create a copy with a different duration. |
Sankey final class
A Sankey diagram component for flow visualization.
| Method | Summary |
|---|---|
__construct(private ?Color $nodeColor = null, private ?Color $flowColor = null, private ?Color $labelColor = null, private string $style = 'rounded') | |
static new(): self | Create a new Sankey diagram with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this Sankey diagram. |
withNode(SankeyNode $node): self | Add a node to the diagram. |
addNode(string $id, string $label, float $value, ?Color $color = null): self | Add a node by parameters. |
withNodes(array $nodes): self | Add all nodes at once. |
withFlow(SankeyFlow $flow): self | Add a flow to the diagram. |
addFlow(string $source, string $target, float $value, ?Color $color = null): self | Add a flow by parameters. |
withFlows(array $flows): self | Add all flows at once. |
withHorizontal(bool $horizontal): self | Set horizontal or vertical layout. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
render(): string | Render the Sankey diagram as a string. |
innerSize(): array | Calculate the natural dimensions of this Sankey diagram. |
withNodeColor(?Color $color): self | Set the node color. |
withFlowColor(?Color $color): self | Set the flow color. |
withLabelColor(?Color $color): self | Set the label color. |
withStyle(string $style): self | Set the border style. |
withNodeWidth(int $width): self | Set the node width. |
withNodeSpacing(int $spacing): self | Set the node spacing. |
SankeyFlow final class
A flow connection between two nodes in a Sankey diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $source, public readonly string $target, public readonly float $value, public readonly ?Color $color = null) | |
withColor(?Color $color): self | Create a copy with a different color. |
SankeyNode final class
A node in a Sankey diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly float $value, public readonly ?Color $color = null) | |
withColor(?Color $color): self | Create a copy with a different color. |
StateMachine final class
A state machine diagram component for visualizing system states and transitions.
| Method | Summary |
|---|---|
__construct(private ?Color $stateColor = null, private ?Color $initialColor = null, private ?Color $finalColor = null, private ?Color $transitionColor = null, private ?Color $textColor = null, private string $style_ = 'rounded') | |
static new(): self | Create a new state machine diagram with default styling. |
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this state diagram. |
withState(StateNode $state): self | Add a state to the diagram. |
addState(string $id, string $label, bool $isInitial = false, bool $isFinal = false): self | Add a state by parameters. |
withStates(array $states): self | Set all states at once. |
withTransition(StateTransition $transition): self | Add a transition to the diagram. |
addTransition(string $from, string $to, string $label): self | Add a transition by parameters. |
addGuard(string $from, string $to, string $condition): self | Add a guard transition. |
withTransitions(array $transitions): self | Set all transitions at once. |
withInitialState(string $stateId): self | Set the initial state ID. |
withShowActions(bool $show): self | Show or hide actions. |
withShowLabels(bool $show): self | Show or hide labels. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the state machine diagram as a string. |
innerSize(): array | Calculate the natural dimensions of this state diagram. |
withStateColor(?Color $color): self | Set the state color. |
withInitialColor(?Color $color): self | Set the initial state color. |
withFinalColor(?Color $color): self | Set the final state color. |
withTransitionColor(?Color $color): self | Set the transition color. |
withTextColor(?Color $color): self | Set the text color. |
withBorderStyle(string $style): self | Set the border style. |
StateNode final class
A state in a state machine diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly bool $isInitial = false, public readonly bool $isFinal = false, public readonly ?Color $color = null) | |
withEntry(string $action): self | Add an entry action. |
withExit(string $action): self | Add an exit action. |
withInternal(string $action): self | Add an internal action. |
static initial(string $id, string $label): self | Create an initial state. |
static final(string $id, string $label): self | Create a final state. |
static state(string $id, string $label): self | Create a normal state. |
StateTransition final class
A transition between states in a state machine diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $from, public readonly string $to, public readonly string $label, public readonly TransitionType $type = TransitionType::Normal, public readonly ?Color $color = null) | |
static guard(string $id, string $from, string $to, string $label): self | Create a guard transition (conditional). |
Sunburst final class
A Sunburst chart component for radial hierarchical visualization.
| Method | Summary |
|---|---|
__construct(private ?Color $segmentColor = null, private ?Color $textColor = null, private ?Color $centerColor = null) | |
static new(): self | Create a new Sunburst chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this Sunburst chart. |
withSegment(SunburstSegment $segment): self | Add a segment to the chart. |
addSegment(string $id, string $label, float $value, ?Color $color = null): self | Add a segment by parameters. |
withSegments(array $segments): self | Set all segments at once. |
withCenterLabel(string $label): self | Set the center label. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withMaxDepth(int $depth): self | Set maximum nesting depth. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the Sunburst chart as a string. |
innerSize(): array | Calculate the natural dimensions of this Sunburst chart. |
withSegmentColor(?Color $color): self | Set the default segment color. |
withTextColor(?Color $color): self | Set the text color. |
withCenterColor(?Color $color): self | Set the center circle color. |
SunburstSegment final class
A segment in a Sunburst chart.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly float $value, public readonly ?Color $color = null) | |
withChildren(array $children): self | Create a copy with children. |
withColor(?Color $color): self | Create a copy with a different color. |
totalValue(): float | Calculate total value including children. |
getTotalValue(): float | BC forwarder for the pre-rename accessor name. |
TimeScale enum
Gantt chart time scale.
Cases: Hours · Days · Weeks · Months
PHP also provides cases(), from() and tryFrom().
Timeline final class
A timeline component for displaying chronological events.
| Method | Summary |
|---|---|
__construct(private array $events, private string $lineStyle = 'solid', private HAlign $align = HAlign::Left, private bool $showDescriptions = true, private bool $showIcons = true, private bool $reverse = false) | |
static new(array $events): self | Create a new timeline with the given events. |
static mocha(array $events): self | Create a timeline with default Catppuccin Mocha colors. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this timeline. |
innerSize(): array | Calculate the natural dimensions of this timeline. |
render(): string | Render the timeline. |
withLineStyle(string $style): self | Set the line style. |
withAlign(HAlign $align): self | Set the alignment. |
withShowDescriptions(bool $show): self | Show or hide descriptions. |
withShowIcons(bool $show): self | Show or hide icons. |
withReverse(bool $reverse): self | Reverse the timeline order. |
TimelineEvent final readonly class
An event in a timeline.
| Method | Summary |
|---|---|
__construct(public string $time, public string $title, public ?string $description = null, public string $type = 'default') |
TimelineNode final readonly class
A node in a timeline.
| Method | Summary |
|---|---|
__construct(public string $label, public ?string $description = null) | |
static new(string $label, ?string $description = null): self | Create a new timeline node. |
static withMultiLineDescription(string $label, array $descriptionLines): self | Create a node with a multiline description. |
TimelineViz final class
A timeline visualization component for displaying events chronologically.
| Method | Summary |
|---|---|
__construct(private array $events = [], private bool $showMarkers = true, private bool $showDescriptions = true, private ?Color $lineColor = null, private ?Color $markerColor = null, private ?Color $textColor = null, private string $orientation = 'vertical') | |
static new(array $events = []): self | Create a new timeline visualization. |
static sample(): self | Create a sample timeline for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this timeline. |
render(): string | Render the timeline. |
innerSize(): array | Calculate the natural dimensions of this timeline. |
withEvents(array $events): self | Set the events. |
withShowMarkers(bool $show): self | Show or hide markers. |
withShowDescriptions(bool $show): self | Show or hide descriptions. |
withLineColor(?Color $color): self | Set the line color. |
withMarkerColor(?Color $color): self | Set the marker color. |
TransitionType enum
State machine transition types.
Cases: Normal · Guard · Internal
PHP also provides cases(), from() and tryFrom().
Tree final class
A hierarchical tree view component.
| Method | Summary |
|---|---|
__construct(private readonly array $nodes, private readonly bool $showLines = true, private readonly ?Color $nodeColor = null, private readonly ?Color $collapsedColor = null, private readonly string $branchChar = '├──', private readonly string $endChar = '└──', private readonly string $verticalChar = '│ ', private readonly string $spaceChar = ' ') | |
static new(array $nodes): self | Create a new tree with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this tree. |
render(): string | Render the tree component. |
innerSize(): array | Calculate the natural dimensions of this tree. |
withShowLines(bool $show): self | Toggle line display. |
withNodeColor(?Color $color): self | Set the color for expanded nodes. |
withCollapsedColor(?Color $color): self | Set the color for collapsed nodes. |
withBranchChars(string $branch, string $end): self | Set custom branch characters. |
withNodeCollapsed(string $key, bool $collapsed): self | Toggle a node's collapsed state. |
TreeNode final class
A node in the tree structure.
| Method | Summary |
|---|---|
__construct(public readonly string $id = '', public readonly string $label = '', public readonly float $value = 0.0, public readonly bool $collapsed = false, public readonly array $children = []) | |
static new(string $label): self | Create a new tree node with just a label. |
static withId(string $id, string $label): self | Create a new tree node with id and label. |
static collapsed(string $label): self | Create a collapsed tree node. |
withChildren(array $children): self | Create a node with children. |
withCollapsed(bool $collapsed): self | Set the collapsed state. |
TreeProvider interface
Interface for tree data providers.
| Method | Summary |
|---|---|
roots(): array | Get the root node(s) of the tree. |
children(string $nodeId): array | Get children of a specific node. |
node(string $nodeId): ?TreeNode | Get a node by its ID. |
hasChildren(string $nodeId): bool | Check if a node has children. |
depth(string $nodeId): int | Get the depth of a node in the tree. |
totalValue(): float | Get total value of all nodes (for proportional sizing). |
TreeViz final class
A tree visualization component for displaying hierarchical data.
| Method | Summary |
|---|---|
__construct(private readonly array $nodes = [], private readonly bool $showLines = true, private readonly bool $showLabels = true, private readonly ?Color $nodeColor = null, private readonly ?Color $lineColor = null, private readonly ?Color $labelColor = null, private readonly string $orientation = 'top-down') | |
static new(array $nodes = []): self | Create a new tree visualization. |
static sample(): self | Create a sample tree for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this tree. |
render(): string | Render the tree. |
innerSize(): array | Calculate the natural dimensions of this tree. |
withNodes(array $nodes): self | Set the nodes. |
withShowLines(bool $show): self | Show or hide connection lines. |
withShowLabels(bool $show): self | Show or hide labels. |
withOrientation(string $orientation): self | Set the orientation. |
TreeVizNode final readonly class
A node in a tree visualization.
| Method | Summary |
|---|---|
__construct(public string $label, public string $type = 'leaf', public array $children = []) | |
withChildren(array $children): self | Create a copy with children. |
Treemap final class
A treemap visualization component.
| Method | Summary |
|---|---|
__construct(private ?Color $borderColor = null, private ?Color $textColor = null, private ?Color $valueColor = null) | |
static new(array $leaves = []): self | Create a new treemap with default styling. |
static sample(int $count = 8): self | Create a sample treemap for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this treemap. |
withLeaves(array $leaves): self | Set all leaves at once. |
withLeaf(TreemapLeaf $leaf): self | Add a leaf to the treemap. |
addLeaf(string $id, string $label, float $value, ?Color $color = null): self | Add a leaf by parameters. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withShowBorders(bool $show): self | Show or hide borders. |
withBorderStyle(string $style): self | Set the border style. |
innerSize(): array | Calculate the natural dimensions of this treemap. |
render(): string | Render the treemap as a string. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
withValueColor(?Color $color): self | Set the value color. |
TreemapLeaf final class
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly float $value, public readonly ?Color $color = null, public readonly array $children = []) | |
withColor(?Color $color): self | |
withChildren(array $children): self |
UMLClass final class
A UML class in a class diagram.
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $name, public readonly ?string $package = null, public readonly bool $isAbstract = false, public readonly bool $isInterface = false, public readonly ?Color $color = null) | |
withAttribute(ClassMember $attribute): self | Add an attribute. |
withMethod(ClassMember $method): self | Add a method. |
withTemplateParam(string $param): self | Add a template parameter. |
attributes(): array | Get all attributes. |
getAttributes(): array | BC forwarder for the pre-rename accessor name. |
methods(): array | Get all methods. |
getMethods(): array | BC forwarder for the pre-rename accessor name. |
templateParams(): array | Get all template parameters. |
getTemplateParams(): array | BC forwarder for the pre-rename accessor name. |
Visibility enum
Visibility modifier for class members.
Cases: Public · Private · Protected · Package
PHP also provides cases(), from() and tryFrom().
SugarCraft\Dashboard\Foundation
Buffer final class
Sugar-dash immutable ANSI renderer Buffer (Sizer/Drawable pattern). Intentionally distinct from \SugarCraft\Vterm\Buffer\Buffer, which is a mutable VT-output grid (resize/cell/put/each). Different role: this composes layout output for inline-termui; the VT version stores terminal state during emulation.
| Method | Summary |
|---|---|
__construct(int $width, int $height) | |
static new(int $width, int $height): self | Create a new buffer with the given dimensions. |
cell(int $x, int $y): Cell | Get the Cell at the given coordinates. |
getCell(int $x, int $y): Cell | BC forwarder for the pre-rename accessor name. |
setCell(int $x, int $y, Cell $cell): self | Set a cell at the given coordinates (wither). |
fill(Rect $rect, Cell $cell): self | Fill a rectangular region with a cell (wither). |
setString(int $x, int $y, string $str, ?Style $style = null): self | Set a string starting at the given coordinates (wither). |
setRect(Rect $rect): self | Set the rectangle this buffer should fill (from Drawable). |
rect(): Rect | Get the rectangle this buffer occupies (from Drawable). |
draw(Buffer $buffer): void | Draw this buffer's content into the target buffer (from Drawable). |
render(): string | Render the buffer as an ANSI string. |
innerSize(): array | Get the inner dimensions of this buffer. |
clear(): self | Clear the buffer (wither). |
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this buffer. |
withTheme(Theme $theme): self | Buffers are passive drawing surfaces — theme application is a pass-through. |
Cell final readonly class
Sugar-dash Cell holds (rune, Style) for the inline-termui renderer. Intentionally distinct from \SugarCraft\Vterm\Cell\Cell, which holds (grapheme, Sgr, continuation, hyperlink) for VT emulation. Both are canonical for their lib.
| Method | Summary |
|---|---|
__construct(public string $rune, public Style $style) |
ColorMode final class
Process-wide color capability for every renderer in this library.
| Method | Summary |
|---|---|
static use(?ColorProfile $profile): void | Pin the capability explicitly; pass null to fall back to the chain. |
static profile(): ColorProfile | |
static resetForTesting(): void | Drop the memo and the override so the next read re-snapshots the environment. Test-only seam. |
Drawable interface
Anything that can be drawn into a Buffer at a specific Rect.
| Method | Summary |
|---|---|
rect(): Rect | Get the rectangle this drawable occupies. |
setRect(Rect $rect): self | Set the rectangle this drawable should fill. |
withTheme(Theme $theme): self | Apply a theme to this drawable, returning a new instance with the theme's colors. Default implementation returns $this (no-op) so existing drawables continue to work unchanged. |
draw(Buffer $buffer): void | Draw the content into the provided buffer. |
EdgeStyle enum
Cases: Solid · Dashed · Dotted · Bold
PHP also provides cases(), from() and tryFrom().
EnumCoerce final class
One implementation of the accept-both rule for knobs converging from a stringly vocabulary onto the enum that already models it (D-147).
| Method | Summary |
|---|---|
static from(\BackedEnum|string $value, string $enumClass, string $knobName): \BackedEnum | Coerce a legacy string or pass through the enum case for $knobName. |
GradientStore final class
Named 101-entry color ramps (index = percent), the registry a themed system monitor reads on every meter / graph cell — at('cpu', 73) is btop's Theme::g("cpu")[73].
| Method | Summary |
|---|---|
static new(): self | |
static fromStops(array $colors): self | Build from btop-style flat keys: every <name>_start entry yields a gradient <name> using <name>_mid / <name>_end when present. Keys without the _start suffix are ignored, as in generateGradients. |
static ramp(Color $start, ?Color $mid = null, ?Color $end = null): array | Expand start / mid / end into btop's 101-entry ramp (memoized). |
withGradient(string $name, Color $start, ?Color $mid = null, ?Color $end = null): self | Register (or replace) gradient $name. This is also how a consumer injects btop's pseudo-gradients, e.g. proc = main_fg → inactive_fg and proc_color = inactive_fg → process_start. |
at(string $name, int $percent): Color | Color at $percent of gradient $name; percent is clamped to 0..100. |
gradient(string $name): array | The full 101-entry ramp for $name. |
has(string $name): bool | |
names(): array |
Item interface
Anything that can be placed in a StackedGrid and rendered as a string.
| Method | Summary |
|---|---|
render(): string | Render the item to a string. |
Measurable interface
A box whose natural (chrome-inclusive) extent can be measured without first being allocated.
| Method | Summary |
|---|---|
naturalExtent(int $width): array | Chrome-inclusive natural size. |
NetAutoScale final class
btop's network-graph auto-scaling: a per-direction ceiling that only moves after a sustained run of samples above it (grow) or far below it (shrink), so a single spike or lull never makes the graph jump.
| Method | Summary |
|---|---|
static new(bool $sync = false): self | Fresh scaler. Like btop's Net::rescale{true}, the first offer always rescales, so the ceilings start at the first sample rather than 0. |
withSync(bool $sync): self | Toggle btop's net_sync (shared download/upload ceiling). |
offer(int $download, int $upload): self | Feed one collect tick (bytes/sec per direction) and return the next state. |
forceRescale(?array $downloadHistory = null, ?array $uploadHistory = null): self | Arm a rescale for the next offer() — btop's interface-change / loss path (and Net::rescale = true after a config change). Counters reset. Pass the newly selected interface's recent samples (oldest first) to swap the averaging window, since btop averages the NEW interface's bandwidth deque. These are the samples from BEFORE the coming tick: the next offer() appends its own sample, so do not include it here or it is counted twice. |
rescaleNow(?array $downloadHistory = null, ?array $uploadHistory = null): self | Rescale NOW from the held samples, without offering a new one — btop's Runner::run("net", no_update = true) after b/n/a/y, where Net::collect skips the counter pass but still runs the rescale pass with rescale = true, so the graph is redrawn against the new ceiling in the same frame instead of one tick later. |
downloadMax(): int | Current download ceiling in bytes/sec (0 until the first offer). |
uploadMax(): int | Current upload ceiling in bytes/sec (0 until the first offer). |
maxFor(string $direction): int | Ceiling for one direction. |
counters(string $direction): array | The [fast, slow] hysteresis counters for one direction. |
rescalePending(): bool | Whether a rescale is armed for the next offer. |
Rect final readonly class
Sugar-dash Rect uses the charmbracelet/rectmath bounds model (minX, minY, maxX, maxY). Intentionally distinct from \SugarCraft\Core\Rect, which uses the ratatui offset+size model (x, y, width, height). Both are canonical for their lib — choose by which upstream semantics the consumer needs.
| Method | Summary |
|---|---|
__construct(public int $minX, public int $minY, public int $maxX, public int $maxY) | |
contains(int $x, int $y): bool | Check if a point is inside the rectangle (inclusive). |
intersect(self $other): ?self | Compute the intersection of two rectangles, or null if no overlap. |
dx(): int | Width of the rectangle (maxX - minX + 1). |
dy(): int | Height of the rectangle (maxY - minY + 1). |
Segment final class
A 7-segment display component.
| Method | Summary |
|---|---|
__construct(private readonly string $content, private readonly int $digitWidth = 3, private readonly bool $showColon = true, private readonly ?Color $onColor = null, private readonly ?Color $offColor = null) | |
static new(string $content): self | Create a new 7-segment display with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this display. |
render(): string | Render the 7-segment display. |
innerSize(): array | Calculate the natural dimensions of this display. |
withDigitWidth(int $width): self | Set the digit width (horizontal size of each digit). |
withShowColon(bool $show): self | Show or hide the colon separator. |
withOnColor(?Color $color): self | Set the "on" (lit) segment color. |
withOffColor(?Color $color): self | Set the "off" (unlit) segment color. |
withContent(string $content): self | Set new content. |
SizedItem interface
A Sizer that can also report its intrinsic (unconstrained) size.
| Method | Summary |
|---|---|
innerSize(): array | Intrinsic size of the item as currently configured: [width, height] in terminal cells. Zeroes mean "measure me by rendering". |
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this item. |
render(): string | Render the item to a string. |
Sizer interface
An Item that knows its own dimensions.
| Method | Summary |
|---|---|
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this item. |
render(): string | Render the item to a string. |
Style final readonly class
Sugar-dash inline-termui Style. Intentionally distinct from \SugarCraft\Style\Style — this carries the inline-termui layout-engine semantics (toAnsi(ColorProfile), inline foreground/ background slots) while Sprinkles\Style carries the lipgloss padding/margin/borders semantics. Both are canonical for their lib — do NOT alias one to the other.
| Method | Summary |
|---|---|
__construct(public ?Color $foreground = null, public ?Color $background = null, public bool $bold = false, public bool $dim = false, public bool $italic = false, public bool $underline = false, public bool $reverse = false, public bool $strike = false) | |
toAnsi(?ColorProfile $profile = null): string | Render this style as ANSI SGR sequences. |
withForeground(Color $color): self | Apply this style's attributes to a foreground Color. |
withBackground(Color $color): self | Apply this style's attributes to a background Color. |
withBold(bool $value = true): self | Add bold modifier. |
StyleParser final class
Parses termui-style inline style strings into Cell arrays.
| Method | Summary |
|---|---|
static parse(string $input, Style $defaultStyle): array | Parse a styled string into a list of Cells. |
Theme final class
Sugar-dash inline-termui Theme (9 colour slots + name, accessors, color()/fg()/bg() helpers, and one wither per slot). Foundation layer: it depends on nothing in this library above Foundation — widgets that want themed styling are built by their own layers (see Bar::themed()), never by a factory here (finding 138). Intentionally distinct from \SugarCraft\Style\Theme (13 colour slots: adds muted, info, border, separator, cursor; readonly properties only, no helper methods). Both are canonical for their lib.
| Method | Summary |
|---|---|
__construct(private readonly string $name, private readonly Color $foreground, private readonly Color $background, private readonly Color $primary, private readonly Color $secondary, private readonly Color $accent, private readonly Color $error, private readonly Color $warning, private readonly Color $success, private readonly Color $highlight) | |
static dark(): self | Create the default dark theme (Tokyo Night inspired). |
static dracula(): self | Create the Dracula theme. |
static oneDark(): self | Create the One Dark theme. |
static githubDark(): self | Create the GitHub Dark theme. |
static light(): self | Create a light theme. |
name(): string | Get the theme name. |
getName(): string | BC forwarder for the pre-rename accessor name. |
foreground(): Color | Get the foreground color. |
background(): Color | Get the background color. |
primary(): Color | Get the primary color. |
secondary(): Color | Get the secondary color. |
accent(): Color | Get the accent color. |
error(): Color | Get the error color. |
warning(): Color | Get the warning color. |
success(): Color | Get the success color. |
highlight(): Color | Get the highlight color. |
color(string $name): ?Color | Get a color by name. |
fg(?ColorProfile $profile = null): string | Get the ANSI escape sequence for the foreground color. |
bg(?ColorProfile $profile = null): string | Get the ANSI escape sequence for the background color. |
withName(string $name): self | Create a new theme with a different name. |
withForeground(Color $color): self | Create a new theme with different foreground color. |
withBackground(Color $color): self | Create a new theme with different background color. |
withPrimary(Color $color): self | Create a new theme with different primary color. |
withSecondary(Color $color): self | Create a new theme with different secondary color. |
withAccent(Color $color): self | Create a new theme with different accent color. |
withError(Color $color): self | Create a new theme with different error color. |
withWarning(Color $color): self | Create a new theme with different warning color. |
withSuccess(Color $color): self | Create a new theme with different success color. |
withHighlight(Color $color): self | Create a new theme with different highlight color. |
Threshold final class
Maps a numeric value (typically a 0..1 ratio) to a Color via ordered stops — the "green below 60%, yellow below 80%, red above" pattern that gauges, meters, and status indicators reinvent everywhere.
| Method | Summary |
|---|---|
static of(array $stops): self | Build from [limit, Color] pairs in any order; they are sorted ascending by limit. |
static health(?Color $ok = null, ?Color $warn = null, ?Color $critical = null): self | The canonical health ramp: green for < 0.6, yellow for < 0.8, red at or above 0.8. Colors are overridable for theming. |
colorFor(float $value): Color | Resolve the color for a value. |
stops(): array |
SugarCraft\Dashboard\Keys
Category enum
Category constants for key bindings.
Cases: Navigation · Editing · View · General · Debug
PHP also provides cases(), from() and tryFrom().
| Method | Summary |
|---|---|
label(): string | Get the display label for this category. |
Key final class
Represents a keyboard key combination.
| Method | Summary |
|---|---|
__construct(public readonly string $key, public readonly bool $ctrl = false, public readonly bool $alt = false, public readonly bool $shift = false) | |
withCtrl(): self | Create a key with Ctrl modifier. |
withAlt(): self | Create a key with Alt modifier. |
withShift(): self | Create a key with Shift modifier. |
toString(): string | Get the normalized key string representation. |
matches(string $key, bool $ctrl = false, bool $alt = false, bool $shift = false): bool | Check if this key matches a given key string and modifiers. |
KeyAction final class
Represents an action triggered by a key combination.
| Method | Summary |
|---|---|
__construct(public readonly string $name, public readonly mixed $execute) | |
execute(Key $key): \SugarCraft\Dashboard\Foundation\Item | Execute the action with the given key. |
KeyIdentifier final class
Unique identifier for a key binding.
| Method | Summary |
|---|---|
__construct(public readonly string $value) | |
static of(string $value): self | Create from a string. |
static quit(): self | Create the standard identifiers. |
static help(): self | |
static refresh(): self | |
static focusNext(): self | |
static focusPrev(): self |
KeyMap final class
Keyboard shortcut handler.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new keymap with default styling. |
render(): string | Render the content managed by this keymap. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this keymap. |
innerSize(): array | Get the dimensions of the managed content. |
on(string $key, callable $action, bool $ctrl = false, bool $alt = false, bool $shift = false): self | Register an action for a key combination. |
onAny(callable $action): self | Register a global action that fires on any key. |
off(string $key, bool $ctrl = false, bool $alt = false, bool $shift = false): self | Remove an action by key combination. |
handle(Key $key): array | Handle a key event and return the new state. |
has(string $key, bool $ctrl = false, bool $alt = false, bool $shift = false): bool | Check if a key combination is registered. |
registeredKeys(): array | Get all registered key combinations. |
getRegisteredKeys(): array | BC forwarder for the pre-rename accessor name. |
hasGlobalActions(): bool | Check if any global actions are registered. |
withContent(\SugarCraft\Dashboard\Foundation\Item $content): self | Set new content. |
withAction(string $key, callable $action): self | Create a new KeyMap with an action registered for a simple key. |
KeyMeta final class
Metadata for a key binding.
| Method | Summary |
|---|---|
__construct(public readonly KeyIdentifier $id, public readonly Key $key, public readonly string $description, public readonly string $category = 'general') | |
display(): string | Get the display string for this binding. |
fullDescription(): string | Get the full description with category. |
KeyRegistry final class
Central registry for key bindings.
| Method | Summary |
|---|---|
static register(KeyIdentifier $id, Key $key, string $description, string $category = 'general'): void | Register a key binding. |
static get(KeyIdentifier|string $id): ?KeyMeta | Get a binding by ID. |
static byCategory(string $category): array | Get all bindings for a category. |
static categories(): array | Get all registered categories. |
static match(Key $key): ?KeyMeta | Check if a key matches any registered binding. |
static reset(): void | Reset the registry (useful for testing). |
SugarCraft\Dashboard\Layout
AlignItems enum
Align items enum for FlexLayout.
Cases: Start · End · FlexStart · FlexEnd · Center · Stretch · Baseline
PHP also provides cases(), from() and tryFrom().
Breakpoint final class
Static helpers for responsive layout breakpoints.
| Method | Summary |
|---|---|
static narrow(int $width, int $threshold = 90): bool | True when the terminal width is considered narrow. |
static medium(int $width, int $narrow = 90, int $wide = 140): bool | True when the terminal width is in the "medium" range. |
static wide(int $width, int $threshold = 140): bool | True when the terminal width is considered wide. |
static pick(int $width, array $thresholds): string | Pick a bucket name from a thresholds map based on current width. |
Center final class
A centered content layout component.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly int $minWidth = 0, private readonly int $minHeight = 0) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new centered layout with the given content. |
static withMin(\SugarCraft\Dashboard\Foundation\Item $content, int $minWidth, int $minHeight): self | Create a new centered layout with minimum dimensions. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this center layout. |
render(): string | Render the centered content. |
innerSize(): array | Calculate the natural dimensions of this layout. |
withMinWidth(int $minWidth): self | Set the minimum width. |
withMinHeight(int $minHeight): self | Set the minimum height. |
withContent(\SugarCraft\Dashboard\Foundation\Item $content): self | Set the content. |
FlexDirection enum
Flex direction enum for FlexLayout.
Cases: Row · Column · RowReverse · ColumnReverse
PHP also provides cases(), from() and tryFrom().
FlexLayout final class
A flexbox-style layout component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly FlexDirection $direction = FlexDirection::Row, private readonly FlexWrap $wrap = FlexWrap::NoWrap, private readonly JustifyContent $justify = JustifyContent::Start, private readonly AlignItems $alignItems = AlignItems::Start, private readonly int $gap = 0) | |
static row(array $items = []): self | Create a new flex layout with row direction. |
static column(array $items = []): self | Create a new flex layout with column direction. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this flex layout. |
render(): string | Render the flex layout. |
innerSize(): array | Calculate the natural dimensions of this layout. |
withItem(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the flex layout. |
withDirection(FlexDirection $direction): self | Set the flex direction. |
withWrap(FlexWrap $wrap): self | Set the flex wrap mode. |
withJustify(JustifyContent $justify): self | Set the justify content property. |
withAlignItems(AlignItems $alignItems): self | Set the align items property. |
withGap(int $gap): self | Set the gap between items. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
FlexWrap enum
Flex wrap enum for FlexLayout.
Cases: NoWrap · Wrap · WrapReverse
PHP also provides cases(), from() and tryFrom().
FocusManager final class
Manages focus state for a layout hierarchy.
| Method | Summary |
|---|---|
__construct(private readonly string $rootId = 'root') | |
focus(string|int $id): self | Move focus to a REGISTERED panel. |
blur(string $id): self | Drop the focused flag for a REGISTERED panel. |
isFocused(string $id): bool | |
focusedId(): ?string | |
getFocusedId(): ?string | BC forwarder for the pre-rename accessor name. |
focusNext(): self | |
focusPrevious(): self | |
register(string|int $id): self | |
unregister(string|int $id): self | |
persistState(Persistence $persistence, string $path): void | Save focus state to disk via the persistence layer. |
restoreState(Persistence $persistence, string $path): self | Restore focus state from disk. |
restoreNotice(): ?string | Why the last restoreState() skipped or repaired something, or null if the last restore was clean. The reason is surfaced, not swallowed — the chrome or log line that shows it is the consumer's call. |
Frame final class
A bordered frame that wraps any Item.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly ?Border $border = null, private readonly ?Color $borderColor = null, private readonly array $padding = [1, 1, 1, 1], private readonly ?string $title = null, private readonly VAlign $verticalAlign = VAlign::Top) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a frame with the default rounded border and purple accent. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this frame. |
render(): string | Render the frame with its content. |
innerSize(): array | Calculate the inner area available for content after borders are subtracted (before padding). |
naturalExtent(int $width): array | Chrome-inclusive natural extent (Measurable, finding 032): the two border rows/columns plus the padding ring on top of whatever the content wants. Content is measured at its own natural render — allocation-free, so this never bounces off the raw-passthrough legs. |
withBorder(Border $border): self | |
withBorderColor(Color $color): self | |
withPadding(int $n): self | |
withPaddingXY(int $vertical, int $horizontal): self | |
withTitle(string $title): self | |
withVerticalAlign(VAlign $align): self | |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
GridItem final class
Represents an item positioned in a GridLayout.
| Method | Summary |
|---|---|
__construct(public readonly \SugarCraft\Dashboard\Foundation\Item $content, public readonly int $column = 0, public readonly int $row = 0, public readonly int $columnSpan = 1, public readonly int $rowSpan = 1) |
GridLayout final class
A CSS Grid-style layout component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], int $columns = 1, int $rows = 0, int $columnGap = 0, int $rowGap = 0) | GridLayout walks the plain array positionally — the GridItem wrapper class is never read here. Every element is used as a bare Item (render(), setSize()/innerSize() behind instanceof guards). |
static columns(int $columns, array $items = []): self | Create a new grid layout with the specified columns. |
static rows(int $rows, array $items = []): self | Create a new grid layout with fixed rows. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this grid layout. |
render(): string | Render the grid layout. |
innerSize(): array | Calculate the natural dimensions of this layout. |
withItem(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the grid layout. |
withItems(array $items): self | Set the items in this grid layout. |
withColumns(int $columns): self | Set the number of columns. |
withRows(int $rows): self | Set the number of rows. |
withColumnGap(int $gap): self | Set the column gap. |
withRowGap(int $gap): self | Set the row gap. |
withGap(int $gap): self | Set both column and row gaps. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
HAlign enum
Horizontal text alignment enum.
Cases: Left · Right · Center
PHP also provides cases(), from() and tryFrom().
HStack final class
A horizontal stack layout component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly int $spacing = 0, private readonly HAlign $alignment = HAlign::Left) | |
static new(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a new horizontal stack with default styling. |
static spaced(int $spacing, \SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a horizontal stack with spacing between items. |
static centered(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a horizontally centered stack. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stack. |
render(): string | Render the stack as a single line string. |
innerSize(): array | Calculate the natural dimensions of this stack. |
withItems(array $items): self | Set the items in this stack. |
withAppended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the end of the stack. |
withPrepended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the beginning of the stack. |
withSpacing(int $spacing): self | Set the spacing between items. |
withAlignment(HAlign $alignment): self | Set the horizontal alignment. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
JustifyContent enum
Justify content enum for FlexLayout.
Cases: Start · End · FlexStart · FlexEnd · Center · SpaceBetween · SpaceAround · SpaceEvenly
PHP also provides cases(), from() and tryFrom().
Layout final class
Advanced layout algorithm for arranging multiple items.
| Method | Summary |
|---|---|
__construct(private readonly array $children, private readonly LayoutDirection $direction = LayoutDirection::Horizontal, private readonly int $gap = 0, private readonly HAlign $horizontalAlign = HAlign::Left, private readonly VAlign $verticalAlign = VAlign::Top, private readonly ?int $width = null, private readonly ?int $height = null) | |
static horizontal(array $children = []): self | Create a new horizontal layout. |
static vertical(array $children = []): self | Create a new vertical layout. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this layout. |
render(): string | Render the layout and all children. |
static clipToHeight(string $block, int $height): string | Shared height discipline for render exits (finding sugar-dashboard-030): a box that was given a real allocation prints exactly that many rows. Content taller than the frame clips here - once, at the exit - instead of stranding rows past the bottom of the frame (and past the bottom of the terminal, when the box is the screen itself). A zero or unset allocation is a pass-through: unallocated boxes answer with their natural height, never a clipped one. |
innerSize(): array | Calculate the natural dimensions of this layout. |
withGap(int $gap): self | Set the gap between children. |
withHorizontalAlign(HAlign $align): self | Set the horizontal alignment. |
withVerticalAlign(VAlign $align): self | Set the vertical alignment. |
withDirection(LayoutDirection $direction): self | Set the direction. |
withChildren(array $children): self | Set the children. |
withChild(\SugarCraft\Dashboard\Foundation\Item $content, int $flex = 0): self | Add a child to the layout. |
LayoutDirection enum
Direction for layout arrangement.
Cases: Horizontal · Vertical
PHP also provides cases(), from() and tryFrom().
LayoutItem final class
An item within a layout with flex properties.
| Method | Summary |
|---|---|
__construct(public readonly \SugarCraft\Dashboard\Foundation\Item $content, public readonly int $flex = 0) | |
static flex(\SugarCraft\Dashboard\Foundation\Item $content, int $flex = 1): self | Create a LayoutItem with flex grow behavior. |
static fixed(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a LayoutItem that takes its natural size. |
Pad final class
A general-purpose boxing/wrapping component that adds padding around content.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly array $padding = [0, 0, 0, 0], private readonly bool $border = false, private readonly VAlign $verticalAlign = VAlign::Top) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a pad with default settings (no padding, no border). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this pad. |
render(): string | Render the pad with its content. |
innerSize(): array | Calculate the inner area available for content after padding is subtracted (but before any border). |
naturalExtent(int $width): array | Chrome-inclusive natural extent (Measurable, finding 032): the padding ring (and the one-cell border ring when border is on) on top of the content's own allocation-free render. |
withPadding(int $n): self | Set uniform padding on all sides. |
withPaddingXY(int $vertical, int $horizontal): self | Set padding with separate vertical and horizontal values. |
withPaddingArray(array $padding): self | Set padding for each side individually. |
withBorder(bool $border): self | Enable or disable the border. |
withVerticalAlign(VAlign $align): self | Set the vertical alignment. |
Panel final class
A panel component with header and footer sections.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item|string $content, private readonly ?string $title = null, private readonly \SugarCraft\Dashboard\Foundation\Item|string|null $header = null, private readonly \SugarCraft\Dashboard\Foundation\Item|string|null $footer = null, private readonly ?Color $borderColor = null, private readonly ?Color $titleColor = null, private readonly string $style = 'single') | |
static new(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Create a new panel with default styling. |
static titled(\SugarCraft\Dashboard\Foundation\Item|string $content, string $title): self | Create a panel with a title. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this panel. |
render(): string | Render the panel as a string. |
innerSize(): array | Calculate the natural dimensions of this panel. |
withContent(\SugarCraft\Dashboard\Foundation\Item|string $content): self | Set the panel content. |
withTitle(?string $title): self | Set the panel title. |
withHeader(\SugarCraft\Dashboard\Foundation\Item|string|null $header): self | Set the panel header content. |
withFooter(\SugarCraft\Dashboard\Foundation\Item|string|null $footer): self | Set the panel footer. |
withBorderColor(?Color $color): self | Set the border color. |
withTitleColor(?Color $color): self | Set the title color. |
withStyle(string $style): self | Set the border style. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
Screen final class
Full screen management for TUI applications.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly bool $alternateScreen = true, private readonly bool $showCursor = false, private readonly bool $enableMouse = false) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new screen with default settings. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this screen. |
render(): string | Render one frame: clear, home, content. |
setup(): string | Session preamble: enter the alternate screen, hide the cursor, enable mouse tracking. Emit ONCE before the first render(). |
teardown(): string | Session trailer matching setup(): disable mouse tracking, restore the cursor and leave the alternate screen. Pair with the same configuration the preamble was built from. |
innerSize(): array | Calculate the natural dimensions of this screen. |
static clear(): string | Clear the entire screen. |
static moveCursor(int $x, int $y): string | Move cursor to a specific position. |
static hide(): string | Hide the cursor. |
static show(): string | Show the cursor. |
withAlternateScreen(bool $enable): self | Enable or disable alternate screen buffer. |
withShowCursor(bool $show): self | Enable or disable cursor visibility. |
withEnableMouse(bool $enable): self | Enable or disable mouse tracking. |
withContent(\SugarCraft\Dashboard\Foundation\Item $content): self | Set new content. |
withAlternateScreenEnabled(): self | Enable alternate screen buffer. |
withAlternateScreenDisabled(): self | Disable alternate screen buffer. |
Sidebar final class
A vertical sidebar navigation component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly ?string $title = null, private readonly ?Color $borderColor = null, private readonly ?Color $activeColor = null, private readonly ?Color $inactiveColor = null, private readonly ?Color $bgColor = null, private readonly bool $collapsed = false) | |
static new(array $items = []): self | Create a new sidebar with default styling. |
static title(string $title, array $items = []): self | Create a sidebar with a title. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this sidebar. |
render(): string | Render the sidebar as a string. |
innerSize(): array | Calculate the natural dimensions of this sidebar. |
withItems(array $items): self | Set the sidebar items. |
withTitle(?string $title): self | Set the sidebar title. |
withBorderColor(?Color $color): self | Set the border color. |
withActiveColor(?Color $color): self | Set the active item color. |
withInactiveColor(?Color $color): self | Set the inactive item color. |
withBgColor(?Color $color): self | Set the background color. |
withCollapsed(bool $collapsed): self | Set the collapsed mode. |
withActiveItem(int $index): self | Mark an item as active by index. |
Spacer final class
A spacer component that renders empty space.
| Method | Summary |
|---|---|
__construct(private readonly int $width = 1, private readonly int $height = 1, private readonly string $fillChar = ' ') | |
static new(int $width = 1, int $height = 1): self | Create a new spacer with default styling. |
static dotted(int $width = 40): self | Create a dotted spacer line (useful for visual separation). |
static dashed(int $width = 40): self | Create a dashed spacer line (useful for visual separation). |
static vertical(int $width = 1, int $height = 10): self | Create a vertical spacer (column of fill characters). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this spacer. |
render(): string | Render the spacer as a string. |
innerSize(): array | Calculate the natural dimensions of this spacer. |
withWidth(int $width): self | Set the width of this spacer. |
withHeight(int $height): self | Set the height of this spacer. |
withSize(int $width, int $height): self | Set both width and height. |
withFillChar(string $char): self | Set the fill character. |
Split final class
A container that splits the available space between multiple components.
| Method | Summary |
|---|---|
__construct(private readonly array $panes, private readonly SplitDirection $direction = SplitDirection::Horizontal, private readonly array $ratios = [], private readonly ?Color $dividerColor = null, private readonly bool $showDividers = true, private readonly int $dividerSize = 1) | |
static horizontal(array $panes, array $ratios = []): self | Create a new horizontal split (side-by-side panes). |
static vertical(array $panes, array $ratios = []): self | Create a new vertical split (stacked panes). |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this split. |
innerSize(): array | Calculate the natural dimensions of this split. |
render(): string | Render the split container. |
withDirection(SplitDirection $direction): self | Set the split direction. |
withRatios(array $ratios): self | Set the pane ratios. |
withShowDividers(bool $show): self | Show or hide dividers between panes. |
withDividerColor(?Color $color): self | Set the divider color. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
SplitDirection enum
Split direction for the Split container.
Cases: Horizontal · Vertical
PHP also provides cases().
Stack final class
A vertical stack layout component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly int $spacing = 0) | |
static new(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a new vertical stack with default styling. |
static spaced(int $spacing, \SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a vertical stack with spacing between items. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stack. |
render(): string | Render the stack as a string. |
innerSize(): array | Calculate the natural dimensions of this stack. |
withItems(array $items): self | Add items to the stack. |
withAppended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the end of the stack. |
withPrepended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the beginning of the stack. |
withSpacing(int $spacing): self | Set the spacing between items. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
StackLayout final class
A stack layout that arranges items in a stack (vertical by default).
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly int $spacing = 0, private readonly LayoutDirection $direction = LayoutDirection::Vertical) | |
static vertical(Item ...$items): self | |
static horizontal(Item ...$items): self | |
setSize(int $width, int $height): Sizer | |
render(): string | |
innerSize(): array | |
withItems(array $items): self | |
withSpacing(int $spacing): self |
VAlign enum
Vertical alignment enum for paragraphs.
Cases: Top · Middle · Bottom
PHP also provides cases(), from() and tryFrom().
VStack final class
A vertical stack layout component with alignment options.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly int $spacing = 0, private readonly HAlign $alignment = HAlign::Left) | |
static new(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a new vertical stack with default styling (left-aligned). |
static spaced(int $spacing, \SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a vertical stack with spacing between items. |
static centered(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a vertically centered stack (items centered horizontally). |
static right(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a right-aligned vertical stack. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stack. |
render(): string | Render the stack as a string. |
innerSize(): array | Calculate the natural dimensions of this stack. |
withItems(array $items): self | Set the items in this stack. |
withAppended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the end of the stack. |
withPrepended(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the beginning of the stack. |
withSpacing(int $spacing): self | Set the spacing between items. |
withAlignment(HAlign $alignment): self | Set the horizontal alignment. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
Viewport final class
A scrollable viewport for content.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly int $scrollX = 0, private readonly int $scrollY = 0, private readonly ?Color $background = null, private readonly ?int $width = null, private readonly ?int $height = null) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content): self | Create a new viewport with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this viewport. |
render(): string | Render the viewport as a string (multi-line). |
innerSize(): array | Calculate the natural dimensions of this viewport. |
withScrollX(int $scrollX): self | Set the scroll position (X coordinate). |
withScrollY(int $scrollY): self | Set the scroll position (Y coordinate). |
withScroll(int $scrollX, int $scrollY): self | Set both scroll coordinates. |
withBackground(?Color $color): self | Set the background color. |
scrollBy(int $deltaX, int $deltaY): self | Scroll the viewport by the given delta. |
canScroll(): bool | Check if scrolling is possible in any direction. |
Window final class
A window component with a title bar and content area.
| Method | Summary |
|---|---|
__construct(private readonly \SugarCraft\Dashboard\Foundation\Item $content, private readonly ?string $title = null, private readonly ?Color $titleColor = null, private readonly ?Color $borderColor = null, private readonly array $padding = [1, 1, 1, 1], private readonly string $controls = self::ControlsNone, private readonly bool $showShadow = false, private readonly VAlign $verticalAlign = VAlign::Top) | |
static new(\SugarCraft\Dashboard\Foundation\Item $content, ?string $title = null): self | Create a new window with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this window. |
render(): string | Render the window with title bar and content. |
innerSize(): array | Calculate the inner area available for content. |
naturalExtent(int $width): array | Chrome-inclusive natural extent (Measurable, finding 032): borders, the title row and the padding ring on top of the content's own allocation-free render. |
withTitle(?string $title): self | Set the window title. |
withTitleColor(?Color $color): self | Set the title color. |
withBorderColor(?Color $color): self | Set the border color. |
withPadding(int $n): self | Set uniform padding on all sides. |
withPaddingXY(int $vertical, int $horizontal): self | Set padding with separate vertical and horizontal values. |
withControls(string $controls): self | Set the window control buttons. |
withShadow(bool $show): self | Enable or disable the shadow effect. |
withVerticalAlign(VAlign $align): self | Set the vertical alignment. |
ZStack final class
A layered stack layout component.
| Method | Summary |
|---|---|
__construct(private readonly array $items = [], private readonly HAlign $alignment = HAlign::Center, private readonly VAlign $vAlignment = VAlign::Middle) | |
static new(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a new layered stack with default styling. |
static left(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a layered stack with all items left-aligned. |
static right(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a layered stack with all items right-aligned. |
static top(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a layered stack with all items top-aligned. |
static bottom(\SugarCraft\Dashboard\Foundation\Item ...$items): self | Create a layered stack with all items bottom-aligned. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this stack. |
render(): string | Render the layered stack as a string. |
innerSize(): array | Calculate the natural dimensions of this stack. |
withItems(array $items): self | Set the items in this stack. |
withTop(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the top of the stack. |
withBottom(\SugarCraft\Dashboard\Foundation\Item $item): self | Add an item to the bottom of the stack. |
withAlignment(HAlign $alignment): self | Set the horizontal alignment. |
withVAlignment(VAlign $alignment): self | Set the vertical alignment. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
SugarCraft\Dashboard\Layout\Boxer
Boxer final class
A tree-based layout engine for rendering multiple Items in a hierarchical structure.
| Method | Summary |
|---|---|
__construct(private readonly Node $root, array $modelMap = [], private readonly int $width = 0, private readonly int $height = 0) | |
static leaf(string $address, Item $model): self | Create a new Boxer with a single leaf node. |
static tree(Node $root, array $modelMap = []): self | Create a new Boxer with a tree structure of nodes. |
static horizontal(Node ...$children): self | Create a horizontal layout with children arranged side by side. |
static vertical(Node ...$children): self | Create a vertical layout with children stacked top to bottom. |
editLeaf(string $address, callable $editFunc): self | Edit a leaf node's content, returning a new Boxer with the changes. |
setSize(int $width, int $height): Sizer | Set the allocated dimensions and propagate to the tree. |
render(): string | Render the boxer layout to a string. |
root(): Node | |
getRoot(): Node | BC forwarder for the pre-rename accessor name. |
modelMap(): array | |
getModelMap(): array | BC forwarder for the pre-rename accessor name. |
width(): int | |
getWidth(): int | BC forwarder for the pre-rename accessor name. |
height(): int | |
getHeight(): int | BC forwarder for the pre-rename accessor name. |
item(string $address): ?Item | Get the item at a given address. |
getItem(string $address): ?Item | BC forwarder for the pre-rename accessor name. |
node(string $address): ?Node | Get the node at a given address. |
getNode(string $address): ?Node | BC forwarder for the pre-rename accessor name. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
persistState(Persistence $persistence, string $path, array $collapsedAddresses = []): void | Persist the layout engine's collapsed-panel addresses to disk. |
restoreState(Persistence $persistence, string $path): array | Restore the persisted collapsed-addresses list. |
Node final class
A node in the boxer layout tree.
| Method | Summary |
|---|---|
__construct(private readonly array $children = [], private readonly bool $verticalStacked = false, private readonly ?\Closure $sizeFunc = null, private readonly bool $noBorder = false, private readonly string $address = '', private readonly int $width = 0, private readonly int $height = 0) | |
static leaf(string $address): self | Create a leaf node with the given address. |
static horizontal(Node ...$children): self | Create a horizontal branch node (children arranged side by side). |
static vertical(Node ...$children): self | Create a vertical branch node (children stacked top to bottom). |
static withSizeFunc(\Closure $sizeFunc, Node ...$children): self | Create a node with a custom size function. |
static noBorder(Node ...$children): self | Create a node that doesn't draw borders. |
children(): array | |
getChildren(): array | BC forwarder for the pre-rename accessor name. |
isLeaf(): bool | |
address(): string | |
getAddress(): string | BC forwarder for the pre-rename accessor name. |
width(): int | |
getWidth(): int | BC forwarder for the pre-rename accessor name. |
height(): int | |
getHeight(): int | BC forwarder for the pre-rename accessor name. |
isVerticalStacked(): bool | |
hasNoBorder(): bool | |
setSize(int $width, int $height): self | Create a new node with updated dimensions. |
withChildren(array $children): self | Create a new node with updated children. |
withVerticalStacked(bool $verticalStacked): self | Create a new node with a different orientation. |
withCustomSizeFunc(?\Closure $sizeFunc): self | Create a new node with a custom size function. |
withBorder(bool $border): self | Create a new node with borders enabled or disabled between children. |
updateSizeRecursive(int $totalWidth, int $totalHeight): self | Update the size of this node and its children recursively. |
renderTree(array $modelMap, int $width, int $height): array|string|\SugarCraft\Dashboard\Layout\Boxer\SizeError | Render this node and its children to a list of lines. |
render(): string | Dummy render for Item interface - use render() with modelMap instead. |
NotFoundError final class
Error thrown when a leaf address is not found in the model map.
SizeError final class
Error thrown when there is not enough space for nodes in the layout tree.
SugarCraft\Dashboard\Layout\Grid
ItemOptions final readonly class
Per-item placement options within a StackedGrid.
| Method | Summary |
|---|---|
__construct(public int $column = 0, public bool $expandVertical = false) |
Options final readonly class
Grid-level configuration options.
| Method | Summary |
|---|---|
__construct(public bool $fitScreen = true) |
StackedGrid final class
Multi-column stacked grid layout.
| Method | Summary |
|---|---|
__construct(private readonly Options $options = new Options()) | |
withItem(\SugarCraft\Dashboard\Foundation\Item $item, ItemOptions $options = new ItemOptions()): self | Return a new grid with the item appended at the given placement. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Propagate terminal dimensions to the grid, returning a sized clone. |
render(): string | Render the entire grid. |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
persistState(Persistence $persistence, string $path, array $collapsedAddresses = []): void | Persist the layout engine's collapsed-panel addresses to disk. |
restoreState(Persistence $persistence, string $path): array | Restore the persisted collapsed-addresses list. |
SugarCraft\Dashboard\Layout\RatioGrid
GridItem final class
A grid item with ratio-based sizing.
| Method | Summary |
|---|---|
__construct(public readonly mixed $content, public readonly float $rowSpan = 1.0, public readonly float $colSpan = 1.0) | |
static full(mixed $content): self |
NewColRow final class
Represents a new column or row in a ratio grid.
| Method | Summary |
|---|---|
__construct(public readonly float $ratio = 1.0, public readonly ?int $fixed = null) | |
static ratio(float $ratio): self | |
static fixed(int $size): self |
RatioGrid final class
A grid layout that sizes rows and columns by ratio.
| Method | Summary |
|---|---|
__construct(private readonly array $grid = [], private readonly array $colDefinitions = [], private readonly array $rowDefinitions = []) | |
static new(int $columns, int $rows): self | |
setSize(int $width, int $height): Sizer | |
render(): string | |
innerSize(): array | |
withCell(int $row, int $col, GridItem $item): self |
SugarCraft\Dashboard\Layout\Support
PersistState trait
Shared collapsed-address persistence for the layout engines.
| Method | Summary |
|---|---|
persistState(Persistence $persistence, string $path, array $collapsedAddresses = []): void | Persist the layout engine's collapsed-panel addresses to disk. |
restoreState(Persistence $persistence, string $path): array | Restore the persisted collapsed-addresses list. |
SugarCraft\Dashboard\Layout\Tile
BaseTile class
Base tile implementation.
| Method | Summary |
|---|---|
__construct(protected readonly string $name = '', protected readonly Size $size = new Size()) | |
name(): string | |
getName(): string | BC forwarder for the pre-rename accessor name. |
size(): Size | |
getSize(): Size | BC forwarder for the pre-rename accessor name. |
setSize(int $width, int $height): Sizer | |
render(): string | |
withTheme(Theme $theme): static | Identity by default: the base tile carries no themeable content. |
innerSize(): array |
Constraint final class
Constraint describes how a child should be sized along a container's axis. Mirrors tealeaves/tealayout_constraint.go constraint struct.
| Method | Summary |
|---|---|
__construct(public readonly ConstraintKind $kind = ConstraintKind::Fixed, public readonly int $fixedSize = 0, public readonly float $flexWeight = 0.0, public readonly int $minSize = 0, public readonly ?int $maxSize = null, public readonly bool $optional = false, public readonly bool $minSizeFit = false) | |
static fixed(int $size): self | |
static flex(float $weight = 1.0): self | |
static fit(): self | |
withMinSize(int $min): self | |
withMaxSize(int $max): self | Cap the size at $max. A non-positive cap means no cap: sizing a visible tile to a zero maximum was the silent clamp-to-zero half of finding sugar-dashboard-217, so 0 now reads as honest no-max. |
withOptional(bool $optional): self | |
withMinSizeFit(bool $fit): self |
ConstraintKind enum
ConstraintKind identifies which constraint type is active. Mirrors tealeaves tealayout_constraint.go constraintKind.
Cases: Fixed · Flex · Fit
PHP also provides cases(), from() and tryFrom().
Dimension final class
Dimension represents a width/height pair. Mirrors tealeaves SizeHint.Min/SizeHint.Desired type.
| Method | Summary |
|---|---|
__construct(public readonly int $width = 0, public readonly int $height = 0) |
Direction enum
Direction for tile layout arrangement.
Cases: Horizontal · Vertical
PHP also provides cases(), from() and tryFrom().
Resolver final class
Resolver for tile layout dimensions using a 5-phase algorithm. Mirrors tealeaves/tealayout_resolve.go.
| Method | Summary |
|---|---|
static resolveLinear(int $available, array $constraints, int $gap, ?array $hinters = null, bool $horizontal = true, int $crossBudget = 0): array | Resolve a single axis of layout: given available space, constraints, gap between children, and optional SizeHinters (may be nil or contain nil entries), it returns the assigned size for each child. |
Size final class
Size constraints for a tile.
| Method | Summary |
|---|---|
__construct(public readonly int $width = 0, public readonly int $height = 0, public readonly float $weight = 1.0, public readonly ?int $minWidth = null, public readonly ?int $minHeight = null, public readonly ?int $maxWidth = null, public readonly ?int $maxHeight = null, public readonly ?int $fixedWidth = null, public readonly ?int $fixedHeight = null, public readonly bool $optional = false, public readonly bool $minSizeFit = false) | |
static fill(): self | Create a fill Size (flexible, weight 1.0). |
static fixed(int $w, int $h): self | Create a fixed Size with explicit width and height. |
static flex(float $weight = 1.0): self | Create a flex Size with optional weight. |
withWidth(int $width): self | |
withHeight(int $height): self | |
withOptional(bool $optional): self | |
withMinSizeFit(bool $minSizeFit): self | |
withMinWidth(?int $minWidth): self | |
withMaxWidth(?int $maxWidth): self | |
withWeight(float $weight): self |
SizeHint final class
SizeHint contains minimum and desired size for a widget. Mirrors tealeaves tealayout_sizehinter.go SizeHint struct.
| Method | Summary |
|---|---|
__construct(public readonly Dimension $min, public readonly Dimension $desired) | |
static empty(): self |
SizeHinter interface
SizeHinter is implemented by widgets that can report their size preferences given available space. The layout engine calls sizeHint during resolution for Fit-constrained and minSizeFit children.
| Method | Summary |
|---|---|
sizeHint(int $availWidth, int $availHeight): SizeHint |
ThemedTile interface
A tile that knows how to re-theme itself, preserving its own type.
| Method | Summary |
|---|---|
withTheme(Theme $theme): static |
Tile final class
A tile in a tile layout.
| Method | Summary |
|---|---|
__construct(string $name = '', Size $size = new Size(), private readonly ?Item $content = null) | |
parent(): ?TileLayout | |
getParent(): ?TileLayout | BC forwarder for the pre-rename accessor name. |
setParent(?TileLayout $parent): void | |
isOptional(): bool | |
isMinSizeFit(): bool | |
content(): ?Item | |
getContent(): ?Item | BC forwarder for the pre-rename accessor name. |
withTheme(Theme $theme): static | Rebuild this tile with its content themed, keeping name, size and any box already allocated to it. |
render(): string | |
name(): string | |
getName(): string | BC forwarder for the pre-rename accessor name. |
size(): Size | |
getSize(): Size | BC forwarder for the pre-rename accessor name. |
setSize(int $width, int $height): Sizer | |
innerSize(): array |
TileLayout final class
A tile-based layout that arranges tiles horizontally or vertically.
| Method | Summary |
|---|---|
__construct(private readonly string $name = 'Root', private readonly Direction $direction = Direction::Horizontal, private readonly array $tiles = [], private readonly Size $baseSize = new Size(), private readonly int $gap = 0) | |
static horizontal(string $name = 'Root'): self | |
static vertical(string $name = 'Root'): self | |
setSize(int $width, int $height): Sizer | |
render(): string | |
innerSize(): array | |
withTiles(array $tiles): self | |
withDirection(Direction $direction): self | |
withTile(Tile $tile): self | |
withGap(int $gap): self | |
withTheme(Theme $theme): self | Apply a theme, fanning it down to any theme-aware children. |
SugarCraft\Dashboard\Module
BaseModule abstract class
Abstract base class for modules with default behaviour.
| Method | Summary |
|---|---|
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
minSize(): array | Get the minimum terminal size required by this module. |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
name(): string | The module's instance name. Two modules of the same type coexist by being named apart (the built-ins take a name: ctor knob); hosts key ticks, subscriptions and registry slots on it, so it must be unique among the modules one host runs. |
BoundedCommand final class
One bounded child-process run: argv, no shell interpolation, wall-clock deadline, output ceiling, and a guaranteed TERM→KILL reap before return.
| Method | Summary |
|---|---|
static run(array $argv, float $timeoutSeconds = self::DEFAULT_TIMEOUT_SECONDS, int $maxOutputBytes = self::MAX_OUTPUT_BYTES): array | Run $argv and report the outcome as output plus, when the run could not complete, ONE specific human-readable cause. The four former blanket 'Command failed' shapes (no command / could not start / interrupted / timed out) are named separately; empty output from a zero-exit child is a SUCCESS with nothing to show (failure === null), not a disguised error. |
static runAsync(LoopInterface $loop, array $argv, float $timeoutSeconds = self::DEFAULT_TIMEOUT_SECONDS, int $maxOutputBytes = self::MAX_OUTPUT_BYTES): PromiseInterface | The loop-driven run(): the same outcome, delivered on a promise, so a tick can hand its child to the loop instead of blocking the dashboard on it. The deadline and the TERM/KILL ladder are ChildRun's, running on $loop. |
ImagePlacement final class
Represents the placement of an image within a module's content.
| Method | Summary |
|---|---|
__construct(public readonly string $path, public readonly int $x, public readonly int $y, public readonly int $width = 0, public readonly int $height = 0) | |
static topLeft(string $path, int $x = 0, int $y = 0): self | Create a placement at the top-left corner. |
static topRight(string $path, int $x = 0, int $y = 0): self | Create a placement at the top-right corner. |
static bottomLeft(string $path, int $x = 0, int $y = 0): self | Create a placement at the bottom-left corner. |
static bottomRight(string $path, int $x = 0, int $y = 0): self | Create a placement at the bottom-right corner. |
static center(string $path, int $width = 0, int $height = 0): self | Create a centered placement. |
ImagePlacer interface
Optional interface for modules that can specify image placements.
| Method | Summary |
|---|---|
imagePlacements(): array | Get the image placements for this module. |
LegacyModule interface
Legacy module contract — superseded by Module.
| Method | Summary |
|---|---|
name(): string | Get the module name. |
init(): array | Initialize the module. |
update(array $state): array | Update the module state. |
view(array $state, int $width, int $height): string | Render the module view. |
minSize(): array | Get the minimum size required by this module. |
LegacyModuleAdapter final class
Adapter letting a legacy plugin implement the Module contract.
| Method | Summary |
|---|---|
__construct(private readonly LegacyModule $legacy, private array $state = []) | |
static from(callable $constructor): self | Create an adapter from a legacy-module constructor. |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
minSize(): array | |
subscriptions(): ?Subscriptions | Schedule the plugin's advertised refresh interval. |
Module interface
Dashboard module contract aligned with \SugarCraft\Core\Model.
| Method | Summary |
|---|---|
name(): string | The module's instance name. Two modules of the same type coexist by being named apart (the built-ins take a name: ctor knob); hosts key ticks, subscriptions and registry slots on it, so it must be unique among the modules one host runs. |
minSize(): array | Get the minimum terminal size required by this module. |
ModuleConfig final class
Configuration for a module instance.
| Method | Summary |
|---|---|
__construct(public readonly string $name, public readonly int $interval = 0, public readonly int $minWidth = 30, public readonly int $minHeight = 4, public readonly array $options = []) | |
static static(string $name, int $minWidth = 30, int $minHeight = 4): self | Create a config with the minimum interval (no auto-update). |
static withInterval(string $name, int $interval, int $minWidth = 30, int $minHeight = 4): self | Create a config with periodic updates. |
static withOptions(string $name, array $options, int $minWidth = 30, int $minHeight = 4): self | Create a config with custom options. |
ProcAvailability final class
Probe-once availability of Linux /proc files — probe-once-and-degrade policy, option (b): probe once, degrade quietly, show a visible 'n/a' sentinel.
| Method | Summary |
|---|---|
static has(string $path): bool | Is $path readable on this host? Probed once per process; afterwards the answer is stable even if the filesystem changes underneath (probe-once, degrade-quietly). |
static markForTesting(string $path, bool $available): void | TEST SEAM ONLY — override the availability answer for $path without touching the real filesystem; production code must never call this. |
static resetForTesting(): void | TEST SEAM ONLY — drop every memoized door so the next has() re-probes the ambient host. Call from tearDown so a degraded pin can never leak its false into a later readable-branch assertion. |
RunLaunch final class
When one run's child was actually launched, as opposed to when its tick asked for it. A host may hold a Cmd for a while before running it, and the settle ceiling a module latches against must count from the launch, or a run that queued for longer than the ceiling is treated as stale while its child is alive.
| Method | Summary |
|---|---|
markLaunched(): void | Called by the run's Cmd at the moment its child is launched. |
latchedSince(float $tickedAt): float | The second the latch counts from: the launch once it happened, otherwise the tick that asked for the run, so a Cmd the host never runs still goes stale. |
TickEpoch final class
Focus-regain epoch counter for modules.
| Method | Summary |
|---|---|
__construct(private readonly int $initialEpoch = 0) | |
static zero(): self | Create a new TickEpoch with zero initial value. |
value(): int | Get the current epoch value. |
bump(): self | Bump the epoch (call when focus is regained). |
isStale(int $received): bool | Check if a received epoch value is stale (lower than current). |
shouldRefresh(int $received): bool | Check if focus should be refreshed based on epoch comparison. |
SugarCraft\Dashboard\Modules\Clock
ClockModule final class
Clock module that displays the current time.
| Method | Summary |
|---|---|
__construct(private readonly bool $showDate = false, private readonly ?string $timezone = null, private readonly ?string $name = null) | |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
static timeBuildCountForTesting(): int | Test seam (ProcAvailability style): counts createTime() bodies, so the tick-gating law is pinned directly. |
static resetTimeBuildCountForTesting(): void | |
minSize(): array | |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
SugarCraft\Dashboard\Modules\Generic
CommandOutputMsg final readonly class
The settled result of one run of a Generic module's command, delivered back to the module that started it. The command runs on the loop, so a tick never blocks on it; $output is the text view() shows (output, or the named failure). $run names the run that produced it: a hung run can settle after a newer one has started, and only the newest may clear the in-flight latch.
| Method | Summary |
|---|---|
__construct(public string $source, public string $output, public int $run) |
GenericModule final class
Generic module that runs a configured command and displays output.
| Method | Summary |
|---|---|
__construct(private readonly string|array $command, private readonly int $intervalSeconds = 5, private readonly ?string $name = null, private readonly ?LoopInterface $loop = null) | |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
minSize(): array | |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
SugarCraft\Dashboard\Modules\System
GpuSampleMsg final readonly class
The settled result of one nvidia-smi sample, delivered back to the System module that asked for it. The sample runs on the loop (SystemModule) so a hung driver cannot freeze a tick; this message carries its outcome home.
| Method | Summary |
|---|---|
__construct(public string $source, public float $load, public bool $spawnFailed, public int $sample) |
SystemModule final class
System module that displays CPU, memory, GPU, and uptime statistics.
| Method | Summary |
|---|---|
__construct(private readonly float $refreshSeconds = self::TICK_INTERVAL, private readonly ?string $name = null, private readonly ?LoopInterface $loop = null) | |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
minSize(): array | |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
SugarCraft\Dashboard\Modules\Uptime
UptimeModule final class
Uptime module that displays system uptime.
| Method | Summary |
|---|---|
__construct(private readonly ?string $name = null) | |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
static sampleCountForTesting(): int | Test seam (ProcAvailability style): counts readUptimeFromProc() bodies entered, so the tick-gating law is pinned directly. |
static resetSampleCountForTesting(): void | |
minSize(): array | |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
SugarCraft\Dashboard\Modules\Weather
HttpClient interface
Abstract HTTP fetch interface for weather data.
| Method | Summary |
|---|---|
fetch(string $location): WeatherSnapshot | Fetch the current weather for the given location. |
WeatherFailureMsg final class
Carries a failed weather lookup back into update().
| Method | Summary |
|---|---|
__construct(public readonly \DateTimeImmutable $attemptedAt, public readonly string $reason) |
WeatherModule class
Weather module that fetches live data from wttr.in and falls back to cache.
| Method | Summary |
|---|---|
__construct(private readonly HttpClient $httpClient, private readonly string $location = 'auto', private readonly float $tickSeconds = self::TICK_INTERVAL, private readonly int $ttlSeconds = self::TTL_SECONDS, private readonly ?string $name = null, private readonly ?LoopInterface $loop = null) | |
name(): string | |
init(): ?\Closure | |
update(Msg $msg): array | |
view(): string | |
static wallReadCountForTesting(): int | |
static resetWallReadCountForTesting(): void | |
minSize(): array | |
subscriptions(): ?Subscriptions | The module's declared subscriptions, memoised per clone lineage. |
state(): array | Get current module state. |
getState(): array | BC forwarder for the pre-rename accessor name. |
WeatherParseFailure final class
The bytes arrived but are not a wttr.in j1 document: invalid JSON or a shape the parser refuses.
WeatherResultMsg final readonly class
Async result of an off-loop weather fetch.
| Method | Summary |
|---|---|
__construct(public WeatherSnapshot $snapshot) |
WeatherSnapshot final class
Readonly DTO holding a single weather snapshot.
| Method | Summary |
|---|---|
__construct(public readonly ?float $tempC, public readonly string $condition, public readonly string $location, public readonly \DateTimeImmutable $fetchedAt) | |
static fromArray(array $data): self | Deserialize from cache JSON array. |
toArray(): array | Serialize for cache JSON. |
WeatherTransportFailure final class
The network channel itself failed: the stream could not be opened, the reply was aborted, or it exceeded the size cap.
WttrInClient final class
Fetches weather data from wttr.in.
| Method | Summary |
|---|---|
__construct(private readonly string $urlPattern = self::BASE_URL) | |
fetch(string $location): WeatherSnapshot |
SugarCraft\Dashboard\Msg
AdapterTickMsg final class
Refresh tick scheduled by the legacy-module adapter's subscription.
TickMsg final class
The one tick marker every module's refresh cadence mints.
| Method | Summary |
|---|---|
__construct(public readonly ?string $source = null) | |
static for(string $source): self | Mint a tick addressed to one module. |
isFor(string $module): bool | True when this tick should drive the named module: addressed to it, or broadcast (source-less). |
SugarCraft\Dashboard\Output
RenderBar final class
Helper for rendering progress bars.
| Method | Summary |
|---|---|
static render(float $percentage, int $width, string $filled = '█', string $empty = '░', ?Color $filledColor = null, ?Color $emptyColor = null, ?ColorProfile $profile = null): string | Render a horizontal progress bar. |
static renderSegmented(float $percentage, int $width, ?Color $color = null, ?ColorProfile $profile = null): string | Render a progress bar shaded at eighth-block precision. |
Truncate final class
Truncation helper with ANSI awareness — the canonical cut for this library (sugar-dashboard-018's consolidation seat).
| Method | Summary |
|---|---|
static truncate(string $text, int $width, string $ellipsis = '…'): string | Truncate a string to a maximum width. |
static truncateLeft(string $text, int $width, string $fill = ' '): string | Truncate with left alignment (pad right). |
static truncateRight(string $text, int $width, string $fill = ' '): string | Truncate with right alignment (pad left). |
static truncateCenter(string $text, int $width, string $fill = ' '): string | Truncate with center alignment. |
WrapCells final class
Helper for wrapping text into cells/columns.
| Method | Summary |
|---|---|
static wrap(string $text, int $width, bool $breakWords = false): array | Wrap text to fit within a given width. |
static wrapAndPad(string $text, int $width, string $pad = ' '): array | Wrap and pad lines to a consistent width. |
SugarCraft\Dashboard\Plot
DistanceFade final class
btop's process-list distance fade: rows dim toward inactive_fg the farther they sit from the selected row, and each metric column (cpu, mem, threads) blends its value color back toward grey by the same distance.
| Method | Summary |
|---|---|
static ramp(Color $from, Color $to): array | btop's two-stop ramp (proc: main_fg → inactive_fg, proc_color: inactive_fg → process_start). |
static distance(int $selected, int $row): int | btop's calc: |selected − row|, selected 1-based (0 = none), row 0-based. |
static fadeIndex(int $calc, int $selectMax): int | Ramp index for the text fade: clamp(calc * 100 / select_max, 0, 100) with C++ truncating division. |
static fadeColor(array $procRamp, int $calc, int $selectMax): Color | Row text color: Theme::g("proc").at(fadeIndex). |
static metricPosition(int $value, int $calc, int $selectMax): int | The blend position btop computes before picking a ramp: (min(v, 100) + 100) - calc * 100 / select_max. Below 100 the metric has been pulled into the grey proc_color half; at or above it the remainder indexes process. |
static metricColor(array $procColorRamp, array $processRamp, int $value, int $calc, int $selectMax): Color | Metric color with the distance blend (proc_gradient on): position < 100 → proc_color[max(0, position)], else process[clamp(position - 100, 0, 100)]. |
static flatMetricColor(array $processRamp, int $value): Color | Metric color with the distance blend off: process[clamp(v, 0, 100)]. |
static metricValues(float $cpuPercent, float $memPercent, int $threads): array | The three integers btop feeds the metric law, each with its own C++ coercion: cpu is (int)round(cpu_p); mem is (int)round(mem * 100 / totalMem) over unsigned integers, so the division has already floored before round() sees it; threads are (int)threads / 3, deliberately compressed so a 300-thread process reads as "hot". |
Gradient101 final class
btop's 101-entry gradient expansion (index = percent), shared by every Plot widget that colors by percent so the integer law lives in one place.
| Method | Summary |
|---|---|
static expand(array $stops): array | Expand ordered low→high stops into a 101-entry lookup. |
Plot final class
A line/scatter chart rendered using braille characters for 2x4 resolution.
| Method | Summary |
|---|---|
__construct(array $data = [], int $width = 80, int $height = 24) | |
static new(array $data = [], int $width = 80, int $height = 24): self | |
withMode(string $mode): self | Set the plot mode. |
withShowAxes(bool $show): self | |
withHorizontalScale(int $scale): self | |
withColor(?Color $color): self | |
withData(array $data): self | |
withMinValue(float $min): self | |
withMaxValue(float $max): self | |
setSize(int $width, int $height): Sizer | |
innerSize(): array | |
rect(): Rect | |
setRect(Rect $rect): self | |
draw(Buffer $buffer): void | |
render(): string | Render the plot as a string. |
withTheme(Theme $theme): self | Apply a theme to this plot, using the theme's primary color. |
RingBuffer final class
Indexed ring buffer for time-series data.
| Method | Summary |
|---|---|
__construct(int $size = 60) | |
push(float $value): void | Push a value onto the ring buffer. |
isEmpty(): bool | Check if the buffer is empty. |
isFull(): bool | Check if the buffer is full. |
count(): int | Get the current number of values in the buffer. |
capacity(): int | Get the maximum capacity of the buffer. |
toArray(): array | Get all values in chronological order (oldest first). |
latest(): ?float | Get the most recent value (newest). |
oldest(): ?float | Get the oldest value in the buffer. |
clear(): void | Clear all values from the buffer. |
SugarCraft\Dashboard\Plot\Braille
BrailleCanvas final class
A canvas that renders to braille characters (2x4 dots per cell).
| Method | Summary |
|---|---|
__construct(int $pixelWidth, int $pixelHeight) | |
static new(int $pixelWidth, int $pixelHeight): self | |
withGradient(array $stops, ?\Closure $scale = null): self | Attach a value→color ramp. Once attached, setPoint()/setLine() with a null color paint the dot from the ramp at the canvas' current value (see withValue()); an explicit color still wins. |
withoutGradient(): self | Detach the ramp: null-color points go back to keeping the cell's current color. The current value is kept for a later withGradient(). |
withValue(int|float $value): self | Set the sample value that subsequent null-color points are painted with when a gradient is attached. Ignored for coloring otherwise. |
gradient(): ?array | The expanded 101-entry ramp (index = percent), or null when no gradient is attached. |
value(): int|float | |
setPoint(int $x, int $y, ?\SugarCraft\Core\Util\Color $color = null): self | Set a single dot at pixel coordinates (x, y). |
setLine(int $x1, int $y1, int $x2, int $y2, ?\SugarCraft\Core\Util\Color $color = null): self | Draw a line from (x1,y1) to (x2,y2) using Bresenham's algorithm. |
clear(): self | Clear all dots from the canvas. |
cell(int $cellX, int $cellY): int | Get accumulated bits for a cell. |
getCell(int $cellX, int $cellY): int | BC forwarder for the pre-rename accessor name. |
cells(): \Generator | Iterate over all cells that have dots set. |
render(?ColorProfile $profile = null): string | Render the canvas as a string of braille characters. |
setSize(int $width, int $height): Sizer | Resize the canvas. UNIT CONTRACT (finding sugar-dashboard-186): the dimensions are PIXELS - Braille cells are 2 wide by 4 tall, so feeding innerSize() (which answers in CELLS) back in here grows the canvas 2x/4x per lap. The round-trip bridge is pixelSize(). |
innerSize(): array | |
pixelSize(): array | |
getPixelSize(): array | BC forwarder for the pre-rename accessor name. |
BrailleMatrix final class
Braille dot matrix constants and utilities.
| Method | Summary |
|---|---|
static cellX(int $pixelX): int | Get the braille cell column index from a pixel X coordinate. |
static cellY(int $pixelY): int | Get the braille cell row index from a pixel Y coordinate. |
static dotBit(int $pixelX, int $pixelY): int | Get the dot bit for a pixel position within its braille cell. |
static rune(int $bits): string | Build a braille rune from accumulated bits. |
static cellWidth(int $pixelWidth): int | Get the character width in braille cells. A braille cell is 2 pixels wide; at least 1 cell is needed for any pixels. |
static cellHeight(int $pixelHeight): int | Get the character height in braille cells. A braille cell is 4 pixels tall; at least 1 cell is needed for any pixels. |
Bresenham final class
Bresenham line algorithm implementation for precise line drawing.
| Method | Summary |
|---|---|
static line(int $x1, int $y1, int $x2, int $y2): array | Generate all points on a line from (x1,y1) to (x2,y2). |
static circleArc(int $cx, int $cy, int $radius, int $octant = 0): array | Generate all points on a circle arc (octant). |
static isOnLine(int $x, int $y, int $x1, int $y1, int $x2, int $y2): bool | Check if a point is on the line segment. |
DualSampleGraph final class
btop's history graph: two adjacent samples quantized into one cell glyph.
| Method | Summary |
|---|---|
static new(int $width, int $height, string $family = self::FAMILY_BRAILLE, bool $invert = false, bool $noZero = false, int $maxValue = 0, int $offset = 0): self | Argument order follows btop's Graph constructor (max_value before offset). A positive offset with no max_value implies max_value 100, as in btop, so the stored maxValue() is the effective one. |
push(int|float ...$values): self | Append samples (oldest first); the frame scrolls left by half a cell per sample (a whole cell in the tty family). |
withData(int|float ...$values): self | Replace the whole history, like handing btop's constructor a deque. |
withGradient(array $stops): self | Color through a 101-stop ramp (Gradient101::expand()). Height 1 colors each drawn cell by max(prev, cur); taller graphs color each row by its vertical position. Named withGradient() rather than the plan's setGradient() to keep the immutable with*() convention. |
withoutGradient(): self | |
withUnderlay(Color $inactiveFg): self | Show the family's graph_bg glyph, in $inactiveFg, wherever btop's graph is transparent. Only height-1 graphs have transparent cells (btop prints taller graphs' blanks as opaque spaces), matching every btop call site, which underlays only one-row graphs. |
withoutUnderlay(): self | |
underlayGlyph(): string | The family's graph_bg glyph: ⣀ braille, ▄ block, 🬭 block2, ░ tty. |
static underlay(string $family, int $cells, Color $inactiveFg, ?ColorProfile $profile = null): string | btop's standalone underlay strip, Theme::c("inactive_fg") + graph_bg * n, for callers that compose the overdraw themselves. |
render(?ColorProfile $profile = null): string | |
setSize(int $width, int $height): Sizer | |
innerSize(): array | |
width(): int | |
height(): int | |
family(): string | |
inverted(): bool | |
noZero(): bool | |
maxValue(): int | |
offset(): int | |
samples(): array | |
gradient(): ?array | |
underlayColor(): ?Color |
SugarCraft\Dashboard\Plot\Canvas
Canvas final class
A 2D pixel drawing canvas.
| Method | Summary |
|---|---|
__construct(private readonly int $widthConstraint = 40, private readonly int $heightConstraint = 20, private readonly ?Color $defaultFg = null, private readonly ?Color $defaultBg = null) | |
static new(int $width = 40, int $height = 20): self | Create a new canvas with default settings. |
setSize(int $width, int $height): Sizer | Set the allocated dimensions for this canvas. |
setPixel(int $x, int $y, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Set a single pixel. |
pixel(int $x, int $y): ?string | Get a pixel character at the given coordinates. |
getPixel(int $x, int $y): ?string | BC forwarder for the pre-rename accessor name. |
drawLine(int $x1, int $y, int $x2, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Draw a horizontal line. |
drawVLine(int $x, int $y1, int $y2, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Draw a vertical line. |
drawRect(int $x, int $y, int $w, int $h, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Draw a rectangle outline. |
fillRect(int $x, int $y, int $w, int $h, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Fill a rectangle. |
drawCircle(int $cx, int $cy, int $radius, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Draw a circle outline using the midpoint circle algorithm. |
fillCircle(int $cx, int $cy, int $radius, string $char = '█', ?Color $fg = null, ?Color $bg = null): self | Fill a circle. |
drawText(int $x, int $y, string $text, ?Color $fg = null, ?Color $bg = null): self | Draw ASCII text at the given position. |
clear(): self | Clear the canvas. |
render(): string | Render the canvas as a string. |
innerSize(): array | Calculate the dimensions this canvas paints. |
withWidth(int $width): self | Set a new width. |
withHeight(int $height): self | Set a new height. |
withDefaultFg(?Color $color): self | Set the default foreground color. |
withDefaultBg(?Color $color): self | Set the default background color. |
CanvasPoint final readonly class
Point in 2D space.
| Method | Summary |
|---|---|
__construct(public int $x, public int $y) |
DrawingOps final class
Drawing operations helper class with static methods for common drawing operations.
| Method | Summary |
|---|---|
static drawHLine(int $x1, int $y, int $x2, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Draw a horizontal line. |
static drawVLine(int $x, int $y1, int $y2, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Draw a vertical line. |
static drawRect(int $x, int $y, int $w, int $h, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Draw a rectangle outline. |
static fillRect(int $x, int $y, int $w, int $h, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Fill a rectangle. |
static drawCircle(int $cx, int $cy, int $radius, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Draw a circle outline using the midpoint circle algorithm. |
static fillCircle(int $cx, int $cy, int $radius, string $char, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Fill a circle. |
static drawText(int $x, int $y, string $text, ?Color $fg, ?Color $bg, Canvas $canvas, int $widthConstraint, int $heightConstraint): Canvas | Draw ASCII text at the given position. |
SugarCraft\Dashboard\Plot\Chart
Area final class
An area chart component with stacked layers.
| Method | Summary |
|---|---|
__construct(private ?Color $color = null, private ?Color $fillColor = null, private ?Color $gridColor = null, private ?Color $labelColor = null) | |
static new(array $dataPoints = []): self | Create a new area chart with default styling. |
static sample(int $points = 10): self | Create a sample area chart for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this area chart. |
withDataPoints(array $dataPoints): self | Set the data points. |
withPoint(AreaPoint $point): self | Add a data point. |
addPoint(string $label, float $value, ?float $y0 = null): self | Add a data point by parameters. |
withLayerColors(array $colors): self | Set layer colors for stacked charts. |
withShowGrid(bool $show): self | Show or hide grid lines. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withStacked(bool $stacked): self | Enable or disable stacked mode. |
withShowLegend(bool $show): self | Show or hide legend. |
render(): string | Render the area chart as a string. |
innerSize(): array | Calculate the natural dimensions of this area chart. |
withColor(?Color $color): self | Set the line color. |
withFillColor(?Color $color): self | Set the fill color. |
withGridColor(?Color $color): self | Set the grid color. |
withLabelColor(?Color $color): self | Set the label color. |
withHeight(int $height): self | Set the height constraint. |
AreaChart final class
An area chart component for displaying time series data.
| Method | Summary |
|---|---|
__construct(private readonly array $series, private readonly int $chartHeight = 10, private readonly int $chartWidth = 40, private readonly bool $showGrid = true, private readonly bool $showLabels = true, private readonly bool $showLegend = false, private readonly float $maxValue = 100.0, private readonly bool $stacked = false) | |
static new(array $series): self | Create a new area chart. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chart. |
innerSize(): array | Calculate the natural dimensions of this area chart. |
render(): string | Render the area chart. |
withDimensions(int $width, int $height): self | Set the chart dimensions. |
withShowGrid(bool $show): self | Show or hide grid lines. |
withShowLegend(bool $show): self | Show or hide legend. |
withMaxValue(float $max): self | Set the maximum value. |
withStacked(bool $stacked): self | Enable stacked mode. |
AreaPoint final readonly class
| Method | Summary |
|---|---|
__construct(public string $label, public float $value, public ?float $y0 = null) |
AxisLabelFormatter trait
Human-readable axis-label formatting (M / K / integer / one-decimal).
Bar final class
A horizontal status bar component.
| Method | Summary |
|---|---|
__construct(private readonly string $content = '', private readonly ?Color $foreground = null, private readonly ?Color $background = null, private readonly HAlign $align = HAlign::Left, private readonly string $leftBorder = '', private readonly string $rightBorder = '') | |
static new(string $content = ''): self | Create a new bar with default styling. |
static themed(string $content, \SugarCraft\Dashboard\Foundation\Theme $theme, ?HAlign $align = null): self | Create a bar styled from a Theme's foreground/background pair. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this bar. |
render(): string | Render the bar as a string. |
innerSize(): array | Calculate the natural dimensions of this bar. |
withContent(string $content): self | Set the bar content text. |
withForeground(?Color $color): self | Set the foreground color. |
withBackground(?Color $color): self | |
withAlign(HAlign $align): self | |
withBorders(string $left, string $right): self |
Bubble final class
A bubble chart component.
| Method | Summary |
|---|---|
__construct(private ?Color $color = null, private ?Color $gridColor = null, private ?Color $labelColor = null, private ?Color $bgColor = null) | |
static new(array $points = []): self | Create a new bubble chart with default styling. |
static sample(int $count = 6): self | Create a sample bubble chart for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this bubble chart. |
withPoints(array $points): self | Set all data points at once. |
withPoint(BubblePoint $point): self | Add a data point. |
addPoint(string $label, float $x, float $y, float $size, ?Color $color = null): self | Add a point by parameters. |
withXRange(float $min, float $max): self | Set explicit bounds. |
withYRange(float $min, float $max): self | Set explicit Y range. |
withSizeRange(float $min, float $max): self | Set size range. |
withShowGrid(bool $show): self | Show or hide grid. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowLegend(bool $show): self | Show or hide legend. |
withShowSizes(bool $show): self | Show or hide bubble sizes. |
render(): string | Render the bubble chart as a string. |
innerSize(): array | Calculate the natural dimensions of this bubble chart. |
withColor(?Color $color): self | Set the default color. |
withGridColor(?Color $color): self | Set the grid color. |
withLabelColor(?Color $color): self | Set the label color. |
withBgColor(?Color $color): self | Set the background color. |
BubblePoint final class
| Method | Summary |
|---|---|
__construct(public readonly string $label, public readonly float $x, public readonly float $y, public readonly float $size, public readonly ?Color $color = null, public readonly ?string $category = null) | |
withColor(?Color $color): self | Create a copy with a different color. |
Candlestick final class
| Method | Summary |
|---|---|
__construct(public readonly string $label, public readonly float $open, public readonly float $high, public readonly float $low, public readonly float $close, public readonly ?Color $color = null) | |
static bullish(string $label, float $open, float $high, float $low, float $close): self | |
static bearish(string $label, float $open, float $high, float $low, float $close): self | |
isBullish(): bool |
CandlestickChart final class
A candlestick chart component for financial data visualization.
| Method | Summary |
|---|---|
__construct(private ?int $maxCandles = null, private ?Color $bullishColor = null, private ?Color $bearishColor = null, private ?Color $wickColor = null, private ?Color $gridColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new candlestick chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this candlestick chart. |
withCandle(Candlestick $candle): self | Add a candlestick to the chart. |
addCandle(string $label, float $open, float $high, float $low, float $close): self | Add a candlestick by parameters. |
withCandles(array $candles): self | Set all candles at once. |
withShowGrid(bool $show): self | Show or hide grid. |
withShowVolume(bool $show): self | Show or hide volume bars. |
withShowLabels(bool $show): self | Show or hide labels. |
withPriceRange(float $min, float $max): self | Set fixed price range. |
render(): string | Render the candlestick chart as a string. |
innerSize(): array | Calculate the natural dimensions of this candlestick chart. |
withBullishColor(?Color $color): self | Set the bullish color. |
withBearishColor(?Color $color): self | Set the bearish color. |
withWickColor(?Color $color): self | Set the wick color. |
withGridColor(?Color $color): self | Set the grid color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
Chart final class
A bar/line chart component with axes, labels, and grid.
| Method | Summary |
|---|---|
__construct(array $dataPoints = [], private readonly ChartType $type = ChartType::Bar, private readonly ?int $widthConstraint = null, private readonly int $heightConstraint = 10, private readonly bool $showGrid = true, private readonly bool $showValues = false, private readonly bool $showLabels = true, private readonly ?string $xAxisLabel = null, private readonly ?string $yAxisLabel = null, private readonly ?Color $color = null, private readonly ?Color $gridColor = null, private readonly ?Color $labelColor = null) | |
static new(array $dataPoints = [], ChartType $type = ChartType::Bar): self | Create a new chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chart. |
render(): string | Renders the chart as a string - PURE (finding sugar-dashboard-192, D-98): every call emits the full frame and the instance never carries frame history, so repeated renders of one chart are byte-identical. Streaming hosts that want delta emission thread a ChartRenderContext through renderDeltaFrame() themselves (DualSampleGraph::frame() is the model: per-call state object, not hidden instance mutation). |
innerSize(): array | Calculate the natural dimensions of this chart. |
withDataPoints(array $dataPoints): self | Set the data points. |
withType(ChartType $type): self | Set the chart type. |
withWidth(int $width): self | Set the width constraint. |
withHeight(int $height): self | Set the height constraint. |
withGrid(bool $show): self | Show or hide grid lines. |
withShowValues(bool $show): self | Show or hide value labels. |
withShowLabels(bool $show): self | Show or hide X-axis labels. |
withXAxisLabel(?string $label): self | Set the X-axis label. |
withYAxisLabel(?string $label): self | Set the Y-axis label. |
withColor(?Color $color): self | Set the chart color. |
withGridColor(?Color $color): self | Set the grid color. |
withLabelColor(?Color $color): self | Set the label color. |
with(array $overrides): self | Canonical wither accepting an overrides array. |
resetPreviousFrame(): void |
ChartBorderStyle trait
Box-drawing border characters for bordered chart components.
ChartDataPoint final readonly class
Data point for charts.
| Method | Summary |
|---|---|
__construct(public string $label, public float $value) |
ChartGridGeometry trait
Shared Y-axis grid math for chart components.
ChartRenderContext final class
Render context for diff-based chart rendering.
| Method | Summary |
|---|---|
__construct(public ?Buffer $previousFrame = null, public ?int $prevWidth = null, public ?int $prevHeight = null) | |
static fresh(): self | Create a fresh context (no previous frame). |
withNext(Buffer $frame, int $width, int $height): self | Create a new context with updated values after render. |
ChartType enum
Chart types.
Cases: Bar · Line
PHP also provides cases(), from() and tryFrom().
Donut final class
A donut chart component for displaying proportional data.
| Method | Summary |
|---|---|
__construct(private readonly array $segments, private readonly int $size = 20, private readonly ?string $centerLabel = null, private readonly ?string $centerValue = null, private readonly ?Color $backgroundColor = null, private readonly bool $showPercentage = false, private readonly float $startAngle = 0.0, private readonly bool $clockwise = true, private readonly ?float $aspect = null, private readonly bool $smoothRim = false, private readonly string $fillStyle = self::FILL_FOREGROUND, private readonly string $renderMode = self::RENDER_FILLED) | |
static new(array $data): self | Create a new donut chart with the given data. |
static mocha(array $data): self | Create a donut chart with default Catppuccin Mocha theme colors. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chart. |
innerSize(): array | Calculate the natural dimensions of this donut chart. |
render(): string | Render the donut chart using Unicode block characters. |
withSize(int $size): self | Set the chart size. |
withCenterLabel(?string $label): self | Set the center label text. |
withCenterValue(?string $value): self | Set the center value text. |
withShowPercentage(bool $show): self | Show percentage in center. |
withStartAngle(float $angle): self | Set the start angle in degrees. |
withAspect(float $ratio = self::DEFAULT_ASPECT): self | Set the aspect-ratio correction applied to the vertical cell axis. |
withSmoothRim(bool $on = true): self | Supersample the annulus boundary with quadrant-block runes. |
withFillStyle(string $style = self::FILL_FOREGROUND): self | Choose how filled ring cells are painted. |
withRenderMode(string $mode = self::RENDER_FILLED): self | Choose the chart's render mode. |
DotMatrix final class
A dot matrix display component.
| Method | Summary |
|---|---|
__construct(string $content, private readonly int $cellSize = 1, private readonly bool $showFrame = false, private readonly ?Color $onColor = null, private readonly ?Color $offColor = null) | |
static new(string $content): self | Create a new dot matrix display with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this display. |
render(): string | Render the dot matrix display. |
innerSize(): array | Calculate the natural dimensions of this display. |
withCellSize(int $size): self | Set the cell size (scale factor for each dot). |
withShowFrame(bool $show): self | Show or hide the frame. |
withOnColor(?Color $color): self | Set the "on" (lit) dot color. |
withOffColor(?Color $color): self | Set the "off" (unlit) dot color. |
withContent(string $content): self | Set new content. |
Funnel final class
A funnel chart component.
| Method | Summary |
|---|---|
__construct(private ?Color $color = null, private ?Color $borderColor = null, private ?Color $labelColor = null, private ?Color $valueColor = null) | |
static new(array $stages = []): self | Create a new funnel chart with default styling. |
static sample(int $stages = 5): self | Create a sample funnel chart for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this funnel chart. |
withStages(array $stages): self | Set all stages at once. |
withStage(FunnelStage $stage): self | Add a stage. |
addStage(string $label, float $value, ?Color $color = null): self | Add a stage by parameters. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withShowPercentages(bool $show): self | Show or hide percentages. |
withCentered(bool $centered): self | Center align the funnel. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the funnel chart as a string. |
innerSize(): array | Calculate the natural dimensions of this funnel chart. |
withColor(?Color $color): self | Set the default color. |
withBorderColor(?Color $color): self | Set the border color. |
withLabelColor(?Color $color): self | Set the label color. |
withValueColor(?Color $color): self | Set the value color. |
FunnelChart final class
A funnel chart component for displaying conversion flows.
| Method | Summary |
|---|---|
__construct(private readonly array $stages, private readonly bool $horizontal = false, private readonly bool $showValues = true, private readonly bool $showPercentages = true, private readonly ?Color $defaultColor = null) | |
static new(array $stages): self | Create a new funnel chart. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chart. |
innerSize(): array | Calculate the natural dimensions of this funnel chart. |
render(): string | Render the funnel chart. |
withHorizontal(bool $horizontal): self | Set horizontal orientation. |
withShowValues(bool $show): self | Show or hide values. |
withShowPercentages(bool $show): self | Show or hide percentages. |
FunnelStage final readonly class
A stage in a funnel chart.
| Method | Summary |
|---|---|
__construct(public string $label, public float $value, public ?Color $color = null) | |
withColor(?Color $color): self | Create a copy with a different color. |
Gauge final class
A horizontal progress bar / gauge component.
| Method | Summary |
|---|---|
__construct(float $ratio, private readonly ?int $widthConstraint = null, private readonly bool $showPercentage = true, private readonly ?Color $filledColor = null, private readonly ?Color $emptyColor = null, private readonly string $filledChar = '█', private readonly string $emptyChar = '░') | |
static new(float $ratio): self | Create a new gauge with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this gauge. |
render(): string | Render the gauge as a string. |
innerSize(): array | Calculate the natural dimensions of this gauge. |
withWidth(int $width): self | Set the width constraint (number of bar characters). |
withPercentage(bool $show): self | Show or hide the percentage label. |
withFilledColor(?Color $color): self | Set the color for the filled portion. |
withEmptyColor(?Color $color): self | Set the color for the empty portion. |
withChars(string $filled, string $empty): self | Set custom characters for filled and empty portions. |
withRatio(float $ratio): self | Set a new ratio value. |
GaugeChart final class
A gauge chart component for displaying a single value within a range.
| Method | Summary |
|---|---|
__construct(private readonly float $value = 0.0, private readonly float $min = 0.0, private readonly float $max = 100.0, private readonly ?Color $color = null, private readonly bool $showValue = true, private readonly bool $showLabel = false, private readonly ?string $label = null, private readonly string $format = 'value') | |
static new(float $value = 0.0, float $min = 0.0, float $max = 100.0): self | Create a new gauge chart. |
static percent(float $value): self | Create a percentage gauge (0-100%). |
static cpu(float $usage): self | Create a CPU-style gauge. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this gauge. |
render(): string | Render the gauge. |
innerSize(): array | Calculate the natural dimensions of this gauge. |
withValue(float $value): self | Set the value. |
withRange(float $min, float $max): self | Set the min/max range. |
withColor(?Color $color): self | Set the color. |
withFormat(string $format): self | Set the format. |
withLabel(?string $label): self | Set the label. |
GaugeCircle final class
A circular gauge component (speedometer style).
| Method | Summary |
|---|---|
__construct(float $ratio, private readonly int $radius = 6, private readonly bool $showNeedle = true, private readonly bool $showTicks = true, private readonly bool $showLabel = true, private readonly ?Color $arcColor = null, private readonly ?Color $needleColor = null, private readonly ?Color $labelColor = null, private readonly ?float $aspect = null, private readonly bool $smoothRim = false) | |
static new(float $ratio): self | Create a new circular gauge with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this gauge. |
render(): string | Render the circular gauge. |
innerSize(): array | Calculate the natural dimensions of this gauge. |
withRadius(int $radius): self | Set the radius of the gauge (the no-allocation fallback size). |
withShowNeedle(bool $show): self | Show or hide the needle. |
withShowTicks(bool $show): self | Show or hide tick marks. |
withShowLabel(bool $show): self | Show or hide the percentage label. |
withPercentage(bool $show): self | Show or hide the percentage label (alias for withShowLabel). |
withRatio(float $ratio): self | Set the ratio value. |
withArcColor(?Color $color): self | Set the arc color. |
withNeedleColor(?Color $color): self | Set the needle color. |
withLabelColor(?Color $color): self | Set the label color. |
withAspect(float $ratio = self::DEFAULT_ASPECT): self | Correct the 2:1 terminal-cell squash so the dial reads visually round. |
withSmoothRim(bool $on = true): self | Supersample the arc rim with quadrant-block runes. |
GaugeWithDetail final class
A horizontal gauge bar with detail text overlaid in the center.
| Method | Summary |
|---|---|
__construct(string $label = '', private readonly float $value = 0, private readonly float $max = 100, string $detail = '', private readonly int $widthConstraint = 40) | |
static new(string $label = '', float $value = 0, float $max = 100, string $detail = '', int $width = 40): self | Create a new gauge with detail overlay. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this gauge. |
render(): string | Render the gauge with detail overlay as a string. |
innerSize(): array | Calculate the natural dimensions of this gauge. |
withValue(float $value): self | Set the current value. |
withMax(float $max): self | Set the maximum value. |
withDetail(string $detail): self | Set the detail text. |
withWidth(int $width): self | Set the width constraint. |
withLabel(string $label): self | Set the label text. |
HeatMapChart final class
A heatmap component for displaying data intensity in a grid format.
| Method | Summary |
|---|---|
__construct(private readonly array $data, private readonly ?array $rowLabels = null, private readonly ?array $columnLabels = null, private readonly ?Color $lowColor = null, private readonly ?Color $highColor = null, private readonly string $scale = 'sequential', private readonly bool $showLabels = true, private readonly int $cellWidth = 1, private readonly int $cellHeight = 1) | |
static new(array $data): self | Create a new heatmap. |
static sample(int $rows = 5, int $cols = 7): self | Create a sample heatmap for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this heatmap. |
render(): string | Render the heatmap. |
innerSize(): array | Calculate the natural dimensions of this heatmap. |
withRowLabels(?array $labels): self | Set row labels. |
withColumnLabels(?array $labels): self | Set column labels. |
withScale(string $scale): self | Set the color scale. |
withLowColor(?Color $color): self | Set the low color. |
withHighColor(?Color $color): self | Set the high color. |
withShowLabels(bool $show): self | Show or hide labels. |
Heatmap final class
A heat map visualization component.
| Method | Summary |
|---|---|
__construct(private readonly array $data, private readonly bool $showLegend = true, private readonly bool $showValues = false, private readonly ?Color $lowColor = null, private readonly ?Color $highColor = null, private readonly string $rowLabelFormat = '', private readonly string $colLabelFormat = '') | |
static new(array $data): self | Create a new heat map with default styling. |
static sample(int $rows = 5, int $cols = 7): self | Create a sample heat map for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this heat map. |
render(): string | Render the heat map. |
innerSize(): array | Calculate the natural dimensions of this heat map. |
dataDimensions(): array | Get the dimensions of the data grid. |
getDataDimensions(): array | BC forwarder for the pre-rename accessor name. |
minValue(): float | Get the minimum value in the data. |
getMinValue(): float | BC forwarder for the pre-rename accessor name. |
maxValue(): float | Get the maximum value in the data. |
getMaxValue(): float | BC forwarder for the pre-rename accessor name. |
withLegend(bool $show): self | Show or hide the legend. |
withValues(bool $show): self | Show or hide cell values. |
withLowColor(?Color $color): self | Set the low (cold) color. |
withHighColor(?Color $color): self | Set the high (hot) color. |
withRowLabelFormat(string $format): self | Set the row label format. |
withColLabelFormat(string $format): self | Set the column label format. |
HeatmapColorScale trait
Value clamping and low→high color ramp for heatmap renderers.
Meter final class
An analog-style meter/gauge component.
| Method | Summary |
|---|---|
__construct(float $ratio, private readonly int $meterHeight = 12, private readonly int $meterWidth = 5, private readonly bool $showNeedle = true, private readonly bool $showScale = true, private readonly bool $showLabel = true, private readonly ?Color $meterColor = null, private readonly ?Color $needleColor = null, private readonly ?Color $scaleColor = null) | |
static new(float $ratio): self | Create a new analog meter with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this meter. |
render(): string | Render the analog meter. |
innerSize(): array | Calculate the natural dimensions of this meter. |
withHeight(int $height): self | Set the meter height. |
withWidth(int $width): self | Set the meter width. The analog face keeps its 3-column minimum; the position-mode bar honours the request down to 1 cell, since btop sizes meters to whatever columns remain (a 1-2 cell bar is legal there). |
withShowNeedle(bool $show): self | Show or hide the needle. |
withShowScale(bool $show): self | Show or hide the scale marks. |
withShowLabel(bool $show): self | Show or hide the percentage label. |
withRatio(float $ratio): self | Set the ratio value. |
withMeterColor(?Color $color): self | Set the meter body color. |
withNeedleColor(?Color $color): self | Set the needle color. |
withScaleColor(?Color $color): self | Set the scale color. |
withGradient(array $stops, bool $positionWise = false): self | Attach a value→color ramp, expanded once into btop's 101-entry memo by Gradient101::expand() (truncating integer law). |
withoutGradient(): self | Detach the ramp; the meter returns to its flat analog face. |
withGlyph(string $glyph = '■'): self | Glyph for every position-mode bar cell (filled and tail alike, as in btop where both are Symbols::meter). Defaults to ■ (U+25A0). |
withInvert(bool $invert = true): self | Flip the ramp direction in position mode (btop's invert): the leftmost cell takes the ramp's high end — e.g. a discharging battery. |
withMeterBg(?Color $color): self | Color of the unfilled tail in position mode. Null restores btop's default theme meter_bg (#40 → #404040). |
gradient(): ?array | |
positionWise(): bool | |
glyph(): string | |
invert(): bool | |
meterBg(): Color | |
static cacheKey(array $stops, int $width, bool $invert, string $glyph = '■', ?Color $meterBg = null): string | Memo key for one position-mode bar shape. Two meters with equal keys render byte-identical strings for every value, so they share one 101-slot memo row. |
static memoStats(): array | Memo diagnostics: distinct bar shapes held, rendered rows across them, and lookup hits/misses since the last resetMemo(). |
static resetMemo(): void | Drop every memoized bar and zero the hit/miss counters. |
OHLC final class
An OHLC (Open-High-Low-Close) chart component for financial data.
| Method | Summary |
|---|---|
__construct(private ?Color $bullishColor = null, private ?Color $bearishColor = null, private ?Color $gridColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null) | |
static new(): self | Create a new OHLC chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this OHLC chart. |
withPoint(OHLCPoint $point): self | Add an OHLC point. |
addPoint(string $label, float $open, float $high, float $low, float $close): self | Add an OHLC point by parameters. |
withPoints(array $points): self | Set all points at once. |
withShowGrid(bool $show): self | Show or hide grid. |
withShowLabels(bool $show): self | Show or hide labels. |
withPriceRange(float $min, float $max): self | Set fixed price range. |
withStyle(string $style): self | Set the border style. |
render(): string | Render the OHLC chart as a string. |
innerSize(): array | Calculate the natural dimensions of this OHLC chart. |
withBullishColor(?Color $color): self | Set the bullish color. |
withBearishColor(?Color $color): self | Set the bearish color. |
withGridColor(?Color $color): self | Set the grid color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
OHLCPoint final readonly class
| Method | Summary |
|---|---|
__construct(public string $label, public float $open, public float $high, public float $low, public float $close, public ?Color $color = null) | |
static bullish(string $label, float $open, float $high, float $low, float $close): self | |
static bearish(string $label, float $open, float $high, float $low, float $close): self | |
isBullish(): bool | |
range(): float | |
getRange(): float | BC forwarder for the pre-rename accessor name. |
bodySize(): float | |
getBodySize(): float | BC forwarder for the pre-rename accessor name. |
Partition final class
A Partition chart component for hierarchical proportional visualization.
| Method | Summary |
|---|---|
__construct(private ?Color $segmentColor = null, private ?Color $borderColor = null, private ?Color $textColor = null) | |
static new(): self | Create a new partition chart with default styling. |
static sample(): self | Create a sample partition chart for demonstration. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this partition chart. |
withRoot(PartitionSegment $root): self | Set the root segment. |
withShowLabels(bool $show): self | Show or hide labels. |
withShowValues(bool $show): self | Show or hide values. |
withHorizontal(bool $horizontal): self | Use horizontal layout (icicle top-down). |
withStyle(string $style): self | Set the border style. |
render(): string | Render the partition chart as a string. |
innerSize(): array | Calculate the natural dimensions of this partition chart. |
withSegmentColor(?Color $color): self | Set the default segment color. |
withBorderColor(?Color $color): self | Set the border color. |
withTextColor(?Color $color): self | Set the text color. |
PartitionSegment final class
| Method | Summary |
|---|---|
__construct(public readonly string $id, public readonly string $label, public readonly float $value, public readonly ?Color $color = null) | |
withChildren(array $children): self | |
withColor(?Color $color): self | |
totalValue(): float | |
getTotalValue(): float | BC forwarder for the pre-rename accessor name. |
depth(): int | |
getDepth(): int | BC forwarder for the pre-rename accessor name. |
PriceAxisProjection trait
Maps a price onto a chart row for the financial chart pair.
Progress final class
A multi-segment progress bar component.
| Method | Summary |
|---|---|
__construct(array $segments, private readonly bool $showLabels = true, private readonly bool $showPercentages = true, private readonly string $segmentSeparator = '') | |
static new(float $ratio): self | Create a new progress bar with default styling. |
static segmented(array $segments): self | Create a multi-segment progress bar. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this progress bar. |
render(): string | Render the progress bar as a string. |
innerSize(): array | Calculate the natural dimensions of this progress bar. |
withSegments(array $segments): self | Set the segments. |
withShowLabels(bool $show): self | Show or hide segment labels. |
withShowPercentages(bool $show): self | Show or hide percentages. |
withWidth(int $width): self | Set the width. |
ProgressRing final class
A circular progress ring component.
| Method | Summary |
|---|---|
__construct(float $ratio, private readonly int $radius = 4, private readonly bool $showPercentage = true, private readonly ?Color $filledColor = null, private readonly ?Color $emptyColor = null) | |
static new(float $ratio): self | Create a new progress ring with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this ring. |
render(): string | Render the progress ring as a string. |
innerSize(): array | Calculate the natural dimensions of this ring. |
withRadius(int $radius): self | Set the radius of the ring. |
withPercentage(bool $show): self | Show or hide the percentage label. |
withRatio(float $ratio): self | Set the ratio value. |
withFilledColor(?Color $color): self | Set the color for the filled portion. |
withEmptyColor(?Color $color): self | Set the color for the empty portion. |
RadarChart final class
A radar/spider chart component for displaying multi-axis data.
| Method | Summary |
|---|---|
__construct(private readonly array $labels, private readonly array $series, private readonly int $size = 20, private readonly int $gridLines = 4, private readonly float $maxValue = 1.0, private readonly bool $showLabels = true, private readonly bool $showGrid = true, private readonly bool $showDots = true) | |
static new(array $labels, array $series): self | Create a new radar chart. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this chart. |
innerSize(): array | Calculate the natural dimensions of this radar chart. |
render(): string | Render the radar chart. |
withSize(int $size): self | Set the chart size. |
withGridLines(int $lines): self | Set the number of grid lines. |
withMaxValue(float $max): self | Set the maximum value for the scale. |
withShowLabels(bool $show): self | Show or hide axis labels. |
withShowGrid(bool $show): self | Show or hide grid lines. |
withShowDots(bool $show): self | Show or hide data point dots. |
SparkArea final class
A spark area chart - minimal area chart for inline use.
| Method | Summary |
|---|---|
__construct(private readonly array $values, private readonly int $chartHeight = 3, private readonly ?Color $color = null, private readonly bool $showMinMax = false, private readonly bool $gradient = true) | |
static new(array $values): self | Create a new spark area. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this spark area. |
innerSize(): array | Calculate the natural dimensions of this spark area. |
render(): string | Render the spark area. |
withHeight(int $height): self | Set the chart height. |
withColor(?Color $color): self | Set the color. |
withShowMinMax(bool $show): self | Show min/max markers. |
withGradient(bool $gradient): self | Enable gradient fill. |
Sparkline final class
An inline sparkline chart component using 8-block Unicode scaling.
| Method | Summary |
|---|---|
__construct(private int $widthConstraint = 40, private int $height = 1, private bool $showDataPoints = false, private bool $fill = false, private bool $dimEdge = false) | |
static new(int $width = 40): self | Create a new sparkline with default styling. |
push(float $value): self | Push a value onto the sparkline buffer. |
pushAll(array $values): self | Push multiple values onto the sparkline buffer. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this sparkline. |
render(): string | Render the sparkline as a string. |
innerSize(): array | Calculate the natural dimensions of this sparkline. |
withWidth(int $width): self | Set the width constraint. |
withHeight(int $height): self | Set the height. |
withDataPoints(bool $show): self | Show or hide data point markers. |
withFill(bool $fill): self | Enable or disable area fill. |
withDimEdge(bool $dim): self | Enable or disable dim-edge padding. |
SparklineArea final class
An area-style sparkline chart component.
| Method | Summary |
|---|---|
__construct(array $data = [], private readonly ?int $widthConstraint = null, private readonly int $height = 3, private readonly bool $showLine = true, private readonly bool $showFill = true, private readonly ?Color $lineColor = null, private readonly ?Color $fillColor = null, private readonly ?Color $maxColor = null, private readonly ?Color $minColor = null) | |
static new(array $data = []): self | Create a new area sparkline with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this sparkline. |
render(): string | Render the area sparkline as a string. |
innerSize(): array | Calculate the natural dimensions of this sparkline. |
withData(array $data): self | Set the data points. |
withWidth(int $width): self | Set the width constraint. |
withHeight(int $height): self | Set the height. |
withShowLine(bool $show): self | Show or hide the line. |
withShowFill(bool $show): self | Show or hide the fill. |
withLineColor(?Color $color): self | Set the line color. |
withFillColor(?Color $color): self | Set the fill color. |
withMaxColor(?Color $color): self | Set the maximum value color. |
withMinColor(?Color $color): self | Set the minimum value color. |
SparklineBar final class
A bar-style sparkline chart component.
| Method | Summary |
|---|---|
__construct(array $data = [], private readonly ?int $widthConstraint = null, private readonly int $height = 8, private readonly bool $showValues = false, private readonly ?Color $color = null, private readonly ?Color $maxColor = null, private readonly ?Color $minColor = null, private readonly bool $showBarGaps = true, private readonly string $separator = ' ') | |
static new(array $data = []): self | Create a new bar sparkline with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this sparkline. |
render(): string | Render the bar sparkline as a string. |
innerSize(): array | Calculate the natural dimensions of this sparkline. |
withData(array $data): self | Set the data points. |
withWidth(int $width): self | Set the width constraint. |
withHeight(int $height): self | Set the height. |
withShowValues(bool $show): self | Show or hide numeric values below bars. |
withColor(?Color $color): self | Set the main color. |
withMaxColor(?Color $color): self | Set the maximum value color. |
withMinColor(?Color $color): self | Set the minimum value color. |
withBarGaps(bool $show): self | Show or hide gaps between bars. |
withSeparator(string $separator): self | Set the separator between bars. |
SparklineScaling trait
Width resolution and data resampling for sparkline renderers.
Waterfall final class
A waterfall chart component for visualizing cumulative changes.
| Method | Summary |
|---|---|
__construct(private ?int $maxItems = null, private ?Color $positiveColor = null, private ?Color $negativeColor = null, private ?Color $totalColor = null, private ?Color $subtotalColor = null, private ?Color $gridColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new waterfall chart with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this waterfall chart. |
withItem(WaterfallItem $item): self | Add an item to the chart. |
addItem(string $label, float $value, WaterfallBarType $type = WaterfallBarType::Positive): self | Add an item by parameters. |
withItems(array $items): self | Set all items at once. |
withShowConnectors(bool $show): self | Show or hide connector lines. |
withShowGrid(bool $show): self | Show or hide grid. |
withValueRange(float $min, float $max): self | Set fixed min/max values. |
render(): string | Render the waterfall chart as a string. |
innerSize(): array | Calculate the natural dimensions of this waterfall chart. |
withPositiveColor(?Color $color): self | Set the positive color. |
withNegativeColor(?Color $color): self | Set the negative color. |
withTotalColor(?Color $color): self | Set the total color. |
withSubtotalColor(?Color $color): self | Set the subtotal color. |
withGridColor(?Color $color): self | Set the grid color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
WaterfallBarType enum
Cases: Positive · Negative · Total · Subtotal
PHP also provides cases(), from() and tryFrom().
WaterfallItem final class
| Method | Summary |
|---|---|
__construct(public readonly string $label, public readonly float $value, public readonly WaterfallBarType $type = WaterfallBarType::Positive, public readonly ?Color $color = null) | |
static positive(string $label, float $value): self | |
static negative(string $label, float $value): self | |
static total(string $label, float $value): self | |
static subtotal(string $label, float $value): self |
WordCloud final class
A word cloud component for displaying text frequency.
| Method | Summary |
|---|---|
__construct(private readonly array $words, private readonly int $maxWords = 20, private readonly bool $shuffle = true, private readonly bool $showWeights = false, private readonly array $colors = []) | |
static new(array $words): self | Create a new word cloud. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this word cloud. |
innerSize(): array | Calculate the natural dimensions of this word cloud. |
render(): string | Render the word cloud. |
withMaxWords(int $max): self | Set max words to display. |
withShuffle(bool $shuffle): self | Set shuffle behavior. |
withShowWeights(bool $show): self | Show weight values. |
withColors(array $colors): self | Set colors. |
SugarCraft\Dashboard\Plot\Graph
AxisPosition enum
Graph axis labels position.
Cases: Left · Right · Both
PHP also provides cases(), from() and tryFrom().
Graph final class
A graph/chart component for displaying data visualizations.
| Method | Summary |
|---|---|
__construct(private readonly ?int $maxDataPoints = null, private GraphType $graphType = GraphType::Line, private ?Color $lineColor = null, private ?Color $gridColor = null, private ?Color $textColor = null, private ?Color $backgroundColor = null, private string $style = 'rounded') | |
static new(): self | Create a new graph with default styling. |
setSize(int $width, int $height): \SugarCraft\Dashboard\Foundation\Sizer | Set the allocated dimensions for this graph. |
withData(array $data): self | Set the data for a single series. |
withSeries(string $label, array $data, ?Color $color = null): self | Add a data series. |
withLabels(array $labels): self | Set axis labels. |
withValueRange(float $min, float $max): self | Set fixed min/max values. |
withShowGrid(bool $show): self | Show or hide grid. |
withShowLegend(bool $show): self | Show or hide legend. |
render(): string | Render the graph as a string. |
innerSize(): array | Calculate the natural dimensions of this graph. |
withGraphType(GraphType $type): self | Set the graph type. |
withLineColor(?Color $color): self | Set the line color. |
withGridColor(?Color $color): self | Set the grid color. |
withTextColor(?Color $color): self | Set the text color. |
withBackgroundColor(?Color $color): self | Set the background color. |
withStyle(string $style): self | Set the border style. |
GraphType enum
Graph types.
Cases: Line · Bar · Area · Scatter
PHP also provides cases(), from() and tryFrom().
SugarCraft\Dashboard\Plot\ProcRow
ProcColumns final class
Column widths of a btop process row:
| Method | Summary |
|---|---|
static new(int $prog, int $cmd, int $threads, int $user, bool $cpuGraphs = true): self | |
static btop(int $boxWidth, bool $cpuGraphs = true): self | btop's widths for a proc box $boxWidth cells wide (borders included). The rows then fill $boxWidth - 2 cells, except below 56 columns where btop's own arithmetic leaves one cell unwritten — the composer pads that slack. |
width(): int | Cells one row occupies, separators included. |
ProcGraphTracker final class
Per-pid lifecycle of the 5×1 cpu mini-graphs in a process list.
| Method | Summary |
|---|---|
static new(int $width = ProcColumns::GRAPH, string $family = DualSampleGraph::FAMILY_BRAILLE): self | |
static sample(float $cpu): int | btop's sample law for the mini-graph: anything in [0.1, 5) is lifted to 5 so a barely-busy process still shows the lowest band (band 1 starts at 5 on a one-row graph); everything else is round(cpu). |
observe(int $pid, float $cpu): self | Record one fresh cpu reading for a drawn row. |
retain(iterable $livePids): self | Keep only the listed pids (btop's periodic dead-process sweep). |
has(int $pid): bool | |
graph(int $pid): ?DualSampleGraph | |
idleCount(int $pid): ?int | Consecutive idle samples so far, or null when the pid has no graph. |
pids(): array | |
count(): int | |
width(): int | |
family(): string |
ProcRow final class
One process as the proc-list row composer sees it — only the fields btop's normal (non-tree) row prints or colors by.
| Method | Summary |
|---|---|
static new(int $pid, string $name, string $cmd = '', int $threads = 1, string $user = '', float $cpu = 0.0, float $memPercent = 0.0, ?string $memLabel = null): self |
ProcRowComposer final class
Composes one btop process-list row (normal, non-tree view):
| Method | Summary |
|---|---|
static new(int $width): self | |
withWidth(int $width, bool $cpuGraphs = true): self | Re-derive btop's widths for a new inner width. |
withColumns(ProcColumns $columns): self | Caller-owned layout; slack right of the cpu column is padded. |
withPalette(ProcRowPalette $palette): self | |
withProcColors(bool $on): self | btop proc_colors: value-colored cpu/name, mem and threads. |
withProcGradient(bool $on): self | btop proc_gradient: distance fade of text and metric colors. |
withFamily(string $family): self | Graph family whose graph_bg glyph underlays rows without a graph (a row with a graph uses that graph's own family). |
width(): int | |
columns(): ProcColumns | |
palette(): ProcRowPalette | |
procColors(): bool | |
procGradient(): bool | |
family(): string | |
row(ProcRow $proc, int $row, int $selected, int $selectMax, ?DualSampleGraph $graph = null, bool $followed = false, ?ColorProfile $profile = null): string | Render one row. |
static cpuLabel(float $cpu): string | btop's cpu% text before right-justifying: {:.2f} cut to 3 chars below 10 and in [100, 1000) ("5.6", "100"), kept whole in between ("12.34", which the 4-wide column then cuts to "12.3"), and above 10 000 scaled to thousands with a "k" ("12k"). The cut is a truncation, not a rounding, as btop's string resize is. |
static memLabel(float $percent): string | btop's mem% text: "0%" under 0.01, else {:.1f} cut to 3 chars, trailing "." dropped. |
static threadsLabel(int $threads): string | btop shortens five-digit thread counts to thousands: 12345 → "12K". |
static userLabel(string $user, int $width): string | btop marks a cut user name with a trailing "+" inside the column. |
ProcRowPalette final class
The theme slots a process row reads: three flat colors for text and underlay, two highlight pairs (selected / followed), and the three 101-entry ramps of the distance fade.
| Method | Summary |
|---|---|
static new(Color $mainFg, Color $inactiveFg, array $processStops, Color $selectedBg, Color $selectedFg, ?Color $followedBg = null, ?Color $followedFg = null): self | |
static btop(): self | btop's built-in Default theme. |
withRamps(array $proc, array $procColor, array $process): self | Replace the three ramps with pre-expanded ones. |
withSelected(Color $bg, Color $fg): self | |
withFollowed(Color $bg, Color $fg): self |
SugarCraft\Dashboard\Plugin
Discovery final class
Discovers plugins in the plugin directory.
| Method | Summary |
|---|---|
static scan(string $directory): array | Discover plugins in a directory. |
static defaultDirectory(): ?string | Get the default plugin directory. |
static scanDefault(): array | Discover plugins in the default directory. |
ExternalModule final class
Wraps an external binary as a Module.
| Method | Summary |
|---|---|
__construct(private readonly string $name, private readonly string $command, private readonly array $args = []) | |
name(): string | Get the module name. |
init(): array | Initialize the module. |
update(array $state): array | Update the module state. |
view(array $state, int $width, int $height): string | Render the module view. |
minSize(): array | Get the minimum size required by this module. |
__destruct() | Destructor to clean up the process. |
PluginSdk abstract class
Plugin SDK for authoring plugins in PHP.
| Method | Summary |
|---|---|
static final run(?callable $handler = null): never | Run the plugin as the main loop of its own process. |
Request final class
Request DTO for plugin communication.
| Method | Summary |
|---|---|
__construct(public readonly string $type, public readonly array $data = []) | |
static init(): self | Create an init request. |
static update(array $state): self | Create an update request. |
static view(int $width, int $height, array $state): self | Create a view request. |
static fromJson(string $json): self | Create from JSON string. |
toJson(): string | Convert to JSON string. |
verb(): ?Verb | The parsed verb at the boundary: null for foreign/unknown labels (which still travel as strings so the host can quote them). |
Response final class
Response DTO for plugin communication.
| Method | Summary |
|---|---|
__construct(public readonly string $type, public readonly array $data = []) | |
static init(string $name, array $minSize, int $interval = 0): self | Create an init response. |
static update(array $state): self | Create an update response. |
static view(string $content): self | Create a view response. |
static error(string $message): self | Create an error response. |
static fromJson(string $json): self | Create from JSON string. |
toJson(): string | Convert to JSON string. |
verb(): ?Verb | The parsed verb at the boundary; null for foreign/unknown labels, which still travel as strings so either side can quote them. |
Verb enum
The plugin wire vocabulary (sugar-dashboard-103).
Cases: Init · Update · View · Error
PHP also provides cases(), from() and tryFrom().
Wire final class
Shared doctrine of the plugin wire: the printable-preview budget and the minSize validation/clamp ladder (sugar-dashboard-199 dedup).
| Method | Summary |
|---|---|
static preview(string $raw): string | Printable, length-clipped rendering of an unparsable wire line. |
static clampMinSize(mixed $minSize): array | Validate and clamp a plugin-supplied minSize to a safe default. Must be a two-element array of positive integers; otherwise the fallback placeholder. |
SugarCraft\Dashboard\Position
Center final class
ANSI-aware centering calculations.
| Method | Summary |
|---|---|
static calculateOffsetX(string $content, int $width): int | Calculate the horizontal offset to center content. |
static calculateOffsetY(int $contentHeight, int $height): int | Calculate the vertical offset to center content. |
static measureRenderedView(string $content): array | Measure the rendered view dimensions. |
static center(string $content, int $width, int $height): string | Center content within given dimensions. |
Overlay final class
Auto-positioning helper for overlays.
| Method | Summary |
|---|---|
static calculate(int $overlayWidth, int $overlayHeight, int $anchorX, int $anchorY, int $containerWidth, int $containerHeight): array | Position an overlay relative to an anchor. |
static fitsBelow(int $overlayHeight, int $anchorY, int $containerHeight): bool | Check if overlay would fit below anchor. |
static fitsAbove(int $overlayHeight, int $anchorY): bool | Check if overlay would fit above anchor. |
SugarCraft\Dashboard\Registry
Constructor interface
Type alias for module constructors.
Registry final class
Instance registry for module constructors.
| Method | Summary |
|---|---|
register(string $name, callable $constructor): void | Register a module constructor. |
get(string $name): callable | Get a module factory by name. |
has(string $name): bool | Check if a module is registered. |
list(): array | List all registered module names. |
reset(): void | Empty this registry (host teardown; scratch registries in tests). |
SugarCraft\Dashboard\State
Persistence final class
Atomic persistence for dashboard panel/tab state.
| Method | Summary |
|---|---|
save(string $path, array $data): void | Save state atomically: write to temp file then rename to target. |
load(string $path): ?array | Load persisted state from disk. |
SugarCraft\Dashboard\Support
DurationFormat final class
The one clock-face renderer for non-negative durations.
| Method | Summary |
|---|---|
static hms(int $totalSeconds, ?int $hundredths = null): string | Paint $totalSeconds (>= 0) as H:MM:SS, or MM:SS below an hour. |
ListWindow final class
Scroll-window arithmetic for vertically listed items.
| Method | Summary |
|---|---|
static scrollTop(int $selected, int $height, int $total): int | First visible index for the given active row, visible height, and total item count. |
Troubleshooting
render() returns Loading... instead of the grid
A grid draws nothing until setSize() has been called with a non-zero width and height. setSize() returns a sized copy and leaves the receiver alone, so keep the result. Call it again whenever the terminal is resized.
$grid = $grid->setSize($cols, $rows);
echo $grid->render();
Items added to a grid never appear
withItem() clones the grid and returns the clone, so the receiver never gains the item. A call whose return value is discarded adds nothing. Assign each result, or chain the calls, as the Quickstart does.
A multi-column grid shows one column
StackedGrid stacks every item into a single column when the width is under 90 cells. That threshold is the default of Breakpoint::narrow(), and the grid does not pass another value. Widen the terminal, or show fewer items when the width is narrow.
A meter reads full for a value such as 62
Meter::new() takes a ratio from 0 to 1, not a percentage, and its constructor clamps the ratio into that range. Meter::new(62) is therefore a full bar. Pass the fraction instead.
use SugarCraft\Dashboard\Plot\Chart\Meter;
echo Meter::new(0.62)->withWidth(20)->render(), "\n";
Upstream mapping
Most of the btop-derived code cites its source in the class docblock, as Mirrors aristocratos/btop, and the rest name the project they were adapted from.
Plot\Braille\DualSampleGraph: btopDraw::GraphPlot\Chart\Meter: btopDraw::MeterPlot\Gradient101,Foundation\GradientStore: btopTheme::generateGradientsandTheme::gFoundation\NetAutoScale: btop network-graph ceilingPlot\DistanceFade,Plot\ProcRow\ProcRowComposer: btop process-list distance fade and row layoutKeys\KeyRegistry: teautilsKeyRegistryKeys\KeyMap: the keymap handling in bubble-keymap, adapted to PHP
Changelog and versioning
The package has no separate changelog file and no release tag yet, so it publishes only dev-master. Its history is the commit log of the sugar-dashboard/ directory in the monorepo, at github.com/detain/sugarcraft/commits/master/sugar-dashboard. Most of the deprecated symbols in src/ carry a REMOVED-IN: 2.0.0 marker in their docblock, so they go in 2.0.0. The exceptions are Module\LegacyModule, which names only v0.x, and the ALIGN_* string constants on Components\Card\Footer, which name no version. Do not plan the removal of either for 2.0.0 until a release says so.
Demos.
VHS-recorded GIFs for the library's examples. Regenerated automatically on every push that touches the source.
Layout & Structure
StackedGrid
Multi-column stacked grid layout.
GridLayout
CSS Grid-style layout.
FlexLayout
Flexbox-style layout.
VStack
Vertical stack with alignment.
HStack
Horizontal stack with spacing.
ZStack
Layered stack.
Stack
Basic vertical stack.
Frame
Bordered frame with title.
Panel
Panel with header/footer.
Card
Card container component.
Divider
Horizontal or vertical divider.
BoxDrawing
Unicode box-drawing frame.
BorderText
Text with ASCII border.
Spacer
Empty space filler.
Split
Split layout.
Center
Centered content.
Cover
Cover layout.
Header
Page header.
Footer
Page footer.
Window
Window frame.
Drawer
Drawer panel.Charts
Chart
Bar/line chart with axes.
AreaChart
Area chart for time series.
Bar
Horizontal status bar.
Donut
Donut chart.
Gauge
Horizontal gauge.
GaugeChart
Circular gauge chart.
GaugeCircle
Circular gauge visualization.
Heatmap
Heat map visualization.
RadarChart
Radar/spider chart.
Bubble
Bubble chart.
Bullet
Bullet chart.
Sparkline
Inline sparkline chart.
SparklineBar
Bar-style sparkline.
SparklineArea
Area-style sparkline.
SparkArea
Spark area chart.
FunnelChart
Funnel chart.Form & Input
Input
Text input field.
Textarea
Multi-line text area.
Select
Dropdown select.
Checkbox
Checkbox group.
Radio
Radio button.
Slider
Slider control.
Toggle
Toggle switch.
Switch
Switch component.
Chip
Chip/tag component.
ChipGroup
Group of chips.
Label
Form label.
ComboBox
Combo box.
DatePicker
Date picker.Navigation
Tabs
Tabbed interface.
TabsVertical
Vertical tab navigation.
Navbar
Navigation bar.
Sidebar
Sidebar navigation.
Breadcrumb
Breadcrumb navigation.
Menu
Menu component.Feedback
Alert
Alert/message box.
Toast
Toast message.
Notification
Toast notification.
Spinner
Loading spinner.
Progress
Progress indicator.
ProgressBar
Progress bar.
ProgressRing
Circular progress indicator.
NProgress
npm-style progress bar.
LoadingText
Animated loading text.Data Display
TableBordered
Bordered table.
TableZebra
Zebra-striped table.
List
List renderer.
Tree
Tree structure.
Metric
Metric display.
Stat
Single stat display.
Stats
Statistics display.
MetricsGrid
Grid of metrics.Media
Image
Image display.
Picture
Picture frame.Avatar
User avatar.AvatarGroup
Group of avatars.Icon
Icon display.
QRCode
QR code.
Barcode
Barcode.
Video
Video player.
Audio
Audio player.Text
Text
Word-wrapped text.
Paragraph
Paragraph text.
Code
Code block.
Kbd
Keyboard key display.
Emoji
Emoji display.
FigletText
ASCII art text.
ASCIIBanner
ASCII banner text.
Highlight
Syntax highlighted code.
HexDump
Hex dump viewer.
DotMatrix
Dot matrix display.
Pictogram
Pictogram display.
Boxer
Tree-based layout splitting — a region subdivided by ratio down to content leaves.Status
Clock
Digital clock.
Timer
Countdown timer.
Stopwatch
Stopwatch.
Calendar
Calendar view.
Terminal
Terminal emulator.
LogViewer
Log file viewer.
Log
Log entry.
Console
Terminal console.
State
Application state.
Focus
Focus state management.Advanced
Accordion
Accordion/collapsible.
ActivityFeed
Activity feed.
Badge
Badge/tag component.
Testimonial
Testimonial quote.
Profile
User profile card.
CTA
Call-to-action.
Jumbotron
Jumbotron hero section.
EmptyState
Empty state placeholder.
Skeleton
Loading skeleton.
Marquee
Scrolling marquee text.
Scrollbar
Custom scrollbar.
Tooltip
Tooltip popup.
Popover
Popover content.
Hint
Hint component.
Tag
Tag component.
Rating
Star rating display.
Leaderboard
Leaderboard display.
Diff
Diff view.
Editor
Text editor.
CommandPalette
Command palette.
Modal
Modal dialog.
WordCloud
Word cloud visualization.Dashboard Examples
Dashboard Layout
Layout containers demo.
Dashboard Charts
Charts demo.
Dashboard Form
Form demo.
Dashboard Nav
Navigation demo.
Dashboard Status
Status indicators demo.
Dashboard Text
Text components demo.
Dashboard Time
Time components demo.
Dashboard UI
UI components demo.
Dashboard Complex
Complex layout demo.
Dashboard Data
Data display demo.
Dashboard Devtools
Devtools demo.
Dashboard Accordion Timeline
Accordion and timeline components.
Dashboard Media
Media components demo.