Repository navigation
UiTheme
Pair\Html\UiTheme resolves the active UI renderer and preserves the legacy theme facade used by older Pair code.
It is the runtime bridge behind Application::uiFramework(...), UiRenderer, form controls, pagination helpers, alerts, badges, and LogBar chrome.
Pair ships three built-in renderer names:
nativebootstrapbulma
Native HTML is the default when no framework is selected or when an invalid non-strict value is normalized.
Returns the current renderer name.
$theme = \Pair\Html\UiTheme::current();Overrides the active renderer for the current runtime.
\Pair\Html\UiTheme::setCurrent('bootstrap');Unknown renderer names raise InvalidArgumentException in this strict path.
Restores the default built-in renderer registration and clears cached renderer instances.
This is mostly useful in tests and long-running processes.
Registers a renderer instance immediately.
\Pair\Html\UiTheme::registerRenderer(new App\Html\TailwindRenderer());Registers a renderer class by name. The class is instantiated only when that renderer is selected.
\Pair\Html\UiTheme::registerRendererClass('tailwind', App\Html\TailwindRenderer::class);Prefer this method when the renderer does not require constructor arguments, because unselected framework classes stay unloaded.
Returns the active renderer or a specific renderer by name.
$renderer = \Pair\Html\UiTheme::renderer('bulma');Returns all registered renderer instances, instantiating registered classes as needed.
These methods preserve older theme checks:
isBootstrap(): boolisBulma(): boolisNative(): bool
UiTheme delegates UI output details to the active renderer:
controlClasses(FormControl $control): arraylabelClasses(?string $customClasses = null): ?stringlabelHelpTooltip(string $description): stringselectWrapperClasses(bool $multiple = false): ?stringalertClass(string $variant = 'primary'): stringbadgeClass(string $variant = 'primary'): stringendAlignmentClass(): stringpagination(Router $router, int $page, int $pages): string
UiTheme also exposes optional LogBar hooks:
logBarChromeClasses(): arraysupportsLogBarBreakpoints(): bool
If the selected renderer implements UiLogBarRenderer, Pair uses its LogBar methods. Otherwise, Pair falls back to the native renderer defaults.
- Registering a renderer under a name that does not match
UiRenderer::name(). - Registering a class that does not implement
UiRenderer. - Calling
setCurrent()before registering a custom renderer name. - Putting framework-specific form or LogBar classes directly into controls instead of centralizing them in a renderer.
See also: UiRenderer, UiLogBarRenderer, Application, Form, FormControl, LogBar, Pagination.
Maintained by Viames Marino — VM Ingegneria · Professional enquiries
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js, PairMotion.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4