Skip to content

Caelrik\Ui\Components ​

Accordion ​

final class Caelrik\Ui\Components\Accordion extends Component implements Stringable

Panels that open and close under their headings (the WAI-ARIA accordion; the Telerik PanelBar): a FAQ, a settings page in sections, filters in a sidebar.

Each heading holds a button (aria-expanded) that shows or hides its panel, a region named by the heading. One panel is open at a time, unless multiple(); Up, Down, Home and End move between the headings. Without JavaScript, every panel is shown.

php
Accordion::make('faq')
    ->panel('Shipping', 'We ship within two days.', open: true)
    ->panel('Returns', Html::raw('<p>Thirty days, <a href="/returns">free</a>.</p>'));

Methods ​

name ​

php
static name(): string

panel ​

php
panel(string $title, Stringable|string $content, bool $open = false): self

A panel: its heading, and its content (a component or Html::raw(); a string is text).

multiple ​

php
multiple(bool $multiple = true): self

Panels open and close on their own; by default, opening one closes the others.

headingLevel ​

php
headingLevel(int $level): self

The headings' level, 2 to 6: one below the heading above the accordion.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Action ​

final class Caelrik\Ui\Components\Action implements Stringable

A button that does something: opens a page, or sends a request after an optional confirmation. Use it on its own (a page, a toolbar) or in a Grid's rows (Grid::actions()).

php
Action::link('edit', 'Edit', '/users/{id}/edit');
Action::request('delete', 'Delete', '/users/{id}')->method('DELETE')->variant('danger')
    ->confirm('Delete {name}?', 'This cannot be undone.')->csrf($token);

{field} in the URL, the confirmation and the accessible name is replaced by the row's value (URL-encoded in the URL). A request action is a form: without JavaScript it posts, with the method in _method (Laravel and Symfony read it); with JavaScript it asks for confirmation in a dialog, sends the request with fetch and shows the answer's message.

A request action with a form (form()) opens it in a modal, filled with the row's values, and sends it to its URL instead:

php
Action::request('edit', 'Edit', '/users/{id}')->method('PATCH')
    ->form(Form::make('user-form')->add(Field::text('name')->required()), 'Edit {name}');

Constants ​

ConstantValue
METHODS['POST', 'PUT', 'PATCH', 'DELETE']
VARIANTS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
LABELS['cancel' => 'Cancel', 'failed' => 'The action failed. Try again.']

Methods ​

php
static link(string $name, string $label, string $url): self

A link to a page, e.g. a record's page: /users/{id}.

request ​

php
static request(string $name, string $label, string $url): self

A request to an endpoint, POST unless method() says otherwise.

method ​

php
method(string $method): self

variant ​

php
variant(string $variant): self

The button's color, from Bootstrap: outlined unless solid().

solid ​

php
solid(bool $solid = true): self

confirm ​

php
confirm(string $question, ?string $detail = null): self

Asks before sending the request: the question (the dialog's title) and an optional detail. The confirm button repeats the action's label.

ariaLabel ​

php
ariaLabel(string $ariaLabel): self

The accessible name, when the label alone is ambiguous: 'Delete {name}'. In a grid it defaults to the label and the row's title (Grid::rowTitle()).

csrf ​

php
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): self

The CSRF token: a hidden field for the form, a header for fetch.

labels ​

php
labels(array $labels): self

form ​

php
form(Form $form, ?string $title = null, ?string $submitLabel = null, ?string $size = null): self

Opens a form in a modal, instead of sending the request at once: Save sends the form's fields to the action's URL with its method. In a grid's row, the fields take the row's values (fields named like columns). {field} in the title takes the row's value.

  • A 2xx answer closes the modal and shows its message; a grid reloads its rows.
  • A 422 answer with errors ({"field": ["..."]}) shows them on the fields.

The form's own submit button is left out: the modal has Cancel and $submitLabel (the action's label by default). Without JavaScript, the button is not shown.

hasForm ​

php
hasForm(): bool

modalId ​

php
modalId(): ?string

The id of the modal that holds the form.

renderModal ​

php
renderModal(): string

The modal with the form, once per page: render() includes it, unless told not to (a grid renders it once for all its rows).

getName ​

php
getName(): string

getLabel ​

php
getLabel(): string

hasAriaLabel ​

php
hasAriaLabel(): bool

isRequest ​

php
isRequest(): bool

renderBulkButton ​

php
renderBulkButton(): string

The action as a submit button of a grid's bulk form (Grid::bulkActions()): it posts the selected rows to its URL. {count} in its confirmation is the number of rows selected; _method goes with the button, as each button may have its own.

renderCsrfField ​

php
renderCsrfField(): string

The hidden CSRF field, or an empty string without a token.

fields ​

php
fields(): array

The row fields this action reads, from its URL, confirmation and accessible name.

toArray ​

php
toArray(): array

The action, for a grid that renders rows in JavaScript (server-side mode).

render ​

php
render(array $row = [], bool $small = false, ?string $ariaLabel = null, bool $modal = true): string

The action for a row: {field} takes the row's values.

  • $ariaLabel: An accessible name used when ariaLabel() was not set.
  • $modal: With a form: render the modal too (once per page).

AdminLayout ​

final class Caelrik\Ui\Components\AdminLayout extends Component implements Stringable

The frame of an admin screen: a skip link, an app bar (brand, your items, the user menu), a sidebar with the navigation, and the main content with its breadcrumb and title.

