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.
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
static name(): stringpanel
panel(string $title, Stringable|string $content, bool $open = false): selfA panel: its heading, and its content (a component or Html::raw(); a string is text).
multiple
multiple(bool $multiple = true): selfPanels open and close on their own; by default, opening one closes the others.
headingLevel
headingLevel(int $level): selfThe headings' level, 2 to 6: one below the heading above the accordion.
toArray
toArray(): arrayrender
render(): stringInherited 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()).
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:
Action::request('edit', 'Edit', '/users/{id}')->method('PATCH')
->form(Form::make('user-form')->add(Field::text('name')->required()), 'Edit {name}');Constants
| Constant | Value |
|---|---|
METHODS | ['POST', 'PUT', 'PATCH', 'DELETE'] |
VARIANTS | ['primary', 'secondary', 'success', 'danger', 'warning', 'info'] |
LABELS | ['cancel' => 'Cancel', 'failed' => 'The action failed. Try again.'] |
Methods
link
static link(string $name, string $label, string $url): selfA link to a page, e.g. a record's page: /users/{id}.
request
static request(string $name, string $label, string $url): selfA request to an endpoint, POST unless method() says otherwise.
method
method(string $method): selfvariant
variant(string $variant): selfThe button's color, from Bootstrap: outlined unless solid().
solid
solid(bool $solid = true): selfconfirm
confirm(string $question, ?string $detail = null): selfAsks before sending the request: the question (the dialog's title) and an optional detail. The confirm button repeats the action's label.
ariaLabel
ariaLabel(string $ariaLabel): selfThe 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
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): selfThe CSRF token: a hidden field for the form, a header for fetch.
labels
labels(array $labels): selfform
form(Form $form, ?string $title = null, ?string $submitLabel = null, ?string $size = null): selfOpens 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
hasForm(): boolmodalId
modalId(): ?stringThe id of the modal that holds the form.
renderModal
renderModal(): stringThe modal with the form, once per page: render() includes it, unless told not to (a grid renders it once for all its rows).
getName
getName(): stringgetLabel
getLabel(): stringhasAriaLabel
hasAriaLabel(): boolisRequest
isRequest(): boolrenderBulkButton
renderBulkButton(): stringThe 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
renderCsrfField(): stringThe hidden CSRF field, or an empty string without a token.
fields
fields(): arrayThe row fields this action reads, from its URL, confirmation and accessible name.
toArray
toArray(): arrayThe action, for a grid that renders rows in JavaScript (server-side mode).
render
render(array $row = [], bool $small = false, ?string $ariaLabel = null, bool $modal = true): stringThe 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.
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
| Constant | Value |
|---|---|
LABELS | ['skip' => 'Skip to main content', 'openNavigation' => 'Open navigation', 'navigation' => 'Navigation', 'close' => 'Close'] |
Methods
name
static name(): stringbrand
brand(string $name, ?string $url = null): selfThe application's name in the app bar, a link to $url.
navigation
navigation(?Navigation $navigation): selfuserMenu
userMenu(?UserMenu $userMenu): selfbreadcrumb
breadcrumb(?Breadcrumb $breadcrumb): selftitle
title(?string $title): selfThe page's heading (h1), under the breadcrumb.
appBar
appBar(Stringable|string ...$items): selfMore in the app bar, before the user menu: components or Html::raw() (a string is text).
content
content(Stringable|string $content): selfThe page's content: components or Html::raw() (a string is escaped text).
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
Avatar::make()->person('Ada Lovelace')->image('/avatars/ada.jpg')->size('lg')->status('online');Constants
| Constant | Value |
|---|---|
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
static name(): stringperson
person(string $name): selfThe person's name: the image's name, and where the initials come from.
image
image(?string $url): selfA picture (relative, http or https; otherwise the initials are shown).
size
size(string $size): selfstatus
status(?string $status): selfdecorative
decorative(bool $decorative = true): selfHidden from screen readers, when the name is written next to it.
square
square(bool $square = true): selfRounded corners instead of a circle (teams, companies).
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringinitials
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.
Badge::make()->text('3')->color('danger')->pill()->hiddenText('unread messages');Constants
| Constant | Value |
|---|---|
COLORS | ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'] |
Methods
name
static name(): stringtext
text(string|int $text): selfcolor
color(string $color): selfpill
pill(bool $pill = true): selfhiddenText
hiddenText(?string $text): selfRead after the text by screen readers only: what the badge counts or means.
toArray
toArray(): arrayrender
render(): stringInherited 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.
Barcode::make('isbn')->type('ean13')->value('978020137962')->label('ISBN');Constants
| Constant | Value |
|---|---|
TYPES | ['code128', 'ean13'] |
LABELS | ['image' => 'Barcode: {label}'] |
Methods
name
static name(): stringvalue
value(string $value): selflabel
label(string $label): selfWhat the barcode is ("ISBN", "Order number"), written above the value and naming the image.
type
type(string $type): selfheight
height(int $pixels): selfThe height of the bars in pixels (80 by default).
scale
scale(int $pixels): selfThe width of the narrowest bar in pixels, 1 to 4 (2 by default); the barcode shrinks to a narrower container.
showValue
showValue(bool $show = true): selfhideValue
hideValue(): selflabels
labels(array $labels): selftoArray
toArray(): arraymodules
static modules(string $value, string $type = 'code128'): arrayThe 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
render(): stringInherited from Component: make(), getId(), options(), attribute(), addClass().
Breadcrumb
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.
Breadcrumb::make()->item('Home', '/')->item('Members', '/members')->item('Ada Lovelace');Methods
name
static name(): stringlabel
label(string $label): selfThe landmark's name; 'Breadcrumb' by default.
item
item(string $label, ?string $url = null): selfA step of the trail. The last one is the current page: its URL is not linked.
toArray
toArray(): arrayrender
render(): stringInherited 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.
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
static name(): stringtitle
title(string $title, int $level = 3): selfsubtitle
subtitle(?string $subtitle): selftext
text(?string $text): selfA paragraph of text under the title.
body
body(Stringable|string|null $body): selfContent under the text: a component (a chart, a list) or Html::raw(); a string is text.
image
image(?string $url, string $alt = ''): selfA picture on top: relative, http or https (others are left out). $alt describes it; empty, it is decorative.
link
link(?string $url): selfMakes the title a link, its click area covering the card.
actions
actions(Action ...$actions): selffooter
footer(Stringable|string|null $footer): selftoArray
toArray(): arrayrender
render(): stringInherited from Component: make(), getId(), options(), attribute(), addClass().
Carousel
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.
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
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfNames the carousel ("Highlights, carousel").
slide
slide(Stringable|string $content, ?string $label = null): selfAdds 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
image(string $src, string $alt, ?string $caption = null, ?string $label = null): selfAdds a picture slide, cropped to the carousel's ratio. The alternative text describes the picture; the caption is shown under it.
autoplay
autoplay(int $seconds = 5): selfShows the next slide every $seconds (2 to 60), with a Stop button; 0 turns it off.
loop
loop(bool $loop = true): selfAfter the last slide comes the first (true by default); otherwise the buttons stop at the ends.
picker
picker(bool $picker = true): selfA button per slide (true by default).
ratio
ratio(string $ratio): selfThe pictures' shape: 16x9 (default), 4x3, 3x2, 21x9 or 1x1.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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
| Constant | Value |
|---|---|
TYPES | ['line', 'bar', 'pie', 'doughnut', 'radar', 'polarArea', 'scatter', 'bubble'] |
Methods
name
static name(): stringtype
type(string $type): selflabels
labels(array $labels): selfdataset
dataset(string $label, array $data, array $options = []): selffromRows
fromRows(iterable $rows, string $labelField, array $series): selfBuilds labels and datasets from rows, e.g. an Eloquent or Doctrine result as arrays.
url
url(string $url): selftitle
title(string $title, bool $visible = true): selfAccessible name of the chart. Also shown above the chart when $visible is true.
height
height(int $height): selfFixed height in pixels. Without it the chart keeps Chart.js' default aspect ratio.
patterns
patterns(bool $enabled = true): selfGives 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
toData(): arraytoArray
toArray(): arrayrender
render(): stringInherited 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.
Chip::make()->label('PHP')->removable('skills[]', 'php');
Chip::make('chip-php')->label('PHP')->checkbox('skills[]', 'php', checked: true);Constants
| Constant | Value |
|---|---|
LABELS | ['remove' => 'Remove {label}', 'removed' => '{label} removed.'] |
Methods
name
static name(): stringlabel
label(string $label): selfavatar
avatar(?Avatar $avatar): selfA small picture before the label (decorative: the label names the chip).
removable
removable(?string $name = null, ?string $value = null): selfA Remove button; with a field name, a hidden field posts the value while the chip stays.
checkbox
checkbox(string $name, string $value, bool $checked = false): selfA filter chip: a checkbox named $name, posting $value when checked.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
static name(): stringfor
for(string $selector): selfA CSS selector for the elements the menu opens on.
label
label(string $label): selfThe menu's accessible name; 'Actions' by default.
link
link(string $label, string $url): selfaction
action(Action $action): selfAn Action::link() or Action::request() (confirmations included; forms in modals are not supported here).
divider
divider(): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfThe caption, and the image's name.
direction
direction(string $direction): selfdown (default) or right.
node
node(string $id, string $text, string $shape = 'box', ?string $color = null): selfA step: a box (default), a terminal (start or end, rounded) or a decision (a diamond).
edge
edge(string $from, string $to, ?string $label = null): selfAn arrow from one step to another, with an optional label ("Yes").
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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
static name(): stringurl
url(string $url): selfThe connector endpoint (it must accept GET and POST).
assetsUrl
assetsUrl(string $url): selfBase URL of elFinder's assets (css/, img/, js/, sounds/), default "/elfinder".
height
height(int $height): selflang
lang(string $lang): selfInterface language, e.g. "fr" (loaded from assetsUrl()/js/i18n/).
title
title(string $title): selfAccessible name of the file manager region.
csrf
csrf(string $token, string $header = 'X-CSRF-TOKEN'): selfThe 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
toArray(): arrayrender
render(): stringInherited 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
static name(): stringaction
action(string $action): selfmethod
method(string $method): selfPUT, PATCH and DELETE are sent as POST with a _method field (Laravel and Symfony convention).
csrf
csrf(string $token, string $field = '_token'): selfadd
add(Field|Section|Repeater ...$items): selfFields, sections that group them (Section::make(), Section::fieldset()) and repeaters (Repeater::make()).
columns
columns(int $columns, string $breakpoint = 'md'): selfLays 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
wizard(string $next = 'Next', string $previous = 'Back', string $progress = 'Progress', string $stepOf = 'Step %d of %d: ', string $completed = 'completed'): selfShows 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
getFields(): arrayEvery field, including those in sections, in order.
floatingLabels
floatingLabels(bool $floating = true): selfBootstrap floating labels for text inputs, selects and textareas.
submit
submit(?string $label): selfLabel of the submit button; null renders no button.
errorSummary
errorSummary(bool $enabled = true, string $title = 'There is a problem'): selfLists 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
errors(array $errors): selfServer-side validation errors, field name => message or list of messages.
values
values(array $values): selfPreviously submitted values (old input), field name => value.
toArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfNames the chart: the table's caption and its scrolling region.
scale
scale(string $scale): selfday, week (default) or month: the width of a day and the scale's marks.
dateFormat
dateFormat(string $format): selfThe format of the start and end dates (PHP's date() letters), "M j, Y" by default.
today
today(DateTimeInterface|string|null $today): selfThe day of the "today" line (the current day by default); null hides it.
task
task(string $id, string $name, DateTimeInterface|string $start, DateTimeInterface|string $end, ?int $progress = null, array $depends = [], string $color = 'primary'): selfA task from $start to $end, both days included ("Y-m-d" or a date).
$depends: ids of the tasks it waits for
milestone
milestone(string $id, string $name, DateTimeInterface|string $date, array $depends = [], string $color = 'primary'): selfA milestone: one day, drawn as a diamond.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
SHAPES | ['arc', 'linear'] |
SIZES | ['sm', 'md', 'lg'] |
COLORS | ['primary', 'secondary', 'success', 'danger', 'warning', 'info'] |
LABELS | ['target' => 'target {target}'] |
Methods
name
static name(): stringlabel
label(string $label): selfvalue
value(int|float $value): selfrange
range(int|float $min, int|float $max): selfThe scale, 0 to 100 by default.
target
target(int|float|null $target): selfformat
format(string $format): selfHow numbers are written: "{value}%", "${value}", "{value} ms". "{value}" by default.
decimals
decimals(?int $decimals): selfDecimals shown (0 to 4); by default up to 2, without trailing zeros.
band
band(int|float $from, int|float $to, string $color, ?string $label = null): selfA colored range of the scale, named for the value text ("High").
shape
shape(string $shape): selfarc (a semicircle, default) or linear (a bar).
linear
linear(bool $linear = true): selfsize
size(string $size): selfcolor
color(string $color): selfThe value's color outside the bands: primary by default.
scale
scale(bool $scale = true): selfThe minimum and maximum written at the ends of the scale (shown by default).
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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
| Constant | Value |
|---|---|
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
static name(): stringcolumn
column(string $field, ?string $title = null, ?callable $configure = null): selfaddColumn
addColumn(Column ...$columns): selfgetColumns
getColumns(): arrayurl
url(string $url): selfSwitches to server-side mode: paging, sorting and search are done by this endpoint.
rows
rows(iterable $rows): selfpageSize
pageSize(int $pageSize): selfpageSizes
pageSizes(array $pageSizes): selfsearchable
searchable(bool $searchable = true): selfexport
export(string ...$formats): selfcaption
caption(string $caption, bool $visuallyHidden = false): selfTable caption, used by screen readers to identify the table (WCAG 1.3.1).
actions
actions(Action ...$actions): selfButtons 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
selectable(string $key = 'id', string $name = 'ids'): selfA 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
bulkActions(Action ...$actions): selfRequest 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
emptyState(string $title, ?string $description = null, ?Action $action = null): selfWhat 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
inlineEdit(string $url, string $method = 'PATCH'): selfWhere 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
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): selfThe CSRF token sent with inline edits, as a form field and a header.
cellEdit
cellEdit(array $input): CellEditReads 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
groupBy(?string $field): selfGroups 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
columnToggle(bool $enabled = true, bool $remember = true): selfA 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
rowTitle(string $field): selfThe field that names a row in its buttons' accessible names ("Delete Ada Lovelace"): by default, the first visible column.
labels
labels(array $labels): selfTranslates the filter bar and the actions column, e.g. ['clear' => 'Effacer les filtres'].
respond
respond(DataSourceInterface $source, array $query): DataResultAnswers 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
toArray(): arrayrender
render(): stringInherited 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
link
link(string $label, string $url, bool $disabled = false): staticA link. A disabled one is shown, and cannot be chosen.
action
action(Action $action): staticAn action: Action::link() or Action::request() (with its confirmation, or a form).
divider
divider(): staticListView
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.
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
| Constant | Value |
|---|---|
LAYOUTS | ['list', 'cards'] |
LABELS | ['search' => 'Search', 'sort' => 'Sort by', 'pages' => 'Pages of {label}', 'previous' => 'Previous', 'next' => 'Next', 'page' => 'Page {page}', 'showing' => … |
Methods
name
static name(): stringlabel
label(string $label): selfThe list's accessible name, e.g. 'Articles'; it also names the pager.
title
title(string $field): selfThe field each item is titled by: a heading (see headingLevel()), and what names the item's actions ("Edit Ada Lovelace").
description
description(?string $field): selfmeta
meta(string ...$fields): selfShort texts under the title, e.g. the author and the date.
link
link(?string $template): selfMakes the title a link: {field} takes the row's value, URL-encoded.
image
image(?string $field, ?string $altField = null): selfA 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
headingLevel(int $level): selfThe level of the items' title headings, 2 to 6: one below the heading above the list.
layout
layout(string $layout, int $columns = 3): self'list' (one item per line) or 'cards' (a grid of cards, $columns wide on large screens).
rows
rows(iterable $rows): selfurl
url(?string $url): selfServer-side mode: the browser asks this endpoint for each page (see respond()).
pageSize
pageSize(int $pageSize): selfsearchable
searchable(bool $searchable = true): selfA search box over the titles, descriptions and meta texts.
sorts
sorts(array $sorts): selfThe orders the user can choose, the first by default: ['-published' => 'Newest first', 'title' => 'Title']. A leading - sorts descending.
actions
actions(Action ...$actions): selfButtons for each item (Action::link(), Action::request(), with a form or not).
emptyState
emptyState(string $title, ?string $description = null, ?Action $action = null): selfWhat the list shows when it has no items at all.
labels
labels(array $labels): selfrespond
respond(DataSourceInterface $source, array $query): DataResultAnswers 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
toArray(): arrayrender
render(): stringInherited 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.
Loader::make()->label('Loading orders')->size('sm')->showLabel();Methods
name
static name(): stringlabel
label(string $label): selfshowLabel
showLabel(bool $show = true): selfShows the label next to the spinner; otherwise only screen readers read it.
size
size(string $size): selfgrow
grow(bool $grow = true): selfA growing dot instead of a turning ring.
color
color(string $color): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfNames the map ("Our offices, map") and its list of places.
center
center(float $lat, float $lng, ?int $zoom = null): selfWhere the map opens; by default it fits its markers.
zoom
zoom(int $zoom): selfmarker
marker(float $lat, float $lng, string $name, ?string $description = null, ?string $url = null, string $color = 'primary'): selfA place: a marker named $name, with a description and a link in its popup and in the list.
size
size(string $size): selfsm (15rem), md (22.5rem, default) or lg (30rem) high.
scrollZoom
scrollZoom(bool $scrollZoom = true): selfZooms with the mouse wheel (off by default, so the page scrolls past the map).
places
places(bool $places = true): selfThe list of places under the map (shown by default). Hide it only when the same places are written elsewhere on the page.
tiles
tiles(string $url, string $attribution, ?string $attributionUrl = null, int $maxZoom = 19): selfThe tile server ("https://…/{z}/{x}/{y}.png") and the attribution its licence asks for.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
TYPES | ['video', 'audio'] |
LABELS | ['transcript' => 'Transcript', 'playFrom' => 'Play from {time}', 'unsupported' => 'Your browser cannot play this media.', 'download' => 'Download it'] |
Methods
name
static name(): stringvideo
video(): selfaudio
audio(): selflabel
label(string $label): selfWhat is played ("Getting started"): it names the player and its controls.
source
source(string $url, ?string $type = null): selfA file to play, with its MIME type ("video/mp4"). Several sources let the browser pick the first format it plays.
poster
poster(string $url): selfThe picture shown before a video plays.
captions
captions(string $url, string $language, string $label, bool $default = false): selfCaptions (WebVTT): the words and sounds, for people who do not hear them. A default track is on from the start.
subtitles
subtitles(string $url, string $language, string $label, bool $default = false): selfSubtitles (WebVTT): a translation of the words.
descriptions
descriptions(string $url, string $language, string $label): selfAudio descriptions (WebVTT): what is seen, for people who do not see it. Browsers expose them to screen readers, which may read them.
transcript
transcript(array $cues): selfThe 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
loop(bool $loop = true): selfmuted
muted(bool $muted = true): selfStarts 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
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited from Component: make(), getId(), options(), attribute(), addClass().
MenuButton
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.
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
| Constant | Value |
|---|---|
VARIANTS | ['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'] |
Methods
name
static name(): stringlabel
label(string $label): selfvariant
variant(string $variant, bool $solid = false): selfThe button's color, outlined unless solid.
small
small(bool $small = true): selfalign
align(string $align): self'start' (the menu's left edge under the button's) or 'end' (right edges aligned).
toArray
toArray(): arrayrender
render(): stringlink
link(string $label, string $url, bool $disabled = false): staticA link. A disabled one is shown, and cannot be chosen.
action
action(Action $action): staticAn action: Action::link() or Action::request() (with its confirmation, or a form).
divider
divider(): staticInherited from Component: make(), getId(), options(), attribute(), addClass().
Modal
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
static name(): stringtitle
title(string $title): selfbody
body(Stringable|string $body): selfbutton
button(string $label, string $variant = 'primary', bool $dismiss = false, array $attributes = []): selfAdds a footer button. Extra attributes, e.g. ['form' => 'contact', 'type' => 'submit'], let a footer button submit a form placed in the body.
cancelButton
cancelButton(string $label = 'Cancel'): selfA secondary footer button that closes the modal.
size
size(string $size): selfstaticBackdrop
staticBackdrop(bool $static = true): selfClicking outside does not close the modal (use for forms, to avoid losing input). Escape and the close button still do.
scrollable
scrollable(bool $scrollable = true): selfcentered
centered(bool $centered = true): selfopen
open(bool $open = true): selfOpens the modal when the page loads, e.g. to show a form again with server errors.
closeLabel
closeLabel(string $label): selfAccessible label of the × close button.
trigger
trigger(string $label, string $variant = 'primary', array $attributes = []): stringA button that opens this modal.
toArray
toArray(): arrayrender
render(): stringInherited from Component: make(), getId(), options(), attribute(), addClass().
Navigation
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.
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
static name(): stringlabel
label(string $label): selfThe landmark's name, e.g. 'Main'. Name each navigation when a page has more than one.
item
item(string $label, string $url, ?string $badge = null): selfA link. $badge is a short text after it, e.g. a count ('3').
group
group(string $label, callable $build): selfA group of links that opens and closes, e.g. a section's pages.
horizontal
horizontal(bool $horizontal = true): selfA 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
current(?string $url): selfThe current page's URL or path, e.g. $_SERVER['REQUEST_URI'] (its query is ignored).
toArray
toArray(): arrayrender
render(): stringInherited 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
| Constant | Value |
|---|---|
TYPES | ['success', 'error', 'info', 'warning'] |
Methods
name
static name(): stringadd
add(string $type, string $message): selfsuccess
success(string $message): selferror
error(string $message): selfinfo
info(string $message): selfwarning
warning(string $message): selffromFlash
fromFlash(array $flash): selfAdds 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
position(string $x, string $y): selfScreen position: x "left", "center" or "right"; y "top" or "bottom".
duration
duration(int $milliseconds): selfDisplay time in milliseconds for success, info and warning messages.
errorDuration
errorDuration(int $milliseconds): selfDisplay time for errors; 0 (default) keeps them until dismissed.
dismissible
dismissible(bool $dismissible = true): selfdismissLabel
dismissLabel(string $label): selfAccessible name of the dismiss buttons (default "Dismiss notification").
getMessages
getMessages(): arraytoArray
toArray(): arrayrender
render(): stringInherited 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.
OrgChart::make('team')->label('Engineering')
->node('ada', 'Ada Lovelace', 'CTO')
->node('alan', 'Alan Turing', 'Lead engineer', parent: 'ada');Constants
| Constant | Value |
|---|---|
LABELS | ['team' => '{name}\'s team, {count} people', 'teamOne' => '{name}\'s team, 1 person'] |
Methods
name
static name(): stringlabel
label(string $label): selfNames the chart: its region and its top list.
node
node(string $id, string $name, ?string $title = null, ?string $parent = null, ?string $image = null, ?string $url = null): selfA person: their job title, the id of their manager, a picture and a link.
fromRows
fromRows(iterable $rows, string $id = 'id', string $parent = 'parent_id', string $name = 'name', string $title = 'title', ?string $image = null, ?string $url = null): selfPeople from rows (arrays, or objects with public properties), such as database rows.
collapsible
collapsible(bool $collapsible = true): selfA button on each manager shows or hides their team (needs JavaScript).
expandLevels
expandLevels(?int $levels): selfHow many levels are open at first (1: the top people only); all by default.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
PdfViewer::make('report')->url('/files/report.pdf')->label('Annual report 2026');Constants
| Constant | Value |
|---|---|
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
static name(): stringurl
url(string $url): selfThe document: a relative, http or https URL, on the same origin or served with CORS.
label
label(string $label): selfThe document's title ("Annual report 2026"): it names the viewer.
page
page(int $page): selfThe page shown first.
zoom
zoom(string|int $zoom): self"fit" (the width of the viewer, default) or a percentage: 50, 75, 100, 125, 150, 200, 300.
size
size(string $size): selfThe height of the viewer: sm (24rem), md (40rem, default) or lg (60rem), never more than the screen.
download
download(bool $download = true): selfWhether the download link is shown (yes by default). Without it, the document still downloads from the error and no-JavaScript messages.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
Popover::make('pricing-help')->button('How is the price set?')->title('Pricing')
->content('Prices include taxes and are set per seat.');Methods
name
static name(): stringbutton
button(string $text, ?string $label = null): selfThe button's text; $label names it for screen readers when the text is a symbol ("?").
variant
variant(string $variant): selfBootstrap's button variant: outline-secondary (the default), primary, link...
title
title(?string $title): selfcontent
content(Stringable|string $content): selfThe panel's content: a component or Html::raw(); a string is escaped text.
align
align(string $align): selfAligns the panel with the button's start (the default) or end.
toArray
toArray(): arrayrender
render(): stringInherited 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.
Progress::make()->label('Uploading report.pdf')->value(40)->showValue();
Progress::make()->label('Profile complete')->value(3)->max(4)->circle()->color('success');Methods
name
static name(): stringlabel
label(string $label, bool $visible = true): selfvalue
value(int|float|null $value): selfThe value, from 0 to max; null for an indeterminate progress.
max
max(int|float $max): selfshowValue
showValue(bool $show = true): selfShows the percentage.
circle
circle(bool $circle = true): selfcolor
color(string $color): selfsize
size(string $size): selfsm, md or lg: the bar's thickness, the circle's diameter.
toArray
toArray(): arrayrender
render(): stringInherited 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.
QrCode::make('site')->value('https://example.com')->label('Our website');Constants
| Constant | Value |
|---|---|
LABELS | ['image' => 'QR code: {label}'] |
Methods
name
static name(): stringvalue
value(string $value): selfThe text the code holds: a web address, a phone number, a Wi-Fi setup…
label
label(string $label): selfWhat the code is for ("Our website"), written above the value and naming the image.
level
level(string $level): selfThe 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
size(int $pixels): selfThe width and height in pixels (160 by default); the code shrinks to a narrower container.
showValue
showValue(bool $show = true): selfhideValue
hideValue(): selflabels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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").
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
| Constant | Value |
|---|---|
LABELS | ['empty' => 'Not set', 'yes' => 'Yes', 'no' => 'No'] |
Methods
name
static name(): stringrecord
record(object|array $record): selfsection
section(?string $title, array $entries, ?string $description = null, int $columns = 1): selfA section: a heading (none with null), a description, its entries and its columns (1 to 4).
headingLevel
headingLevel(int $level): selfThe sections' headings, h2 (the default) to h6.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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
| Constant | Value |
|---|---|
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
static name(): stringview
view(string $view): selfInitial view: month, week, day or list.
views
views(string ...$views): selfViews offered in the toolbar, in order.
date
date(DateTimeInterface|string $date): selfInitially displayed date (defaults to today).
url
url(string $url): selfLoads events for each visible range from this endpoint (answered by respond()).
events
events(iterable $events): selfEmbedded events, also rendered as a list for browsers without JavaScript.
businessHours
businessHours(string $start = '09:00', string $end = '17:00', array $days = [1, 2, 3, 4, 5]): selfHighlights working hours, e.g. businessHours('08:00', '18:00', [1, 2, 3, 4, 5]).
$days: 0 = Sunday ... 6 = Saturday
slotTimes
slotTimes(string $min, string $max): selfVisible hours in the week and day views, e.g. slotTimes('07:00', '20:00').
firstDay
firstDay(int $day): selfFirst day of the week: 0 = Sunday, 1 = Monday...
locale
locale(string $locale): selfBCP 47 locale for dates and toolbar texts, e.g. "fr" or "en-GB".
timeZone
timeZone(string $timeZone): self"local" (browser time zone, default), "UTC" or an IANA name such as "Europe/Paris".
title
title(string $title): selfAccessible name of the calendar region.
createUrl
createUrl(string $url): selfEndpoint receiving new events (selecting a time range creates one).
updateUrl
updateUrl(string $url): selfEndpoint 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
deleteUrl(string $url): selfEndpoint 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
csrf(string $token, string $header = 'X-CSRF-TOKEN'): selfCSRF token sent in a header with every change (Laravel reads X-CSRF-TOKEN natively).
labels
labels(array $labels): selfTranslates the prompts and the event dialog, e.g. ['save' => 'Enregistrer']. "{title}" in confirmDelete and editEvent is replaced by the event title.
respond
respond(EventSourceInterface $source, array $query): EventResultAnswers 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
toArray(): arrayrender
render(): stringInherited 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.
Skeleton::make()->label('Loading profile')->avatar()->heading()->lines(3);Methods
name
static name(): stringlabel
label(string $label): selfavatar
avatar(bool $avatar = true): selfheading
heading(bool $heading = true): selfimage
image(bool $image = true): selfA picture's place, above the text.
lines
lines(int $lines): selfstill
still(bool $still = true): selfStill shapes, without the glow.
toArray
toArray(): arrayrender
render(): stringInherited 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.
Sparkline::make()->label('Revenue')->values([8, 9, 12, 11, 14, 13, 16])->type('area')->markLast();Constants
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfWhat the values are ("Revenue"): the start of the image's name.
values
values(array $values): self$values: two or more numbers, oldest first
type
type(string $type): selfline (default), area (a line over a tinted area) or bar.
size
size(string $size): selfsm, md (default) or lg; it scales with the text around it.
color
color(string $color): selfBootstrap's colors, kept at 3:1 against the page: primary by default.
markLast
markLast(bool $mark = true): selfA dot on the last value (line and area).
decorative
decorative(bool $decorative = true): selfHidden from screen readers, when the values are written next to it.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringpoints
static points(array $values, int $width, int $height): arrayThe 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
static describe(string $template, string $label, array $values): stringThe name of a sparkline: the template with {label}, {count}, {first}, {last}, {min}, {max}.
numbers
static numbers(array $values): arrayInherited 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".
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
| Constant | Value |
|---|---|
LABELS | ['more' => 'More options'] |
Methods
name
static name(): stringmain
main(Action $action): selfvariant
variant(string $variant, bool $solid = false): selfThe arrow's color: the main action's, if you set its variant.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringlink
link(string $label, string $url, bool $disabled = false): staticA link. A disabled one is shown, and cannot be chosen.
action
action(Action $action): staticAn action: Action::link() or Action::request() (with its confirmation, or a form).
divider
divider(): staticInherited 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.
Splitter::make('mail')->pane($folders, size: 25, min: 15, label: 'Folders')->pane($message, label: 'Message');Constants
| Constant | Value |
|---|---|
LABELS | ['resize' => 'Resize {pane}'] |
Methods
name
static name(): stringorientation
orientation(string $orientation): self'horizontal': panes side by side; 'vertical': one above the other.
pane
pane(Stringable|string $content, ?float $size = null, float $min = 10.0, float $max = 90.0, string $label = ''): selfA 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
remember(bool $remember = true): selfKeeps the user's sizes in the browser (localStorage), per splitter id.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
Stat::make('revenue')->label('Revenue')->value('$12,400')
->trend(12.5, 'vs last month')->sparkline([8, 9, 12, 11, 14, 13, 16]);Constants
| Constant | Value |
|---|---|
LABELS | ['up' => 'Up', 'down' => 'Down', 'flat' => 'No change', 'sparkline' => '{label}, last {count} values: from {first} to {last}, lowest {min}, highest {max}.'] |
Methods
name
static name(): stringlabel
label(string $label): selfvalue
value(string|int|float $value): selfThe value as shown: a string, or a number (thousands separated, up to 2 decimals).
description
description(string $description): selftrend
trend(float $change, string $text = '', string $suffix = '%'): selfThe change against a previous period (12.5 for +12.5%), what it compares with, and its unit ('%' by default; '' for a count).
goodWhen
goodWhen(string $direction): selfWhich way is good: 'up' (the default; green when it rises) or 'down' (costs, churn, response times: green when it falls).
sparkline
sparkline(array $values): selfThe last values, oldest first (two or more numbers).
color
color(string $color): selfThe sparkline's color (Bootstrap's): primary by default.
link
link(?string $url): selfMakes the label a link whose click area covers the tile (relative, http or https).
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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).
Stats::make('kpis')->label('This month')->columns(4)->add($revenue, $orders, $visits, $churn);Methods
name
static name(): stringlabel
label(string $label): selfNames the list for screen readers ("Key figures, list, 4 items").
columns
columns(int $columns): selfadd
add(Stat ...$stats): selftoArray
toArray(): arrayrender
render(): stringInherited 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
static name(): stringtab
tab(string $id, string $label, Stringable|string $content): selfactive
active(string $id): selfInitially selected tab (defaults to the first one).
style
style(string $style): self"tabs" (default), "pills" or "underline".
fill
fill(bool $fill = true): selfTabs share the full width.
rememberInHash
rememberInHash(bool $remember = true): selfKeeps the selected tab in the URL hash (#profile), so links and reloads open it.
label
label(string $label): selfAccessible name of the tab list (aria-label), e.g. "Account settings".
toArray
toArray(): arrayrender
render(): stringInherited 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().
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
| Constant | Value |
|---|---|
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
static name(): stringlabel
label(string $label): selfcolumns
columns(array $columns): selfThe 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
cards(iterable $rows, string $id = 'id', string $column = 'status', string $title = 'title'): selfThe 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
description(?string $field): selfmeta
meta(string ...$fields): selflink
link(?string $template): selfMakes a card's title a link: {field} takes the card's value, URL-encoded.
moveUrl
moveUrl(string $url, string $method = 'PATCH'): selfWhere 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
csrf(string $token, string $field = '_token', string $header = 'X-CSRF-TOKEN'): selfheadingLevel
headingLevel(int $level): selfThe columns' heading level, 2 to 5; the cards' titles are one level below.
labels
labels(array $labels): selfcardMove
cardMove(array $input): CardMoveReads 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
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
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
static name(): stringtheme
theme(Theme $theme): selfThe theme to start from (default: the bootstrap preset), also the one Reset restores.
preview
preview(Stringable|string ...$items): selfComponents (or trusted HTML) shown in the preview, e.g. a Grid, a Form and a Chart.
saveUrl
saveUrl(string $url): selfEndpoint receiving the theme: a JSON body from the Save button, or the form fields without JavaScript. Read it with ThemeBuilder::fromRequest().
csrf
csrf(string $token, string $field = '_token'): selfassetsUrl
assetsUrl(string $url): self which were removed. It will be removed in 1.0.labels
labels(array $labels): self@param array<string, string> $labels Keys from self::LABELS, or token names for their label.
fromRequest
static fromRequest(array $form, string $body = ''): ThemeThe 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.
$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
getTheme(): ThemetoArray
toArray(): arrayrender
render(): stringInherited 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.
TileLayout::make('dashboard')->columns(4)
->tile('revenue', 'Revenue', $chart, cols: 2)
->tile('orders', 'Orders', $list, rows: 2)
->reorderable()->resizable()->remember();Constants
| Constant | Value |
|---|---|
MAX_COLUMNS | 12 |
MAX_ROWS | 6 |
LABELS | ['arrange' => 'Arrange {tile}', 'helpMove' => 'The arrow keys move the tile.', 'helpResize' => 'With Shift, they resize it.', 'earlier' => 'Move earlier', 'l… |
Methods
name
static name(): stringcolumns
columns(int $columns): selfThe grid's columns, 1 to 12 (3 by default). Small screens show one.
tile
tile(string $key, string $title, Stringable|string $content, int $cols = 1, int $rows = 1): selfA 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
headingLevel(int $level): selfThe tiles' headings, h2 (the default) to h6.
reorderable
reorderable(bool $reorderable = true): selfresizable
resizable(bool $resizable = true): selfremember
remember(bool $remember = true): selfKeeps the user's layout in the browser (localStorage), per layout id. To keep it on the server, listen to the caelrik:change event.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
COLORS | ['primary', 'secondary', 'success', 'danger', 'warning', 'info'] |
Methods
name
static name(): stringlabel
label(string $label): selfNames the list for screen readers ("Order history, list, 4 items").
headingLevel
headingLevel(?int $level): selfEvent titles as headings (h2 to h6), to move from one event to the next; paragraphs by default.
dateFormat
dateFormat(string $format): selfThe format of dates (PHP's date() letters), "M j, Y" by default.
alternate
alternate(bool $alternate = true): selfEvents on both sides of the line on wide screens (one side on phones).
event
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): selfAdds 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
toArray(): arrayrender
render(): stringInherited 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.
Toolbar::make('members-tools')->label('Members')
->add(Action::link('new', 'New member', '/members/new')->variant('primary')->solid())
->separator()
->add($exportMenu, $moreSplit);Methods
name
static name(): stringlabel
label(string $label): selfThe toolbar's accessible name, e.g. 'Members' or 'Text formatting'. Required.
add
add(Stringable|string ...$items): selfControls: components (Action, MenuButton, SplitButton...) or Html::raw() (a string is escaped text).
separator
separator(): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
Tooltip::make()->text('Saves a draft you can finish later')->trigger($saveButton);Methods
name
static name(): stringtext
text(string $text): selftrigger
trigger(Stringable|string $trigger): selfThe control it describes: a component, Html::raw(), or escaped text (then focusable).
placement
placement(string $placement): self'top' (the default) or 'bottom'; it flips when there is no room.
toArray
toArray(): arrayrender
render(): stringInherited 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.
TreeList::make('tasks')->caption('Tasks')
->column('name', 'Task')->column('owner', 'Owner')->column('hours', 'Hours')
->rows($tasks, id: 'id', parent: 'parent_id');Constants
| Constant | Value |
|---|---|
MAX_INDENT | 12 |
LABELS | ['expandAll' => 'Expand all', 'collapseAll' => 'Collapse all', 'actions' => 'Actions'] |
Methods
name
static name(): stringcolumn
column(string $field, ?string $title = null, ?callable $configure = null): selfThe 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
caption(string $caption, bool $visuallyHidden = false): selfrows
rows(iterable $rows, string $id = 'id', string $parent = 'parent_id'): selfRows 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
expanded(string|int ...$ids): selfRows open at first, by id. Others start closed (with JavaScript).
expandAll
expandAll(bool $expandAll = true): selfactions
actions(Action ...$actions): selfButtons for each row, in a last column (Action::link(), Action::request(), with a form or not), named with the row's title.
rowTitle
rowTitle(string $field): selfThe field that names a row in its buttons ("Delete Design"): by default, the first column.
labels
labels(array $labels): selftoArray
toArray(): arrayrender
render(): stringInherited 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.
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
| Constant | Value |
|---|---|
LABELS | ['loading' => 'Loading…', 'failed' => 'The items could not be loaded.'] |
Methods
name
static name(): stringlabel
label(string $label): selfThe tree's accessible name, e.g. 'Folders'.
nodes
nodes(iterable $nodes): selffromRows
fromRows(iterable $rows, string $id = 'id', string $parent = 'parent_id', string $label = 'name', ?string $href = null): selfBuilds 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
selectable(string $name): selfOne node can be selected: a radio button named $name, which posts the node's id.
checkable
checkable(string $name): selfNodes 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
url(?string $url): selfWhere children of a hasChildren node come from: {id} takes the node's id. The endpoint answers {"data": [nodes]} (see children()).
expandAll
expandAll(bool $expandAll = true): selfEvery node starts open, not only those marked expanded.
labels
labels(array $labels): selfchildren
static children(iterable $nodes): arrayAn endpoint's answer for a node's children: {"data": [nodes]}, checked like nodes().
getNodes
getNodes(): arraytoArray
toArray(): arrayjsonSerialize
jsonSerialize(): arrayrender
render(): stringInherited 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.
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
static name(): stringuser
user(string $name, ?string $detail = null, ?string $avatar = null): selfThe 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).
link
link(string $label, string $url): selfaction
action(Action $action): selfAn action in the menu, e.g. Sign out: Action::request('logout', 'Sign out', '/logout').
divider
divider(): selftoArray
toArray(): arrayrender
render(): stringInherited from Component: make(), getId(), options(), attribute(), addClass().