โ† All 41 libraries

CandyKit

๐ŸŽ CandyKit

CLI presentation helpers

port of charmbracelet/fang cli presentation library-only

CandyKit code coverage

StatusLine, Banner, Section, Stage, HelpText. Library-only โ€” no Symfony Console requirement. Drop into any Composer project to give CLI output the same look as the rest of the stack.

Install

composer require sugarcraft/candy-kit

Quickstart

use SugarCraft\Kit\{StatusLine, Banner};

echo Banner::title('CandyApp', 'v0.1.0'), "\n\n";
echo StatusLine::info   ('connecting to https://example.com'), "\n";
echo StatusLine::success('done in 0.4s'), "\n";
echo StatusLine::warn   ('disk almost full'), "\n";
echo StatusLine::error  ('connection refused'), "\n";

What's in the box

StatusLinesuccess / error / warn / info / prompt static helpers โ€” glyph + message styled per the active theme.
BannerBordered title block with optional subtitle, rounded by default. Useful for app intros / --version output. Title and subtitle are single display lines โ€” embedded escapes, newlines and control bytes are stripped.
ThemePalette of Sprinkles\Style objects keyed by status level. Theme::ansi() ships the colourful palette; Theme::detect() downgrades it to what the output can show via candy-core's ColorProfile::detect() โ€” no escape bytes when STDOUT is not a tty, colour dropped but bold kept under NO_COLOR on a terminal, full colour under CLICOLOR_FORCE / FORCE_COLOR. Every presenter called without a theme uses Theme::detect(); apply the same downgrade to a preset with withColorProfile().
SectionOne-line themed dividers โ€” header() label + fill rule, bare rule(), indented subHeader(). An explicit width is a hard cap: an over-long label is cut with โ€ฆ rather than overflowing.
StagePer-line step renderers โ€” numbered step(), subStep(), and subStepWithProgress() (bar or spinner).
HelpTextfang-style --help page: USAGE, an optional description, and titled two-column key/description sections. Wraps to width (default 80, null = never wrap): long descriptions continue at the description column, and switch to a stacked layout when the key column leaves fewer than 16 cells.

Source & demos

Try the quickstart โ†’

API

ClassMethodDescription
StatusLinesuccess(msg, ?theme)Render a success line
StatusLineerror(msg, ?theme)Render an error line
StatusLinewarn(msg, ?theme)Render a warning line
StatusLineinfo(msg, ?theme)Render an info line
StatusLineprompt(msg, ?theme)Render a prompt line
Bannertitle(title, subtitle = '', ?theme, ?border)Bordered title banner (control bytes stripped from caller text)
Sectionheader(label, ?theme, leftPad = 2, ?width = 80, rune = 'โ”€')Label + fill rule; a non-null width is a hard cap (long labels end in โ€ฆ)
Sectionrule(?theme, ?width = 80, rune = 'โ”€') / subHeader(label, ?theme, indent = 4, ?width = 80, rune = 'ยท')Bare divider / indented nested heading
Stagestep() / subStep() / subStepWithProgress()Numbered step, sub-step, and sub-step with a bar or spinner
HelpTextrender(usage, sections, description = '', ?theme, ?width = 80)Full --help page; wraps to width, null = never wrap, width < 1 throws
HelpTextrenderRows(rows, ?theme, ?width = 80)One two-column block; stacked layout below MIN_DESCRIPTION_WIDTH (16) cells
Themeansi() / detect(?env, ?stream) / plain()Colourful palette / palette downgraded to the stream's ColorProfile / no styling
ThemewithColorProfile(ColorProfile $profile)Downgrade any theme to a colour profile

Demos.

VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.

CLI page

CLI page

StatusLine + Banner + Stage forming a cohesive CLI page.
Logo

Logo

Logo::sugarcraft() preset + custom color + fromAscii.
Section

Section

Styled section with title and themeable body content.
Stage

Stage

Multi-section presentation container.