Skip to content

Celerik\Ui ​

Assets ​

final class Celerik\Ui\Assets

Renders the tags for the prebuilt bundle (public/celerik.css and public/celerik.js).

celerik.js is an ES module that loads each component's library from public/chunks/ only when that component is on the page. Module scripts are deferred, so jQuery and Bootstrap (peer dependencies) only need to be included before these tags.

Constants ​

ConstantValue
STYLESHEET'celerik.css'
SCRIPT'celerik.js'
THEMES['bootstrap', 'material', 'tailwind']
CDN'https://cdn.jsdelivr.net/npm/@celerik/ui@%s/public'

Methods ​

cdnUrl ​

php
static cdnUrl(?string $version = null): string

The bundle's URL on the jsDelivr CDN, for Assets::tags() when you do not serve the package's public/ folder yourself:

php
Assets::tags(Assets::cdnUrl());          // the installed version
Assets::tags(Assets::cdnUrl('0.2.0'));

Allow https://cdn.jsdelivr.net in script-src and style-src if you use a CSP.

php
                    development version (a branch or a path repository).
  • $version: A released version; by default the installed one.
  • Throws InvalidArgumentException When the version is not a release version.
  • Throws LogicException When no version is given and the installed one is a

tags ​

php
static tags(string $baseUrl, ?string $nonce = null, string $theme = 'bootstrap', ?string $customTheme = null): string
php
                      FullCalendar reads to allow the styles it injects at runtime.
php
                            ThemeBuilder), loaded last. Its base must be $theme.
  • $nonce: CSP nonce. Also printed as <meta name="csp-nonce">, which
  • $theme: "bootstrap" (default), "material" or "tailwind".
  • $customTheme: URL of a stylesheet made with Theme::toCss() (or the

Component ​

abstract class Celerik\Ui\Component implements Stringable

Base class for every Celerik UI component.

Components render framework-neutral HTML. Client-side behaviour is attached by the JS bundle, which looks for data-celerik="<name>" and reads the JSON stored in data-celerik-options. No inline scripts are emitted, so pages work under a strict CSP.

Methods ​

__construct ​

php
__construct(?string $id = null)

make ​

php
static make(?string $id = null): static

name ​

php
static name(): string

Short name used for data-celerik and the component registry (e.g. "grid").

toArray ​

php
toArray(): array

Options consumed by the JS wrapper.

render ​

php
render(): string

getId ​

php
getId(): string

options ​

php
options(array $options): static

Merges raw options for the underlying library (DataTables, Chart.js, Parsley...). They are applied last on the client, so they can override any generated setting.

attribute ​

php
attribute(string $name, string|int|float|bool|null $value = true): static

addClass ​

php
addClass(string ...$classes): static

ComponentRegistry ​

final class Celerik\Ui\ComponentRegistry

Maps component names to classes. Plugins register their own components here and the matching initializer on the client with Celerik.register(name, fn).

Methods ​

withDefaults ​

php
static withDefaults(): self

register ​

php
register(string $class): self

has ​

php
has(string $name): bool

create ​

php
create(string $name, ?string $id = null): Component

all ​

php
all(): array

Released under the MIT License.