Celerik\Ui\Components
Chart
final class Celerik\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().
FileManager
final class Celerik\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 Celerik 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 Celerik\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 ...$fields): selfgetFields
getFields(): arrayfloatingLabels
floatingLabels(bool $floating = true): selfBootstrap floating labels for text inputs, selects and textareas (the Material look).
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().
Grid
final class Celerik\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().
Constants
| Constant | Value |
|---|---|
EXPORT_FORMATS | ['copy', 'csv', 'print'] |
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).
respond
respond(DataSourceInterface $source, array $query): DataResultAnswers a server-side request for this grid.
Only declared columns may be sorted or searched, 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().
Modal
final class Celerik\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().
Notification
final class Celerik\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().
Scheduler
final class Celerik\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().
Tabs
final class Celerik\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().
ThemeBuilder
final class Celerik\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::preset('material'))
->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', 'base' => 'Base look', 'preset' => 'Start from a preset', 'loadPreset' => 'Load preset', 'light' => 'Lig… |
TOKENS | ['primary' => ['Primary', 'Buttons, links, active tabs, the current page, calendar events.'], 'primaryHover' => ['Primary, hovered', 'Hovered and pressed but… |
BASE_NAMES | ['bootstrap' => 'Bootstrap', 'material' => 'Material', 'tailwind' => 'Tailwind'] |
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).
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): selfBase URL of the bundle (public/), to switch the base look in the preview. By default it is the directory of the page's celerik.css.
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().