On large screens the sidebar stays beside the content; on small ones it is a panel (Bootstrap's offcanvas, a dialog) opened by the app bar's menu button. Without JavaScript, the sidebar is simply shown above the content.

php
echo AdminLayout::make('app')
    ->brand('Acme', '/')
    ->navigation(Navigation::make('main')->label('Main')->item('Dashboard', '/')->current($path))
    ->userMenu(UserMenu::make('account')->user('Ada Lovelace')->link('Profile', '/profile'))
    ->breadcrumb(Breadcrumb::make()->item('Home', '/')->item('Dashboard'))
    ->title('Dashboard')
    ->content(Html::raw($page));

Constants ​

ConstantValue
LABELS['skip' => 'Skip to main content', 'openNavigation' => 'Open navigation', 'navigation' => 'Navigation', 'close' => 'Close']

Methods ​

name ​

php
static name(): string

brand ​

php
brand(string $name, ?string $url = null): self

The application's name in the app bar, a link to $url.

php
navigation(?Navigation $navigation): self

userMenu ​

php
userMenu(?UserMenu $userMenu): self
php
breadcrumb(?Breadcrumb $breadcrumb): self

title ​

php
title(?string $title): self

The page's heading (h1), under the breadcrumb.

appBar ​

php
appBar(Stringable|string ...$items): self

More in the app bar, before the user menu: components or Html::raw() (a string is text).

content ​

php
content(Stringable|string $content): self

The page's content: components or Html::raw() (a string is escaped text).

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Avatar ​

final class Caelrik\Ui\Components\Avatar extends Component implements Stringable

A person's picture, or their initials on a color picked from their name (AA contrast). It is an image named after the person ("Ada Lovelace, online"), or decorative() next to their written name. A status is a dot whose shape, not only its color, tells it apart. Plain HTML, no JavaScript.

php
Avatar::make()->person('Ada Lovelace')->image('/avatars/ada.jpg')->size('lg')->status('online');

Constants ​

ConstantValue
SIZES['sm', 'md', 'lg', 'xl']
STATUSES['online', 'away', 'busy', 'offline']
LABELS['online' => '{name}, online', 'away' => '{name}, away', 'busy' => '{name}, busy', 'offline' => '{name}, offline']

Methods ​

name ​

php
static name(): string

person ​

php
person(string $name): self

The person's name: the image's name, and where the initials come from.

image ​

php
image(?string $url): self

A picture (relative, http or https; otherwise the initials are shown).

size ​

php
size(string $size): self

status ​

php
status(?string $status): self

decorative ​

php
decorative(bool $decorative = true): self

Hidden from screen readers, when the name is written next to it.

square ​

php
square(bool $square = true): self

Rounded corners instead of a circle (teams, companies).

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

initials ​

php
static initials(string $name): string

"Ada Lovelace" gives "AL", "Plato" gives "P".

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Badge ​

final class Caelrik\Ui\Components\Badge extends Component implements Stringable

A badge: a short status or count, in a Bootstrap color with an AA contrast (text-bg-*). A hidden text completes it for screen readers: "3" reads "3 unread messages". Plain HTML, no JavaScript.

php
Badge::make()->text('3')->color('danger')->pill()->hiddenText('unread messages');

Constants ​

ConstantValue
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']

Methods ​

name ​

php
static name(): string

text ​

php
text(string|int $text): self

color ​

php
color(string $color): self

pill ​

php
pill(bool $pill = true): self

hiddenText ​

php
hiddenText(?string $text): self

Read after the text by screen readers only: what the badge counts or means.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Barcode ​

final class Caelrik\Ui\Components\Barcode extends Component implements Stringable

A one-dimensional barcode drawn by PHP as an SVG (no JavaScript, no inline styles), with its value written under it as text.

  • code128 (default): any ASCII text; runs of digits are packed two by two.
  • ean13: 12 digits (the check digit is added) or 13 (the check digit is checked), as on products and books (ISBN).
  • The drawing is an image named "Barcode: {label}" (the label, or else the value). Dark bars on a light tile, in dark mode and in forced colors too: scanners need them.
php
Barcode::make('isbn')->type('ean13')->value('978020137962')->label('ISBN');

Constants ​

ConstantValue
TYPES['code128', 'ean13']
LABELS['image' => 'Barcode: {label}']

Methods ​

name ​

php
static name(): string

value ​

php
value(string $value): self

label ​

php
label(string $label): self

What the barcode is ("ISBN", "Order number"), written above the value and naming the image.

type ​

php
type(string $type): self

height ​

php
height(int $pixels): self

The height of the bars in pixels (80 by default).

scale ​

php
scale(int $pixels): self

The width of the narrowest bar in pixels, 1 to 4 (2 by default); the barcode shrinks to a narrower container.

showValue ​

php
showValue(bool $show = true): self

hideValue ​

php
hideValue(): self

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

modules ​

php
static modules(string $value, string $type = 'code128'): array

The modules of a barcode, without the quiet zones ("1" a bar, "0" a space), and the text it holds (an EAN-13 with its check digit).

  • Throws InvalidArgumentException when the value cannot be written in this type

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

final class Caelrik\Ui\Components\Breadcrumb extends Component implements Stringable

Where the page sits: Home / Members / Ada Lovelace. A navigation landmark with an ordered list; the last item is the current page (aria-current="page") and is not a link.

php
Breadcrumb::make()->item('Home', '/')->item('Members', '/members')->item('Ada Lovelace');

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The landmark's name; 'Breadcrumb' by default.

item ​

php
item(string $label, ?string $url = null): self

A step of the trail. The last one is the current page: its URL is not linked.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Card ​

final class Caelrik\Ui\Components\Card extends Component implements Stringable

A card: a title, text, a picture, content, actions and a footer (Bootstrap's card). With link(), the title is a link whose click area covers the card, while its actions keep working; the card stays one link in the reading order, not a big one.

php
Card::make('revenue')->title('Revenue')->subtitle('November')
    ->text('Up 12% on October.')->link('/reports/revenue')
    ->actions(Action::link('export', 'Export', '/reports/revenue.csv'));

Methods ​

name ​

php
static name(): string

title ​

php
title(string $title, int $level = 3): self

subtitle ​

php
subtitle(?string $subtitle): self

text ​

php
text(?string $text): self

A paragraph of text under the title.

body ​

php
body(Stringable|string|null $body): self

Content under the text: a component (a chart, a list) or Html::raw(); a string is text.

image ​

php
image(?string $url, string $alt = ''): self

A picture on top: relative, http or https (others are left out). $alt describes it; empty, it is decorative.

php
link(?string $url): self

Makes the title a link, its click area covering the card.

actions ​

php
actions(Action ...$actions): self
php
footer(Stringable|string|null $footer): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

final class Caelrik\Ui\Components\Carousel extends Component implements Stringable

A carousel (the WAI-ARIA carousel pattern): slides shown one at a time, with Previous and Next buttons and a button per slide.

  • Each slide is a group named "2 of 5", or by its label; changes made by the user are announced (the slides are a polite live region, silent while they rotate).
  • autoplay(): a Stop/Start button comes first; rotation pauses while the pointer or focus is in the carousel, stops once the user picks a slide, and does not start for reduced motion (WCAG 2.2.2).
  • Touch screens swipe. Without JavaScript, the slides are shown one under the other.
php
Carousel::make('news')->label('News')
    ->image('/img/lake.jpg', 'Lake Kivu at dawn', caption: 'Our new office')
    ->slide(Html::raw('<h3>Spring sale</h3><p>…</p>'), label: 'Spring sale')
    ->autoplay(6);

Constants ​

ConstantValue
RATIOS['16x9', '4x3', '3x2', '21x9', '1x1']
LABELS['previous' => 'Previous slide', 'next' => 'Next slide', 'start' => 'Start automatic slide show', 'stop' => 'Stop automatic slide show', 'slides' => 'Choose …

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the carousel ("Highlights, carousel").

slide ​

php
slide(Stringable|string $content, ?string $label = null): self

Adds a slide: text (escaped) or HTML (a component, Html::raw()). The label names the slide and its button ("Spring sale"); "2 of 5" and "Slide 2" otherwise.

image ​

php
image(string $src, string $alt, ?string $caption = null, ?string $label = null): self

Adds a picture slide, cropped to the carousel's ratio. The alternative text describes the picture; the caption is shown under it.

autoplay ​

php
autoplay(int $seconds = 5): self

Shows the next slide every $seconds (2 to 60), with a Stop button; 0 turns it off.

loop ​

php
loop(bool $loop = true): self

After the last slide comes the first (true by default); otherwise the buttons stop at the ends.

picker ​

php
picker(bool $picker = true): self

A button per slide (true by default).

ratio ​

php
ratio(string $ratio): self

The pictures' shape: 16x9 (default), 4x3, 3x2, 21x9 or 1x1.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Chart ​

final class Caelrik\Ui\Components\Chart extends Component implements Stringable

Chart backed by Chart.js.

Data is either embedded (labels() + dataset(), or fromRows()) or loaded from an endpoint with url(); the endpoint returns {"data": $chart->toData()}. A visually hidden data table is rendered as the text alternative (WCAG 1.1.1).

Constants ​

ConstantValue
TYPES['line', 'bar', 'pie', 'doughnut', 'radar', 'polarArea', 'scatter', 'bubble']

Methods ​

name ​

php
static name(): string

type ​

php
type(string $type): self

labels ​

php
labels(array $labels): self

dataset ​

php
dataset(string $label, array $data, array $options = []): self

fromRows ​

php
fromRows(iterable $rows, string $labelField, array $series): self

Builds labels and datasets from rows, e.g. an Eloquent or Doctrine result as arrays.

url ​

php
url(string $url): self

title ​

php
title(string $title, bool $visible = true): self

Accessible name of the chart. Also shown above the chart when $visible is true.

height ​

php
height(int $height): self

Fixed height in pixels. Without it the chart keeps Chart.js' default aspect ratio.

patterns ​

php
patterns(bool $enabled = true): self

Gives each series its own point shape and line dash, shown in the legend too, so series can be told apart without color (WCAG 1.4.1). On by default for line, radar and scatter charts; options set per dataset are kept.

toData ​

php
toData(): array

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Chip ​

final class Caelrik\Ui\Components\Chip extends Component implements Stringable

A chip: a compact label, plain, removable or selectable.

  • removable(): a Remove button ("Remove PHP") takes the chip and its hidden field away (JavaScript; without it the button is hidden), moves focus to the next chip's button, says so, and fires a cancelable caelrik:remove.
  • checkbox(): a filter chip, a real checkbox posted with its form, with or without JavaScript.
php
Chip::make()->label('PHP')->removable('skills[]', 'php');
Chip::make('chip-php')->label('PHP')->checkbox('skills[]', 'php', checked: true);

Constants ​

ConstantValue
LABELS['remove' => 'Remove {label}', 'removed' => '{label} removed.']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

avatar ​

php
avatar(?Avatar $avatar): self

A small picture before the label (decorative: the label names the chip).

removable ​

php
removable(?string $name = null, ?string $value = null): self

A Remove button; with a field name, a hidden field posts the value while the chip stays.

checkbox ​

php
checkbox(string $name, string $value, bool $checked = false): self

A filter chip: a checkbox named $name, posting $value when checked.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

ContextMenu ​

final class Caelrik\Ui\Components\ContextMenu extends Component implements Stringable

A menu of actions for an element, opened by a right click, Shift+F10 or the Menu key on it: the files of a list, a grid's rows, the cards of a page.

Targets are the elements matching for(); {field} in the items' URLs and texts takes the target's data-field value (data-id="7" fills {id}). The menu is written in the browser for each target, as an ARIA menu.

A context menu is a shortcut: offer the same actions another way too (a row's buttons, a MenuButton), for users who never right-click, and on touch screens.

php
ContextMenu::make('file-menu')->for('#files [data-id]')
    ->link('Open', '/files/{id}')
    ->action(Action::request('delete', 'Delete {name}', '/files/{id}')->method('DELETE')
        ->confirm('Delete {name}?'));

Methods ​

name ​

php
static name(): string

for ​

php
for(string $selector): self

A CSS selector for the elements the menu opens on.

label ​

php
label(string $label): self

The menu's accessible name; 'Actions' by default.

php
link(string $label, string $url): self

action ​

php
action(Action $action): self

An Action::link() or Action::request() (confirmations included; forms in modals are not supported here).

divider ​

php
divider(): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Diagram ​

final class Caelrik\Ui\Components\Diagram extends Component implements Stringable

A flowchart drawn by PHP as an SVG (no JavaScript, no inline styles), and written as text.

  • Steps are laid out in ranks, downwards or to the right; an arrow that goes back (a loop) is drawn around the side. Each rank is ordered to cross fewer arrows.
  • The SVG is an image named by the caption; under it, "Steps as text" lists every step and where each arrow leads ("Yes: Account created"), with links between the steps.
php
Diagram::make('signup')->label('Sign-up')
    ->node('form', 'Fill in the form')
    ->node('valid', 'Is it valid?', shape: 'decision')
    ->node('done', 'Account created', shape: 'terminal', color: 'success')
    ->edge('form', 'valid')->edge('valid', 'done', 'Yes')->edge('valid', 'form', 'No');

Constants ​

ConstantValue
SHAPES['box', 'terminal', 'decision']
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
DIRECTIONS['down', 'right']
LABELS['image' => '{label}. The steps are written as text below.', 'text' => 'Steps as text', 'next' => 'Next', 'start' => 'Start', 'end' => 'End']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The caption, and the image's name.

direction ​

php
direction(string $direction): self

down (default) or right.

node ​

php
node(string $id, string $text, string $shape = 'box', ?string $color = null): self

A step: a box (default), a terminal (start or end, rounded) or a decision (a diamond).

edge ​

php
edge(string $from, string $to, ?string $label = null): self

An arrow from one step to another, with an optional label ("Yes").

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

FileManager ​

final class Caelrik\Ui\Components\FileManager extends Component implements Stringable

File manager (elFinder). The connector endpoint runs FileManagerConnector::run().

elFinder's own JS and CSS are loaded from assetsUrl() (copy them from vendor/studio-42/elfinder: css, img, js, sounds); jQuery UI comes with the Caelrik chunk, which is loaded only on pages with a file manager.

Methods ​

name ​

php
static name(): string

url ​

php
url(string $url): self

The connector endpoint (it must accept GET and POST).

assetsUrl ​

php
assetsUrl(string $url): self

Base URL of elFinder's assets (css/, img/, js/, sounds/), default "/elfinder".

height ​

php
height(int $height): self

lang ​

php
lang(string $lang): self

Interface language, e.g. "fr" (loaded from assetsUrl()/js/i18n/).

title ​

php
title(string $title): self

Accessible name of the file manager region.

csrf ​

php
csrf(string $token, string $header = 'X-CSRF-TOKEN'): self

The framework's CSRF token, sent as a header with every request (Laravel reads X-CSRF-TOKEN natively). elFinder adds its own token on top.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Form ​

final class Caelrik\Ui\Components\Form extends Component implements Stringable

Bootstrap form with client-side validation (Parsley.js) and input masks (Inputmask).

Client-side validation is a convenience only: always validate again on the server and pass the messages back with errors().

Methods ​

name ​

php
static name(): string

action ​

php
action(string $action): self

method ​

php
method(string $method): self

PUT, PATCH and DELETE are sent as POST with a _method field (Laravel and Symfony convention).

csrf ​

php
csrf(string $token, string $field = '_token'): self

add ​

php
add(Field|Section|Repeater ...$items): self

Fields, sections that group them (Section::make(), Section::fieldset()) and repeaters (Repeater::make()).

columns ​

php
columns(int $columns, string $breakpoint = 'md'): self

Lays the fields and sections out in 1, 2, 3, 4 or 6 columns from a Bootstrap breakpoint up, one column below it. columnSpan() widens a field or section.

wizard ​

php
wizard(string $next = 'Next', string $previous = 'Back', string $progress = 'Progress', string $stepOf = 'Step %d of %d: ', string $completed = 'completed'): self

Shows the form's sections one at a time, as the steps of a wizard, with a step indicator and Back and Next buttons. Next checks the step's fields first; the submit button is on the last step, and after a failed submit the form opens at the first step with an error. Add Section::make() items (and hidden fields).

  • $stepOf: the screen reader prefix of a step's heading (sprintf: step, count)

getFields ​

php
getFields(): array

Every field, including those in sections, in order.

floatingLabels ​

php
floatingLabels(bool $floating = true): self

Bootstrap floating labels for text inputs, selects and textareas.

submit ​

php
submit(?string $label): self

Label of the submit button; null renders no button.

errorSummary ​

php
errorSummary(bool $enabled = true, string $title = 'There is a problem'): self

Lists every error at the top of the form, with a link to each field, and moves focus to the list after a failed submit (server-side or in the browser). Screen readers then announce the problems once, instead of one live region per field (WCAG 3.3.1). The messages next to the fields stay.

errors ​

php
errors(array $errors): self

Server-side validation errors, field name => message or list of messages.

values ​

php
values(array $values): self

Previously submitted values (old input), field name => value.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Gantt ​

final class Caelrik\Ui\Components\Gantt extends Component implements Stringable

A Gantt chart: a table of tasks (name, start, end, progress, what each depends on) whose last column is the timeline. Every row draws its own bar as an SVG sized by attributes (no inline styles), so bars always line up with their rows; the table says everything the bars show.

  • Milestones are diamonds; "Milestone" is written in their progress cell.
  • The timeline has a scale (day, week or month), a line for today and, with JavaScript, arrows from each task to the tasks that depend on it. It scrolls sideways, task names stay.
php
Gantt::make('launch')->label('Product launch')->scale('week')
    ->task('design', 'Design', '2026-11-02', '2026-11-13', progress: 100)
    ->task('build', 'Build', '2026-11-16', '2026-12-11', progress: 40, depends: ['design'])
    ->milestone('release', 'Release', '2026-12-14', depends: ['build']);

Constants ​

ConstantValue
SCALES['day', 'week', 'month']
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
LABELS['task' => 'Task', 'start' => 'Start', 'end' => 'End', 'progress' => 'Progress', 'depends' => 'Depends on', 'timeline' => 'Timeline', 'milestone' => 'Milesto…

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the chart: the table's caption and its scrolling region.

scale ​

php
scale(string $scale): self

day, week (default) or month: the width of a day and the scale's marks.

dateFormat ​

php
dateFormat(string $format): self

The format of the start and end dates (PHP's date() letters), "M j, Y" by default.

today ​

php
today(DateTimeInterface|string|null $today): self

The day of the "today" line (the current day by default); null hides it.

task ​

php
task(string $id, string $name, DateTimeInterface|string $start, DateTimeInterface|string $end, ?int $progress = null, array $depends = [], string $color = 'primary'): self

A task from $start to $end, both days included ("Y-m-d" or a date).

  • $depends: ids of the tasks it waits for

milestone ​

php
milestone(string $id, string $name, DateTimeInterface|string $date, array $depends = [], string $color = 'primary'): self

A milestone: one day, drawn as a diamond.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Gauge ​

final class Caelrik\Ui\Components\Gauge extends Component implements Stringable

A gauge: a value on a scale, as a semicircle (default) or a bar, drawn by PHP as an SVG (no JavaScript, no inline styles). It is a meter (role="meter") named by its label, whose value text gives the value, its band and the target ("72%, High, target 90%").

  • band(): colored ranges of the scale; the value takes its band's color, and the band's name is written next to the value, so the color is never the only sign.
  • target(): a mark across the scale.
php
Gauge::make('cpu')->label('CPU')->value(72)->format('{value}%')
    ->band(0, 60, 'success', 'Normal')->band(60, 85, 'warning', 'High')->band(85, 100, 'danger', 'Critical')
    ->target(90);

Constants ​

ConstantValue
SHAPES['arc', 'linear']
SIZES['sm', 'md', 'lg']
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
LABELS['target' => 'target {target}']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

value ​

php
value(int|float $value): self

range ​

php
range(int|float $min, int|float $max): self

The scale, 0 to 100 by default.

target ​

php
target(int|float|null $target): self

format ​

php
format(string $format): self

How numbers are written: "{value}%", "${value}", "{value} ms". "{value}" by default.

decimals ​

php
decimals(?int $decimals): self

Decimals shown (0 to 4); by default up to 2, without trailing zeros.

band ​

php
band(int|float $from, int|float $to, string $color, ?string $label = null): self

A colored range of the scale, named for the value text ("High").

shape ​

php
shape(string $shape): self

arc (a semicircle, default) or linear (a bar).

linear ​

php
linear(bool $linear = true): self

size ​

php
size(string $size): self

color ​

php
color(string $color): self

The value's color outside the bands: primary by default.

scale ​

php
scale(bool $scale = true): self

The minimum and maximum written at the ends of the scale (shown by default).

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Grid ​

final class Caelrik\Ui\Components\Grid extends Component implements Stringable

Data grid backed by DataTables.

Client-side mode: pass rows with rows(); they are rendered as HTML (readable without JS). Server-side mode: pass an endpoint with url(); the endpoint answers with respond(). Columns with a filter() get a filter bar above the table, shown once JavaScript runs. Actions (actions()) get a last column with a button for each row. A selectable grid (selectable()) gets a first column of checkboxes, and bulk actions (bulkActions()) a bar above the table that sends the selected rows. Columns with a total() get a footer, and a grid grouped by a field (groupBy()) shows a heading row, counted and totalled, before each group. Columns with an editor (Column::editable()) are changed in place and saved to inlineEdit()'s URL.

Constants ​

ConstantValue
EXPORT_FORMATS['copy', 'csv', 'print']
LABELS['filters' => 'Filters', 'any' => 'Any', 'yes' => 'Yes', 'no' => 'No', 'from' => 'From', 'to' => 'To', 'clear' => 'Clear filters', 'actions' => 'Actions', 's…

Methods ​

name ​

php
static name(): string

column ​

php
column(string $field, ?string $title = null, ?callable $configure = null): self

addColumn ​

php
addColumn(Column ...$columns): self

getColumns ​

php
getColumns(): array

url ​

php
url(string $url): self

Switches to server-side mode: paging, sorting and search are done by this endpoint.

rows ​

php
rows(iterable $rows): self

pageSize ​

php
pageSize(int $pageSize): self

pageSizes ​

php
pageSizes(array $pageSizes): self

searchable ​

php
searchable(bool $searchable = true): self

export ​

php
export(string ...$formats): self

caption ​

php
caption(string $caption, bool $visuallyHidden = false): self

Table caption, used by screen readers to identify the table (WCAG 1.3.1).

actions ​

php
actions(Action ...$actions): self

Buttons for each row, in a last column: Action::link() and Action::request(). The fields their URLs and texts read ({id}) must be columns of the grid; hide the ones not to show (Column::hidden()).

selectable ​

php
selectable(string $key = 'id', string $name = 'ids'): self

A first column of checkboxes to select rows, and a box that selects every row of the page. $key identifies a row (a column, hidden or not); bulk actions send the selected keys as $name[]. The selection is kept across pages, filters and sorting.

bulkActions ​

php
bulkActions(Action ...$actions): self

Request actions for the selected rows, in a bar above the table ("3 selected"): Action::request('delete', 'Delete', '/members/bulk-delete')->confirm('Delete {count} members?'). They post the selected keys (ids[]) to their URL. Needs selectable().

emptyState ​

php
emptyState(string $title, ?string $description = null, ?Action $action = null): self

What the grid shows when it has no rows at all, e.g. 'No members yet', 'Invite your team to get started.' and an Action::link() to the invitation page. When search or filters match no row, the grid says so instead, with a button that clears them.

inlineEdit ​

php
inlineEdit(string $url, string $method = 'PATCH'): self

Where a change to an editable cell (Column::editable()) is saved, e.g. '/members/{id}': {field} takes the row's value. The browser sends field and value in a form-encoded POST, with _method set to $method, so that PHP reads them in $_POST. Read them with cellEdit(), and answer with CellEdit::answer() or, for a refused value, a 422 with InvalidCellEdit::toArray().

csrf ​

php
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): self

The CSRF token sent with inline edits, as a form field and a header.

cellEdit ​

php
cellEdit(array $input): CellEdit

Reads an inline edit the browser sent ($_POST): only an editable column's field is accepted, with a value its editor allows.

  • Throws InvalidCellEdit With a message for the user (answer it with a 422).

groupBy ​

php
groupBy(?string $field): self

Groups the rows by a field (a column, hidden or not): they are sorted by it first, and each group starts with a heading row that names it, counts its rows and totals its columns that have a total(). Counts and totals cover the whole group, not only the page.

columnToggle ​

php
columnToggle(bool $enabled = true, bool $remember = true): self

A Columns button that lets the user show or hide columns, except those that are not toggleable() and hidden() ones. With $remember, the choice is kept in the browser (localStorage), per grid id.

rowTitle ​

php
rowTitle(string $field): self

The field that names a row in its buttons' accessible names ("Delete Ada Lovelace"): by default, the first visible column.

labels ​

php
labels(array $labels): self

Translates the filter bar and the actions column, e.g. ['clear' => 'Effacer les filtres'].

respond ​

php
respond(DataSourceInterface $source, array $query): DataResult

Answers a server-side request for this grid.

Only declared columns may be sorted or searched, a column filter applies only as its type says, and the returned rows contain only declared column fields, so nothing else from the data source leaks out.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

HasMenuItems ​

trait Caelrik\Ui\Components\HasMenuItems

The items of a menu (MenuButton, SplitButton): links, actions and dividers. PHP writes a plain list that works without JavaScript; menu.js makes it an ARIA menu.

Methods ​

php
link(string $label, string $url, bool $disabled = false): static

A link. A disabled one is shown, and cannot be chosen.

action ​

php
action(Action $action): static

An action: Action::link() or Action::request() (with its confirmation, or a form).

divider ​

php
divider(): static

ListView ​

final class Caelrik\Ui\Components\ListView extends Component implements Stringable

A list of items, one per row, with a pager: articles, people, products, notifications.

Each item shows row fields: a title (a link with link()), a description, meta texts, an image and actions. Pass the rows with rows() (the browser pages, searches and sorts them; without JavaScript, every item is shown), or an endpoint with url(), answered with respond() and any DataSourceInterface.

php
ListView::make('articles')->label('Articles')
    ->title('title')->link('/articles/{id}')->description('summary')->meta('author', 'published')
    ->sorts(['-published' => 'Newest first', 'title' => 'Title'])->searchable()
    ->rows($articles);

Constants ​

ConstantValue
LAYOUTS['list', 'cards']
LABELS['search' => 'Search', 'sort' => 'Sort by', 'pages' => 'Pages of {label}', 'previous' => 'Previous', 'next' => 'Next', 'page' => 'Page {page}', 'showing' => …

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The list's accessible name, e.g. 'Articles'; it also names the pager.

title ​

php
title(string $field): self

The field each item is titled by: a heading (see headingLevel()), and what names the item's actions ("Edit Ada Lovelace").

description ​

php
description(?string $field): self

meta ​

php
meta(string ...$fields): self

Short texts under the title, e.g. the author and the date.

php
link(?string $template): self

Makes the title a link: {field} takes the row's value, URL-encoded.

image ​

php
image(?string $field, ?string $altField = null): self

A picture from a field holding its URL (relative, http or https; others are left out). Its text alternative comes from $altField; without one, the picture is decorative.

headingLevel ​

php
headingLevel(int $level): self

The level of the items' title headings, 2 to 6: one below the heading above the list.

layout ​

php
layout(string $layout, int $columns = 3): self

'list' (one item per line) or 'cards' (a grid of cards, $columns wide on large screens).

rows ​

php
rows(iterable $rows): self

url ​

php
url(?string $url): self

Server-side mode: the browser asks this endpoint for each page (see respond()).

pageSize ​

php
pageSize(int $pageSize): self

searchable ​

php
searchable(bool $searchable = true): self

A search box over the titles, descriptions and meta texts.

sorts ​

php
sorts(array $sorts): self

The orders the user can choose, the first by default: ['-published' => 'Newest first', 'title' => 'Title']. A leading - sorts descending.

actions ​

php
actions(Action ...$actions): self

Buttons for each item (Action::link(), Action::request(), with a form or not).

emptyState ​

php
emptyState(string $title, ?string $description = null, ?Action $action = null): self

What the list shows when it has no items at all.

labels ​

php
labels(array $labels): self

respond ​

php
respond(DataSourceInterface $source, array $query): DataResult

Answers a server-side request (page, per_page, search, sort): only the list's sorts and text fields are allowed, and the rows hold only the fields the list shows.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Loader ​

final class Caelrik\Ui\Components\Loader extends Component implements Stringable

A loading indicator: Bootstrap's spinner in a status region that says what is loading ("Loading orders"), hidden or shown. The spinner slows down for reduced motion. Plain HTML, no JavaScript.

php
Loader::make()->label('Loading orders')->size('sm')->showLabel();

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

showLabel ​

php
showLabel(bool $show = true): self

Shows the label next to the spinner; otherwise only screen readers read it.

size ​

php
size(string $size): self

grow ​

php
grow(bool $grow = true): self

A growing dot instead of a turning ring.

color ​

php
color(string $color): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Map ​

final class Caelrik\Ui\Components\Map extends Component implements Stringable

A map (Leaflet) with markers, and the same places written as a list under it.

  • The list is the text alternative: each place's name, description and link, and a "Show on map" button that brings its marker into view, opens its popup and moves focus to it.
  • The map is a named region: arrow keys move it, plus and minus zoom (said to screen readers); markers are buttons named after their place. Wheel zoom is off unless scrollZoom(), so the page scrolls past the map; animations stop for reduced motion.
  • Tiles from OpenStreetMap by default; tiles() sets another server and its attribution.
php
Map::make('offices')->label('Our offices')
    ->marker(-1.6792, 29.2228, 'Goma', 'Avenue du Lac 12', url: '/offices/goma')
    ->marker(-2.5083, 28.8608, 'Bukavu', color: 'success');

Constants ​

ConstantValue
SIZES['sm', 'md', 'lg']
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
LABELS['map' => 'map', 'places' => 'Places on the map', 'show' => 'Show on map', 'more' => 'More about {name}', 'keys' => 'Arrow keys move the map, plus and minus …

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the map ("Our offices, map") and its list of places.

center ​

php
center(float $lat, float $lng, ?int $zoom = null): self

Where the map opens; by default it fits its markers.

zoom ​

php
zoom(int $zoom): self

marker ​

php
marker(float $lat, float $lng, string $name, ?string $description = null, ?string $url = null, string $color = 'primary'): self

A place: a marker named $name, with a description and a link in its popup and in the list.

size ​

php
size(string $size): self

sm (15rem), md (22.5rem, default) or lg (30rem) high.

scrollZoom ​

php
scrollZoom(bool $scrollZoom = true): self

Zooms with the mouse wheel (off by default, so the page scrolls past the map).

places ​

php
places(bool $places = true): self

The list of places under the map (shown by default). Hide it only when the same places are written elsewhere on the page.

tiles ​

php
tiles(string $url, string $attribution, ?string $attributionUrl = null, int $maxZoom = 19): self

The tile server ("https://…/{z}/{x}/{y}.png") and the attribution its licence asks for.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

MediaPlayer ​

final class Caelrik\Ui\Components\MediaPlayer extends Component implements Stringable

A video or audio player: a native <video> or <audio> element (it plays without JavaScript, with the browser's controls), which Plyr gives the same accessible controls in every browser: play, a seek bar, the time, volume, captions, speed, picture in picture and full screen, all with the keyboard and named for screen readers.

  • captions() and descriptions() add text tracks (WebVTT); transcript() writes the words under the player, each with a time that plays the media from there (WCAG 1.2).
  • The player is a figure named by its label.
php
MediaPlayer::make('intro')->label('Getting started')
    ->source('/media/intro.mp4', 'video/mp4')->poster('/media/intro.jpg')
    ->captions('/media/intro.en.vtt', 'en', 'English', default: true);

Constants ​

ConstantValue
TYPES['video', 'audio']
LABELS['transcript' => 'Transcript', 'playFrom' => 'Play from {time}', 'unsupported' => 'Your browser cannot play this media.', 'download' => 'Download it']

Methods ​

name ​

php
static name(): string

video ​

php
video(): self

audio ​

php
audio(): self

label ​

php
label(string $label): self

What is played ("Getting started"): it names the player and its controls.

source ​

php
source(string $url, ?string $type = null): self

A file to play, with its MIME type ("video/mp4"). Several sources let the browser pick the first format it plays.

poster ​

php
poster(string $url): self

The picture shown before a video plays.

captions ​

php
captions(string $url, string $language, string $label, bool $default = false): self

Captions (WebVTT): the words and sounds, for people who do not hear them. A default track is on from the start.

subtitles ​

php
subtitles(string $url, string $language, string $label, bool $default = false): self

Subtitles (WebVTT): a translation of the words.

descriptions ​

php
descriptions(string $url, string $language, string $label): self

Audio descriptions (WebVTT): what is seen, for people who do not see it. Browsers expose them to screen readers, which may read them.

transcript ​

php
transcript(array $cues): self

The words under the player, each with a time that plays the media from there: a list of [time, text] or [time, text, speaker], the time in seconds or as "1:05" / "1:02:03".

loop ​

php
loop(bool $loop = true): self

muted ​

php
muted(bool $muted = true): self

Starts muted (a background video). The player never plays on its own: autoplay moves and sounds without warning (WCAG 1.4.2, 2.2.2).

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

final class Caelrik\Ui\Components\MenuButton extends Component implements Stringable

A button that opens a menu of links and actions (the WAI-ARIA menu button; the Telerik DropDownButton): Export ▾ → CSV, Excel, Print.

With JavaScript, the menu opens with Enter, Space or Down (Up: on its last item), its items are chosen with the arrow keys, Home, End and their first letter, and Escape or Tab closes it, returning focus to the button. Without JavaScript, the items are a plain list.

php
MenuButton::make('export')->label('Export')
    ->link('CSV', '/members.csv')->link('Excel', '/members.xlsx')
    ->divider()->action(Action::request('email', 'E-mail me the list', '/members/email'));

Constants ​

ConstantValue
VARIANTS['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

variant ​

php
variant(string $variant, bool $solid = false): self

The button's color, outlined unless solid.

small ​

php
small(bool $small = true): self

align ​

php
align(string $align): self

'start' (the menu's left edge under the button's) or 'end' (right edges aligned).

toArray ​

php
toArray(): array

render ​

php
render(): string
php
link(string $label, string $url, bool $disabled = false): static

A link. A disabled one is shown, and cannot be chosen.

action ​

php
action(Action $action): static

An action: Action::link() or Action::request() (with its confirmation, or a form).

divider ​

php
divider(): static

Inherited from Component: make(), getId(), options(), attribute(), addClass().

final class Caelrik\Ui\Components\Modal extends Component implements Stringable

Bootstrap modal dialog. Bootstrap's JS (the page's bootstrap.bundle) handles opening, focus trapping, Escape and returning focus to the trigger.

Content: a string is escaped text; a Stringable (e.g. a Form, or Html::raw()) is HTML.

Methods ​

name ​

php
static name(): string

title ​

php
title(string $title): self

body ​

php
body(Stringable|string $body): self

button ​

php
button(string $label, string $variant = 'primary', bool $dismiss = false, array $attributes = []): self

Adds a footer button. Extra attributes, e.g. ['form' => 'contact', 'type' => 'submit'], let a footer button submit a form placed in the body.

cancelButton ​

php
cancelButton(string $label = 'Cancel'): self

A secondary footer button that closes the modal.

size ​

php
size(string $size): self

staticBackdrop ​

php
staticBackdrop(bool $static = true): self

Clicking outside does not close the modal (use for forms, to avoid losing input). Escape and the close button still do.

scrollable ​

php
scrollable(bool $scrollable = true): self

centered ​

php
centered(bool $centered = true): self

open ​

php
open(bool $open = true): self

Opens the modal when the page loads, e.g. to show a form again with server errors.

closeLabel ​

php
closeLabel(string $label): self

Accessible label of the × close button.

trigger ​

php
trigger(string $label, string $variant = 'primary', array $attributes = []): string

A button that opens this modal.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

final class Caelrik\Ui\Components\Navigation extends Component implements Stringable

An application's navigation: links, and groups of links that open and close. The sidebar of an AdminLayout (the Telerik Drawer), or a navigation anywhere.

Groups are native disclosures (<details>): they open and close without JavaScript. The link to the current page has aria-current="page"; when no link is the page itself, the closest section (a link whose path starts the current one) has aria-current="true". A group holding the current link starts open.

php
Navigation::make('main')->label('Main')
    ->item('Dashboard', '/')
    ->group('Members', static fn (Navigation $group) => $group
        ->item('All members', '/members')
        ->item('Invitations', '/members/invitations', badge: '3'))
    ->current($_SERVER['REQUEST_URI']);

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The landmark's name, e.g. 'Main'. Name each navigation when a page has more than one.

item ​

php
item(string $label, string $url, ?string $badge = null): self

A link. $badge is a short text after it, e.g. a count ('3').

group ​

php
group(string $label, callable $build): self

A group of links that opens and closes, e.g. a section's pages.

horizontal ​

php
horizontal(bool $horizontal = true): self

A bar of links across the page (a site's menu), its groups opening below their names, instead of a column. With JavaScript, an open group closes with Escape, when another opens, and when focus or a click leaves it.

current ​

php
current(?string $url): self

The current page's URL or path, e.g. $_SERVER['REQUEST_URI'] (its query is ignored).

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Notification ​

final class Caelrik\Ui\Components\Notification extends Component implements Stringable

Toast notifications (Notyf), typically from flash messages after a redirect.

Messages are always treated as text, never HTML. Errors stay until dismissed by default, so they cannot disappear before being read. Without JavaScript the messages are shown as Bootstrap alerts.

Constants ​

ConstantValue
TYPES['success', 'error', 'info', 'warning']

Methods ​

name ​

php
static name(): string

add ​

php
add(string $type, string $message): self

success ​

php
success(string $message): self

error ​

php
error(string $message): self

info ​

php
info(string $message): self

warning ​

php
warning(string $message): self

fromFlash ​

php
fromFlash(array $flash): self

Adds flash messages: key => message or list of messages. Common keys are mapped (status → success, danger → error, notice → info...); unknown keys are ignored.

Laravel: ->fromFlash(session()->only(['success', 'status', 'error', 'warning', 'info'])) Symfony: ->fromFlash($request->getSession()->getFlashBag()->all())

position ​

php
position(string $x, string $y): self

Screen position: x "left", "center" or "right"; y "top" or "bottom".

duration ​

php
duration(int $milliseconds): self

Display time in milliseconds for success, info and warning messages.

errorDuration ​

php
errorDuration(int $milliseconds): self

Display time for errors; 0 (default) keeps them until dismissed.

dismissible ​

php
dismissible(bool $dismissible = true): self

dismissLabel ​

php
dismissLabel(string $label): self

Accessible name of the dismiss buttons (default "Dismiss notification").

getMessages ​

php
getMessages(): array

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

OrgChart ​

final class Caelrik\Ui\Components\OrgChart extends Component implements Stringable

An organization chart: people in nested lists, drawn as a tree by CSS (connectors are borders, no inline styles). Screen readers hear lists and their levels; it needs no JavaScript. In a narrow container it becomes an indented list; otherwise it scrolls sideways.

  • collapsible(): each manager gets a button that shows or hides their team ("Ada Lovelace's team, 3 people"), with aria-expanded; expandLevels() sets how deep it opens.
php
OrgChart::make('team')->label('Engineering')
    ->node('ada', 'Ada Lovelace', 'CTO')
    ->node('alan', 'Alan Turing', 'Lead engineer', parent: 'ada');

Constants ​

ConstantValue
LABELS['team' => '{name}\'s team, {count} people', 'teamOne' => '{name}\'s team, 1 person']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the chart: its region and its top list.

node ​

php
node(string $id, string $name, ?string $title = null, ?string $parent = null, ?string $image = null, ?string $url = null): self

A person: their job title, the id of their manager, a picture and a link.

fromRows ​

php
fromRows(iterable $rows, string $id = 'id', string $parent = 'parent_id', string $name = 'name', string $title = 'title', ?string $image = null, ?string $url = null): self

People from rows (arrays, or objects with public properties), such as database rows.

collapsible ​

php
collapsible(bool $collapsible = true): self

A button on each manager shows or hides their team (needs JavaScript).

expandLevels ​

php
expandLevels(?int $levels): self

How many levels are open at first (1: the top people only); all by default.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

PdfViewer ​

final class Caelrik\Ui\Components\PdfViewer extends Component implements Stringable

A PDF viewer (PDF.js, loaded only by pages that use it): the pages drawn in a scrolling area, with a text layer that screen readers read and the browser's search finds, a toolbar (previous and next page, a page number, zoom) and a download link, always there.

  • The viewer is a region named by its label; the download link is the way to open the document in another reader (a screen reader's own PDF support, a tagged PDF), and the fallback without JavaScript.
  • No inline styles: the pages are sized by the CSSOM.
php
PdfViewer::make('report')->url('/files/report.pdf')->label('Annual report 2026');

Constants ​

ConstantValue
SIZES['sm', 'md', 'lg']
ZOOMS['fit', 50, 75, 100, 125, 150, 200, 300]
LABELS['toolbar' => 'Pages and zoom', 'previous' => 'Previous page', 'next' => 'Next page', 'page' => 'Page', 'of' => 'of {total}', 'zoomOut' => 'Zoom out', 'zoomI…

Methods ​

name ​

php
static name(): string

url ​

php
url(string $url): self

The document: a relative, http or https URL, on the same origin or served with CORS.

label ​

php
label(string $label): self

The document's title ("Annual report 2026"): it names the viewer.

page ​

php
page(int $page): self

The page shown first.

zoom ​

php
zoom(string|int $zoom): self

"fit" (the width of the viewer, default) or a percentage: 50, 75, 100, 125, 150, 200, 300.

size ​

php
size(string $size): self

The height of the viewer: sm (24rem), md (40rem, default) or lg (60rem), never more than the screen.

download ​

php
download(bool $download = true): self

Whether the download link is shown (yes by default). Without it, the document still downloads from the error and no-JavaScript messages.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Popover ​

final class Caelrik\Ui\Components\Popover extends Component implements Stringable

A popover: a button that shows a small panel of content next to it (help, details, a few links). It is a native disclosure (<details>), so it opens without JavaScript; with it, Escape closes it and returns focus to its button, and it closes when focus or a click goes elsewhere. The panel follows the button in the reading and tab order.

php
Popover::make('pricing-help')->button('How is the price set?')->title('Pricing')
    ->content('Prices include taxes and are set per seat.');

Methods ​

name ​

php
static name(): string

button ​

php
button(string $text, ?string $label = null): self

The button's text; $label names it for screen readers when the text is a symbol ("?").

variant ​

php
variant(string $variant): self

Bootstrap's button variant: outline-secondary (the default), primary, link...

title ​

php
title(?string $title): self

content ​

php
content(Stringable|string $content): self

The panel's content: a component or Html::raw(); a string is escaped text.

align ​

php
align(string $align): self

Aligns the panel with the button's start (the default) or end.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Progress ​

final class Caelrik\Ui\Components\Progress extends Component implements Stringable

Progress: a bar (a native <progress>, sized without inline styles) or a circle (an SVG progressbar), named by its label, its value shown or not. Without a value it is indeterminate: something is going on, how much is not known. Plain HTML, no JavaScript; to move it, set the bar's value, or the circle's aria-valuenow and its arc.

php
Progress::make()->label('Uploading report.pdf')->value(40)->showValue();
Progress::make()->label('Profile complete')->value(3)->max(4)->circle()->color('success');

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label, bool $visible = true): self

value ​

php
value(int|float|null $value): self

The value, from 0 to max; null for an indeterminate progress.

max ​

php
max(int|float $max): self

showValue ​

php
showValue(bool $show = true): self

Shows the percentage.

circle ​

php
circle(bool $circle = true): self

color ​

php
color(string $color): self

size ​

php
size(string $size): self

sm, md or lg: the bar's thickness, the circle's diameter.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

QrCode ​

final class Caelrik\Ui\Components\QrCode extends Component implements Stringable

A QR code drawn by PHP as an SVG (no JavaScript, no inline styles), with its content written under it, so that nobody needs a phone to read it.

  • The drawing is an image named "QR code: {label}" (the label, or else the value).
  • The value is written in the caption, as a link when it is a web address; hideValue() keeps it out of the caption (a long token), and the label then says what the code is for.
  • Dark modules on a light tile, in dark mode and in forced colors too: scanners need them.
php
QrCode::make('site')->value('https://example.com')->label('Our website');

Constants ​

ConstantValue
LABELS['image' => 'QR code: {label}']

Methods ​

name ​

php
static name(): string

value ​

php
value(string $value): self

The text the code holds: a web address, a phone number, a Wi-Fi setup…

label ​

php
label(string $label): self

What the code is for ("Our website"), written above the value and naming the image.

level ​

php
level(string $level): self

The error correction: L (7%), M (15%, default), Q (25%) or H (30%). A higher level makes a denser code that still scans when damaged or partly covered.

size ​

php
size(int $pixels): self

The width and height in pixels (160 by default); the code shrinks to a narrower container.

showValue ​

php
showValue(bool $show = true): self

hideValue ​

php
hideValue(): self

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

RecordView ​

final class Caelrik\Ui\Components\RecordView extends Component implements Stringable

A read-only layout of a record's fields, by sections (Filament's infolists): each section a heading and a description list of labels and values, in one to four columns (one on small screens). The record is an array, an ArrayAccess (an Eloquent model) or an object; fields use dot notation ("company.name").

php
RecordView::make('member')->record($member)
    ->section('Profile', [Entry::text('name', 'Name'), Entry::email('email', 'E-mail')], columns: 2)
    ->section('Account', [Entry::badge('status', 'Status', ['active' => 'success'])]);

Constants ​

ConstantValue
LABELS['empty' => 'Not set', 'yes' => 'Yes', 'no' => 'No']

Methods ​

name ​

php
static name(): string

record ​

php
record(object|array $record): self

section ​

php
section(?string $title, array $entries, ?string $description = null, int $columns = 1): self

A section: a heading (none with null), a description, its entries and its columns (1 to 4).

headingLevel ​

php
headingLevel(int $level): self

The sections' headings, h2 (the default) to h6.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Scheduler ​

final class Caelrik\Ui\Components\Scheduler extends Component implements Stringable

Scheduler / calendar backed by FullCalendar (MIT plugins only).

Events are embedded with events() or loaded per visible range from url(); the endpoint answers with respond(). With createUrl(), updateUrl() and deleteUrl() users can add, move, resize and remove events; each change is POSTed as JSON with the CSRF header, and rolled back in the calendar if the server rejects it.

Constants ​

ConstantValue
VIEWS['month' => 'dayGridMonth', 'week' => 'timeGridWeek', 'day' => 'timeGridDay', 'list' => 'listWeek']
LABELS['newEvent', 'confirmDelete', 'createEvent', 'editEvent', 'title', 'allDay', 'start', 'end', 'save', 'cancel', 'delete', 'titleRequired', 'startRequired', 'e…

Methods ​

name ​

php
static name(): string

view ​

php
view(string $view): self

Initial view: month, week, day or list.

views ​

php
views(string ...$views): self

Views offered in the toolbar, in order.

date ​

php
date(DateTimeInterface|string $date): self

Initially displayed date (defaults to today).

url ​

php
url(string $url): self

Loads events for each visible range from this endpoint (answered by respond()).

events ​

php
events(iterable $events): self

Embedded events, also rendered as a list for browsers without JavaScript.

businessHours ​

php
businessHours(string $start = '09:00', string $end = '17:00', array $days = [1, 2, 3, 4, 5]): self

Highlights working hours, e.g. businessHours('08:00', '18:00', [1, 2, 3, 4, 5]).

  • $days: 0 = Sunday ... 6 = Saturday

slotTimes ​

php
slotTimes(string $min, string $max): self

Visible hours in the week and day views, e.g. slotTimes('07:00', '20:00').

firstDay ​

php
firstDay(int $day): self

First day of the week: 0 = Sunday, 1 = Monday...

locale ​

php
locale(string $locale): self

BCP 47 locale for dates and toolbar texts, e.g. "fr" or "en-GB".

timeZone ​

php
timeZone(string $timeZone): self

"local" (browser time zone, default), "UTC" or an IANA name such as "Europe/Paris".

title ​

php
title(string $title): self

Accessible name of the calendar region.

createUrl ​

php
createUrl(string $url): self

Endpoint receiving new events (selecting a time range creates one).

updateUrl ​

php
updateUrl(string $url): self

Endpoint receiving moved and resized events, from dragging or from the event dialog (Enter, Space or a click on an event), so dates can be changed without a mouse.

deleteUrl ​

php
deleteUrl(string $url): self

Endpoint receiving deleted events. With updateUrl() the event dialog has a Delete button; otherwise clicking (or Enter on) an event without a URL asks to delete it.

csrf ​

php
csrf(string $token, string $header = 'X-CSRF-TOKEN'): self

CSRF token sent in a header with every change (Laravel reads X-CSRF-TOKEN natively).

labels ​

php
labels(array $labels): self

Translates the prompts and the event dialog, e.g. ['save' => 'Enregistrer']. "{title}" in confirmDelete and editEvent is replaced by the event title.

respond ​

php
respond(EventSourceInterface $source, array $query): EventResult

Answers FullCalendar's request for the visible range (?start=...&end=...).

  • Throws InvalidArgumentException When the range is missing, invalid or too long: answer with HTTP 400.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Skeleton ​

final class Caelrik\Ui\Components\Skeleton extends Component implements Stringable

A skeleton: grey shapes standing for content that is loading (Bootstrap's placeholders). Screen readers hear its status ("Loading profile"), not the shapes; the glow stops for reduced motion. Plain HTML, no JavaScript.

php
Skeleton::make()->label('Loading profile')->avatar()->heading()->lines(3);

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

avatar ​

php
avatar(bool $avatar = true): self

heading ​

php
heading(bool $heading = true): self

image ​

php
image(bool $image = true): self

A picture's place, above the text.

lines ​

php
lines(int $lines): self

still ​

php
still(bool $still = true): self

Still shapes, without the glow.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Sparkline ​

final class Caelrik\Ui\Components\Sparkline extends Component implements Stringable

A sparkline: a small chart drawn by PHP as an SVG (no JavaScript, no inline styles), the size of a word, for text, table cells and record views. It is an image named after its values' range ("Revenue, last 7 values: from 8 to 16, lowest 8, highest 16."), or decorative() when the values are written next to it.

php
Sparkline::make()->label('Revenue')->values([8, 9, 12, 11, 14, 13, 16])->type('area')->markLast();

Constants ​

ConstantValue
TYPES['line', 'area', 'bar']
SIZES['sm', 'md', 'lg']
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']
LABELS['name' => '{label}, last {count} values: from {first} to {last}, lowest {min}, highest {max}.']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

What the values are ("Revenue"): the start of the image's name.

values ​

php
values(array $values): self
  • $values: two or more numbers, oldest first

type ​

php
type(string $type): self

line (default), area (a line over a tinted area) or bar.

size ​

php
size(string $size): self

sm, md (default) or lg; it scales with the text around it.

color ​

php
color(string $color): self

Bootstrap's colors, kept at 3:1 against the page: primary by default.

markLast ​

php
markLast(bool $mark = true): self

A dot on the last value (line and area).

decorative ​

php
decorative(bool $decorative = true): self

Hidden from screen readers, when the values are written next to it.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

points ​

php
static points(array $values, int $width, int $height): array

The points of a line through the values, in a width × height box: a 2-unit margin keeps the stroke inside, and equal values draw a line in the middle.

describe ​

php
static describe(string $template, string $label, array $values): string

The name of a sparkline: the template with {label}, {count}, {first}, {last}, {min}, {max}.

numbers ​

php
static numbers(array $values): array

Inherited from Component: make(), getId(), options(), attribute(), addClass().

SplitButton ​

final class Caelrik\Ui\Components\SplitButton extends Component implements Stringable

A main action with a menu of others beside it: Save | ▾ Save as draft, Save and close. The main action is any Action; the arrow is a menu button named "More options".

php
SplitButton::make('save')->main(Action::request('save', 'Save', '/posts/1')->variant('primary')->solid())
    ->action(Action::request('draft', 'Save as draft', '/posts/1/draft'))
    ->link('Preview', '/posts/1/preview');

Constants ​

ConstantValue
LABELS['more' => 'More options']

Methods ​

name ​

php
static name(): string

main ​

php
main(Action $action): self

variant ​

php
variant(string $variant, bool $solid = false): self

The arrow's color: the main action's, if you set its variant.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string
php
link(string $label, string $url, bool $disabled = false): static

A link. A disabled one is shown, and cannot be chosen.

action ​

php
action(Action $action): static

An action: Action::link() or Action::request() (with its confirmation, or a form).

divider ​

php
divider(): static

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Splitter ​

final class Caelrik\Ui\Components\Splitter extends Component implements Stringable

Panes side by side (or one above the other) that the user resizes: a file list and a preview, a form and its help (the WAI-ARIA window splitter).

Between two panes, a divider is a focusable separator whose value is the first pane's size: Left and Right (Up and Down for panes one above the other) resize it, Home and End go to its limits, Enter collapses it to its minimum and back; it can also be dragged. Sizes are set by JavaScript (no inline styles, for a strict CSP); without it the panes share the space.

php
Splitter::make('mail')->pane($folders, size: 25, min: 15, label: 'Folders')->pane($message, label: 'Message');

Constants ​

ConstantValue
LABELS['resize' => 'Resize {pane}']

Methods ​

name ​

php
static name(): string

orientation ​

php
orientation(string $orientation): self

'horizontal': panes side by side; 'vertical': one above the other.

pane ​

php
pane(Stringable|string $content, ?float $size = null, float $min = 10.0, float $max = 90.0, string $label = ''): self

A pane: its content, its size and limits in percent of the splitter, and its name (the divider after it is named after it). A pane without a size shares what is left.

remember ​

php
remember(bool $remember = true): self

Keeps the user's sizes in the browser (localStorage), per splitter id.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Stat ​

final class Caelrik\Ui\Components\Stat extends Component implements Stringable

A stat tile: a label, a value, a trend against a previous period and a sparkline.

The trend's direction is said in words ("Up", "Down"), not only by its arrow and color; the sparkline is an SVG drawn by PHP (no JavaScript, no inline styles) whose name gives its values' range. Put several in Stats.

php
Stat::make('revenue')->label('Revenue')->value('$12,400')
    ->trend(12.5, 'vs last month')->sparkline([8, 9, 12, 11, 14, 13, 16]);

Constants ​

ConstantValue
LABELS['up' => 'Up', 'down' => 'Down', 'flat' => 'No change', 'sparkline' => '{label}, last {count} values: from {first} to {last}, lowest {min}, highest {max}.']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

value ​

php
value(string|int|float $value): self

The value as shown: a string, or a number (thousands separated, up to 2 decimals).

description ​

php
description(string $description): self

trend ​

php
trend(float $change, string $text = '', string $suffix = '%'): self

The change against a previous period (12.5 for +12.5%), what it compares with, and its unit ('%' by default; '' for a count).

goodWhen ​

php
goodWhen(string $direction): self

Which way is good: 'up' (the default; green when it rises) or 'down' (costs, churn, response times: green when it falls).

sparkline ​

php
sparkline(array $values): self

The last values, oldest first (two or more numbers).

color ​

php
color(string $color): self

The sparkline's color (Bootstrap's): primary by default.

php
link(?string $url): self

Makes the label a link whose click area covers the tile (relative, http or https).

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Stats ​

final class Caelrik\Ui\Components\Stats extends Component implements Stringable

A row of stat tiles: a list, named by its label, in 1 to 6 columns (two on small screens, one on phones).

php
Stats::make('kpis')->label('This month')->columns(4)->add($revenue, $orders, $visits, $churn);

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the list for screen readers ("Key figures, list, 4 items").

columns ​

php
columns(int $columns): self

add ​

php
add(Stat ...$stats): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Tabs ​

final class Caelrik\Ui\Components\Tabs extends Component implements Stringable

Bootstrap tabs following the WAI-ARIA tabs pattern (tablist, tab, tabpanel). Bootstrap's JS switches panels and handles arrow-key navigation.

Content: a string is escaped text; a Stringable (e.g. a Grid, or Html::raw()) is HTML.

Methods ​

name ​

php
static name(): string

tab ​

php
tab(string $id, string $label, Stringable|string $content): self

active ​

php
active(string $id): self

Initially selected tab (defaults to the first one).

style ​

php
style(string $style): self

"tabs" (default), "pills" or "underline".

fill ​

php
fill(bool $fill = true): self

Tabs share the full width.

rememberInHash ​

php
rememberInHash(bool $remember = true): self

Keeps the selected tab in the URL hash (#profile), so links and reloads open it.

label ​

php
label(string $label): self

Accessible name of the tab list (aria-label), e.g. "Account settings".

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

TaskBoard ​

final class Caelrik\Ui\Components\TaskBoard extends Component implements Stringable

A task board (Kanban): columns of cards that move from one column to another.

Every card has a "Move to" choice and button: a form that posts without JavaScript, and a way to move cards without dragging (WCAG 2.5.7). With JavaScript, cards are also dragged (SortableJS), and moved from the keyboard: Space picks a card up, the arrow keys move it, Space drops it and Escape cancels, each step announced. A move is sent to moveUrl().

php
TaskBoard::make('sprint')->label('Sprint')
    ->columns(['todo' => 'To do', 'doing' => ['label' => 'In progress', 'limit' => 3], 'done' => 'Done'])
    ->cards($tasks, column: 'status')->description('summary')->meta('owner')
    ->moveUrl('/tasks/{id}/move')->csrf($token);

Constants ​

ConstantValue
LABELS['move' => 'Move', 'moveTo' => 'Move {card} to', 'help' => 'Press Space to pick up a card. Move it with the arrow keys, then press Space to drop it, or Escap…

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

columns ​

php
columns(array $columns): self

The columns, in order: key => label, or key => ['label' => ..., 'limit' => 3]. A limit stops cards from being dropped into a full column in the browser; check it on the server too.

cards ​

php
cards(iterable $rows, string $id = 'id', string $column = 'status', string $title = 'title'): self

The cards, in order within each column. $column is the field that holds a card's column key; cards whose column is not on the board are left out.

description ​

php
description(?string $field): self

meta ​

php
meta(string ...$fields): self
php
link(?string $template): self

Makes a card's title a link: {field} takes the card's value, URL-encoded.

moveUrl ​

php
moveUrl(string $url, string $method = 'PATCH'): self

Where a move is sent, e.g. '/tasks/{id}/move': a form-encoded POST with column, position (from 0; left out without JavaScript), _method and the CSRF token. Read it with cardMove(); answer a refused move with a 422 and InvalidCardMove::toArray().

csrf ​

php
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): self

headingLevel ​

php
headingLevel(int $level): self

The columns' heading level, 2 to 5; the cards' titles are one level below.

labels ​

php
labels(array $labels): self

cardMove ​

php
cardMove(array $input): CardMove

Reads a move the browser sent ($_POST): a column of the board, and a position from 0.

  • Throws InvalidCardMove With a message for the user (answer it with a 422).

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

ThemeBuilder ​

final class Caelrik\Ui\Components\ThemeBuilder extends Component implements Stringable

Edit a theme's tokens with a live preview of real components and a WCAG contrast report, then export the stylesheet (Theme::toCss()) or the theme JSON.

php
ThemeBuilder::make('builder')
    ->theme(Theme::fromJson(file_get_contents('theme.json')))
    ->preview($grid, $form, $chart);

It is a development tool: put it behind authentication or a local-only route. Without JavaScript it is a form (with a contrast report computed in PHP) that posts the theme to saveUrl(); with JavaScript the preview, the report and the export are live.

Constants ​

ConstantValue
LABELS['title' => 'Theme builder', 'name' => 'Theme name', 'light' => 'Light mode colors', 'dark' => 'Dark mode colors', 'shape' => 'Shape', 'radius' => 'Corner ra…
TOKENS['primary' => ['Primary', 'Buttons, links, active tabs, the current page, calendar events.'], 'primaryHover' => ['Primary, hovered', 'Hovered and pressed but…
SHADOW_NAMES['none' => 'None', 'subtle' => 'Subtle', 'elevated' => 'Elevated', 'outlined' => 'Outlined']
FONTS['system-ui, -apple-system, "Segoe UI", Roboto, sans-serif', 'ui-sans-serif, system-ui, sans-serif, \'Apple Color Emoji\', \'Segoe UI Emoji\'', 'Inter, syste…

Methods ​

name ​

php
static name(): string

theme ​

php
theme(Theme $theme): self

The theme to start from (default: the bootstrap preset), also the one Reset restores.

preview ​

php
preview(Stringable|string ...$items): self

Components (or trusted HTML) shown in the preview, e.g. a Grid, a Form and a Chart.

saveUrl ​

php
saveUrl(string $url): self

Endpoint receiving the theme: a JSON body from the Save button, or the form fields without JavaScript. Read it with ThemeBuilder::fromRequest().

csrf ​

php
csrf(string $token, string $field = '_token'): self

assetsUrl ​

php
assetsUrl(string $url): self
php
        which were removed. It will be removed in 1.0.

labels ​

php
labels(array $labels): self

@param array<string, string> $labels Keys from self::LABELS, or token names for their label.

fromRequest ​

php
static fromRequest(array $form, string $body = ''): Theme

The theme posted to saveUrl(): a JSON body (the Save button, {"theme": {...}}) or the form fields (without JavaScript, theme[light][primary]…). Check the CSRF token first.

php
$theme = ThemeBuilder::fromRequest($_POST, file_get_contents('php://input'));
file_put_contents('theme.json', $theme->toJson());
  • $form: The parsed form fields ($_POST, $request->request->all()).
  • $body: The raw request body, for JSON requests.
  • Throws InvalidArgumentException When the theme is missing or invalid: answer with HTTP 422.

getTheme ​

php
getTheme(): Theme

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

TileLayout ​

final class Caelrik\Ui\Components\TileLayout extends Component implements Stringable

A dashboard of tiles on a grid of columns: each tile a titled region, as wide and as high as its spans. The user can rearrange them (reorderable(), resizable()):

  • each tile's Arrange button shows its tools (Move earlier, Move later, Narrower, Wider, Shorter, Taller), buttons that work with one click or the keyboard (WCAG 2.5.7);
  • on that button, the arrow keys move the tile, and with Shift resize it;
  • the button can be dragged to another tile's place, and the tile's corner to a new size. Tiles move in the page, so the reading and focus order follow what is seen. Without JavaScript the tiles are shown as laid out by PHP; on small screens, in one column.
php
TileLayout::make('dashboard')->columns(4)
    ->tile('revenue', 'Revenue', $chart, cols: 2)
    ->tile('orders', 'Orders', $list, rows: 2)
    ->reorderable()->resizable()->remember();

Constants ​

ConstantValue
MAX_COLUMNS12
MAX_ROWS6
LABELS['arrange' => 'Arrange {tile}', 'helpMove' => 'The arrow keys move the tile.', 'helpResize' => 'With Shift, they resize it.', 'earlier' => 'Move earlier', 'l…

Methods ​

name ​

php
static name(): string

columns ​

php
columns(int $columns): self

The grid's columns, 1 to 12 (3 by default). Small screens show one.

tile ​

php
tile(string $key, string $title, Stringable|string $content, int $cols = 1, int $rows = 1): self

A tile: its key (for ids and saved layouts), its title, its content (a component or Html::raw(); a string is escaped text), and how many columns and rows it spans.

headingLevel ​

php
headingLevel(int $level): self

The tiles' headings, h2 (the default) to h6.

reorderable ​

php
reorderable(bool $reorderable = true): self

resizable ​

php
resizable(bool $resizable = true): self

remember ​

php
remember(bool $remember = true): self

Keeps the user's layout in the browser (localStorage), per layout id. To keep it on the server, listen to the caelrik:change event.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Timeline ​

final class Caelrik\Ui\Components\Timeline extends Component implements Stringable

A timeline: an ordered list of events, each with a title, a time (a <time> element for a date), a description, a colored marker and an optional link. The current step is marked with aria-current="step" and a ring. On wide screens, alternate() puts the events on both sides of the line. Plain HTML, no JavaScript.

php
Timeline::make('order')->label('Order history')
    ->event('Order placed', new DateTimeImmutable('2026-11-01 09:30'), 'Paid by card.', color: 'success')
    ->event('Shipped', 'Yesterday', current: true);

Constants ​

ConstantValue
COLORS['primary', 'secondary', 'success', 'danger', 'warning', 'info']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

Names the list for screen readers ("Order history, list, 4 items").

headingLevel ​

php
headingLevel(?int $level): self

Event titles as headings (h2 to h6), to move from one event to the next; paragraphs by default.

dateFormat ​

php
dateFormat(string $format): self

The format of dates (PHP's date() letters), "M j, Y" by default.

alternate ​

php
alternate(bool $alternate = true): self

Events on both sides of the line on wide screens (one side on phones).

event ​

php
event(string $title, DateTimeInterface|string|null $time = null, Stringable|string|null $content = null, ?string $color = null, ?string $marker = null, ?string $url = null, bool $current = false): self

Adds an event. A date is shown in the date format inside a <time> element; a string ("Yesterday") is shown as it is. The marker is a short decorative text ("✓", "3").

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Toolbar ​

final class Caelrik\Ui\Components\Toolbar extends Component implements Stringable

A row of controls: actions, menu buttons, split buttons, your own buttons and fields.

With JavaScript it is a WAI-ARIA toolbar: one tab stop, and Left, Right, Home and End move between its controls (a menu button's own keys still open its menu). Without, each control is a tab stop.

php
Toolbar::make('members-tools')->label('Members')
    ->add(Action::link('new', 'New member', '/members/new')->variant('primary')->solid())
    ->separator()
    ->add($exportMenu, $moreSplit);

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The toolbar's accessible name, e.g. 'Members' or 'Text formatting'. Required.

add ​

php
add(Stringable|string ...$items): self

Controls: components (Action, MenuButton, SplitButton...) or Html::raw() (a string is escaped text).

separator ​

php
separator(): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Tooltip ​

final class Caelrik\Ui\Components\Tooltip extends Component implements Stringable

A tooltip: a short text describing a control, shown while it is hovered or focused (the WAI-ARIA tooltip pattern). It meets WCAG 1.4.13: the pointer can move onto it, Escape hides it without moving focus, and it stays until the pointer or focus leaves. The control describes itself with it (aria-describedby) and keeps its own name: a tooltip is extra, never the only name of an icon button. It needs JavaScript; without it, nothing is shown.

php
Tooltip::make()->text('Saves a draft you can finish later')->trigger($saveButton);

Methods ​

name ​

php
static name(): string

text ​

php
text(string $text): self

trigger ​

php
trigger(Stringable|string $trigger): self

The control it describes: a component, Html::raw(), or escaped text (then focusable).

placement ​

php
placement(string $placement): self

'top' (the default) or 'bottom'; it flips when there is no room.

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

TreeList ​

final class Caelrik\Ui\Components\TreeList extends Component implements Stringable

A table whose rows nest like a tree: tasks and subtasks, an organisation, a budget with its lines, folders with their sizes.

PHP writes a table that reads without JavaScript: every row, in tree order, its first cell indented by its level. With JavaScript it becomes a WAI-ARIA treegrid: rows open and close, one tab stop, arrow keys between rows and cells.

php
TreeList::make('tasks')->caption('Tasks')
    ->column('name', 'Task')->column('owner', 'Owner')->column('hours', 'Hours')
    ->rows($tasks, id: 'id', parent: 'parent_id');

Constants ​

ConstantValue
MAX_INDENT12
LABELS['expandAll' => 'Expand all', 'collapseAll' => 'Collapse all', 'actions' => 'Actions']

Methods ​

name ​

php
static name(): string

column ​

php
column(string $field, ?string $title = null, ?callable $configure = null): self

The first column holds the tree: its cells are indented and show the open and close marks. Columns take a Grid column's settings (title, className(), width(), hidden()).

caption ​

php
caption(string $caption, bool $visuallyHidden = false): self

rows ​

php
rows(iterable $rows, string $id = 'id', string $parent = 'parent_id'): self

Rows with a parent field ($parent), or with their children under children. A row whose parent is not among the rows is a top-level row; rows in a cycle are left out.

expanded ​

php
expanded(string|int ...$ids): self

Rows open at first, by id. Others start closed (with JavaScript).

expandAll ​

php
expandAll(bool $expandAll = true): self

actions ​

php
actions(Action ...$actions): self

Buttons for each row, in a last column (Action::link(), Action::request(), with a form or not), named with the row's title.

rowTitle ​

php
rowTitle(string $field): self

The field that names a row in its buttons ("Delete Design"): by default, the first column.

labels ​

php
labels(array $labels): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

TreeView ​

final class Caelrik\Ui\Components\TreeView extends Component implements Stringable, JsonSerializable

A tree of nodes: folders, categories, an outline, a site's pages.

PHP writes nested lists that read and work without JavaScript: links are links, and a selectable() or checkable() tree has real radio buttons or checkboxes that post with the form around it. With JavaScript it becomes a WAI-ARIA tree: one tab stop, arrow keys to move, open and close, Home and End, type-ahead, Space to select or check.

php
TreeView::make('folders')->label('Folders')->nodes([
    ['id' => 1, 'label' => 'Documents', 'expanded' => true, 'children' => [
        ['id' => 2, 'label' => 'Invoices', 'href' => '/folders/2'],
    ]],
]);

A node: label (required), id, href, children, expanded, checked (or selected), disabled, and hasChildren for children loaded from url() when the node opens.

Constants ​

ConstantValue
LABELS['loading' => 'Loading…', 'failed' => 'The items could not be loaded.']

Methods ​

name ​

php
static name(): string

label ​

php
label(string $label): self

The tree's accessible name, e.g. 'Folders'.

nodes ​

php
nodes(iterable $nodes): self

fromRows ​

php
fromRows(iterable $rows, string $id = 'id', string $parent = 'parent_id', string $label = 'name', ?string $href = null): self

Builds the nodes from flat rows with a parent field, e.g. categories from a database. A row whose parent is not among the rows is a root. $href's {field} takes the row's value, URL-encoded.

selectable ​

php
selectable(string $name): self

One node can be selected: a radio button named $name, which posts the node's id.

checkable ​

php
checkable(string $name): self

Nodes can be checked: a checkbox per node, named $name[], which posts the checked ids. Checking a parent checks its children; a parent with some children checked is mixed.

url ​

php
url(?string $url): self

Where children of a hasChildren node come from: {id} takes the node's id. The endpoint answers {"data": [nodes]} (see children()).

expandAll ​

php
expandAll(bool $expandAll = true): self

Every node starts open, not only those marked expanded.

labels ​

php
labels(array $labels): self

children ​

php
static children(iterable $nodes): array

An endpoint's answer for a node's children: {"data": [nodes]}, checked like nodes().

getNodes ​

php
getNodes(): array

toArray ​

php
toArray(): array

jsonSerialize ​

php
jsonSerialize(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

UserMenu ​

final class Caelrik\Ui\Components\UserMenu extends Component implements Stringable

The signed-in user's menu, in an app bar: their name and picture (or initials), and links such as Profile, plus actions such as Sign out (an Action::request()).

It is a disclosure (<details>), not an ARIA menu: it opens and closes without JavaScript, and its links are read and reached as links. With JavaScript, Escape closes it and returns focus to its button, and it closes when focus or a click leaves it.

php
UserMenu::make('account')->user('Ada Lovelace', 'ada@example.com', '/avatars/ada.jpg')
    ->link('Profile', '/profile')->link('Settings', '/settings')
    ->divider()->action(Action::request('logout', 'Sign out', '/logout')->csrf($token));

Methods ​

name ​

php
static name(): string

user ​

php
user(string $name, ?string $detail = null, ?string $avatar = null): self

The user's name, a detail under it in the menu (e.g. their e-mail), and their picture's URL (relative, http or https; otherwise their initials are shown).

php
link(string $label, string $url): self

action ​

php
action(Action $action): self

An action in the menu, e.g. Sign out: Action::request('logout', 'Sign out', '/logout').

divider ​

php
divider(): self

toArray ​

php
toArray(): array

render ​

php
render(): string

Inherited from Component: make(), getId(), options(), attribute(), addClass().

Released under the MIT License.