Skip to content

Getting started ​

Caelrik UI is a set of PHP components that render accessible Bootstrap 5 markup. A small JavaScript bundle then enhances them with proven open-source libraries (DataTables, Chart.js, Parsley.js, FullCalendar, Quill, FilePond, Notyf, Leaflet, elFinder), each loaded only on the pages that use it.

You build a component in PHP, print it in your template, and, for server-side data, answer its requests with the same definition.

Requirements ​

  • PHP 8.2 or later, with ext-fileinfo for uploads
  • Bootstrap 5.3 (CSS, and bootstrap.bundle.js for Modal and Tabs) and jQuery 3.7 or 4 on the page
  • Optional: Laravel 11+ or Symfony 7 for the adapters

Install ​

bash
composer require caelrik/ui

Then make the bundle (the package's public/ folder) available to the browser:

bash
php artisan vendor:publish --tag=caelrik-assets   # copies it to public/vendor/caelrik
bash
# Register Caelrik\Ui\Adapters\Symfony\CaelrikUiBundle in config/bundles.php, then:
php bin/console assets:install                    # copies it to public/bundles/caelrik
bash
cp -r vendor/caelrik/ui/public public/vendor/caelrik

Publish the assets again after every Caelrik update. Releases include the built bundle, so no Node.js is needed.

Or use the CDN or npm ​

Instead of publishing the assets, load the bundle of the installed version from jsDelivr:

php
<?= Caelrik\Ui\Assets::tags(Caelrik\Ui\Assets::cdnUrl()) ?>
blade
<x-caelrik-assets :base-url="Caelrik\Ui\Assets::cdnUrl()" />

Allow https://cdn.jsdelivr.net in script-src and style-src if you use a Content Security Policy. With a JavaScript bundler (Vite, webpack), install it from npm instead:

bash
npm install @caelrik/ui
js
import '@caelrik/ui';                       // registers the components and starts them
import '@caelrik/ui/caelrik.css';

The PHP version and the npm version must match: the components and the bundle change together.

Load the assets ​

Load Bootstrap and jQuery first, then the Caelrik tags in the <head>:

blade
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@4.0.0/dist/jquery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
<x-caelrik-assets />
twig
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@4.0.0/dist/jquery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
{{ caelrik_assets() }}
php
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@4.0.0/dist/jquery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" defer></script>
<?= Caelrik\Ui\Assets::tags('/vendor/caelrik') ?>

The tags are a stylesheet and one ES module (caelrik.js). Module scripts are deferred, so they run after jQuery and Bootstrap.

Your first component ​

Grid demo. Data is embedded and nothing is saved.
php
<?php

use Caelrik\Ui\Components\Action;
use Caelrik\Ui\Components\Grid;
use Caelrik\Ui\Components\Grid\Column;
use Caelrik\Ui\Components\Grid\Filter;

return Grid::make('users')
    ->caption('Team members')
    ->column('name', 'Name', static fn (Column $column) => $column->filter(Filter::text())->toggleable(false))
    ->column('role', 'Role', static fn (Column $column) => $column->filter(Filter::select([
        'Engineer' => 'Engineer',
        'Researcher' => 'Researcher',
        'Director' => 'Director',
    ])))
    ->column('remote', 'Remote', static fn (Column $column) => $column->filter(Filter::boolean()))
    ->column('joined', 'Joined', static fn (Column $column) => $column->filter(Filter::dateRange()))
    ->actions(
        Action::link('profile', 'Profile', '?member={name}'),
        // The demo answers requests in the browser: nothing is saved.
        Action::request('remove', 'Remove', '/demo-api/members/{name}')
            ->method('DELETE')
            ->variant('danger')
            ->confirm('Remove {name}?', 'They lose access to the team.'),
    )
    ->columnToggle()
    ->emptyState('No members yet', 'Invite your team to get started.', Action::link('invite', 'Invite', '?invite=1'))
    ->selectable('name', 'members')
    ->bulkActions(
        Action::request('remind', 'Send a reminder', '/demo-api/members/remind')
            ->confirm('Send a reminder to {count} members?'),
    )
    ->export('copy', 'csv')
    ->pageSize(5)
    ->rows([
        ['name' => 'Ada Lovelace', 'role' => 'Engineer', 'remote' => true, 'joined' => '2024-03-12'],
        ['name' => 'Alan Turing', 'role' => 'Researcher', 'remote' => false, 'joined' => '2023-11-02'],
        ['name' => 'Grace Hopper', 'role' => 'Director', 'remote' => false, 'joined' => '2022-06-20'],
        ['name' => 'Katherine Johnson', 'role' => 'Researcher', 'remote' => true, 'joined' => '2025-01-15'],
        ['name' => 'Linus Torvalds', 'role' => 'Engineer', 'remote' => true, 'joined' => '2024-09-30'],
        ['name' => 'Margaret Hamilton', 'role' => 'Director', 'remote' => false, 'joined' => '2021-04-08'],
        ['name' => 'Tim Berners-Lee', 'role' => 'Engineer', 'remote' => true, 'joined' => '2025-07-01'],
    ]);

Print it in your template:

blade
<x-caelrik :component="$grid" />
twig
{{ caelrik(grid) }}
php
<?= $grid ?>

The grid works without JavaScript too: PHP renders a real <table> with its caption and header scopes, and the bundle turns it into a sortable, searchable, paged grid.

Next steps ​

Released under the MIT License.