Ui

The declarative UI library: static builder functions that emit semantic markup for content, forms, tables, layout, navigation, tabs, paging and object displays, together with a theme system whose immutable data objects describe how those elements are styled.

This page is a pure reference. For how the framework fits together, see the Guide. Interface is composed by nesting these static calls, passing closures for the content of each container; the theme classes describe styling as plain data.

Classes

Ui

Core response override helpers: clear any buffered output and send new content or a redirect, then exit.

OverrideOutput

Ui::OverrideOutput(string $content, ?string $contentType = null, ?int $httpStatusCode = null): void

Clear all output buffers, optionally set a content type and status code, send the content and exit. Never returns.

NameTypeDescription
$contentstringThe content to send to the browser.
$contentType?stringAn optional content type header.
$httpStatusCode?intAn optional HTTP status code.

Returns void

OverrideRedirect

Ui::OverrideRedirect(string $url): void

Clear all output buffers, send a Location redirect to the given url and exit.

NameTypeDescription
$urlstringThe url path to redirect to.

Returns void

UiCard

Cards linking to a destination, a raw card wrapping custom content, and a flex list to hold cards.

Functions

Card

UiCard::Card(string $title, string $info, string $link, string $optionalImageUrl = null): void

Render a linked card with a heading, optional info paragraph and optional image. The heading level follows the current section depth.

NameTypeDescription
$titlestringThe card heading.
$infostringAn info paragraph; omitted when empty.
$linkstringThe url the card links to.
$optionalImageUrlstringAn optional image url shown at the top.

Returns void

List

UiCard::List(callable $content): void

Wrap the given content in a flex container to lay out a row of cards.

NameTypeDescription
$contentcallableA closure that emits the cards.

Returns void

RawCard

UiCard::RawCard(Callable $content): void

Render a card wrapping arbitrary content emitted by the closure.

NameTypeDescription
$contentCallableA closure that emits the card body.

Returns void

UiCode

A preformatted code block that emits its content unescaped.

Functions
Pre

Pre

UiCode::Pre(string $content)

Emit the content inside a pre element, without escaping.

NameTypeDescription
$contentstringThe preformatted content.

UiContent

The building blocks of page content: layout areas and sections, titles and text, lists, icons, images, links, menus, buttons, asides, headers, footers and collapsible details. Section nesting tracks a depth used to pick heading levels.

Area

UiContent::Area(callable $content): void

Wrap content in a section and main, resetting section depth to zero so titles start at h1.

NameTypeDescription
$contentcallableA closure that emits the area content.

Returns void

Aside

UiContent::Aside(Callable $content): void

Wrap content in an aside element.

NameTypeDescription
$contentCallableA closure that emits the aside content.

Returns void

Button

UiContent::Button(string $u_url, string $text): void

Render a link styled as a button.

NameTypeDescription
$u_urlstringThe url the button links to.
$textstringThe button label.

Returns void

UiContent::ButtonLink(string $u_url, callable $content): void

Render a button-styled link whose contents are emitted by the closure.

NameTypeDescription
$u_urlstringThe url the button links to.
$contentcallableA closure that emits the button contents.

Returns void

Buttons

UiContent::Buttons(Callable $buttonsUi): void

Wrap a group of buttons in a buttons container.

NameTypeDescription
$buttonsUiCallableA closure that emits the buttons.

Returns void

Code

UiContent::Code(string $text): void

Render escaped text inside a pre element.

NameTypeDescription
$textstringThe code text to display.

Returns void

Collapse

UiContent::Collapse(bool $initiallyCollapsed, string $title, callable $content): void

Render a details element with a summary title, open unless initially collapsed.

NameTypeDescription
$initiallyCollapsedboolTrue to start closed, false to start open.
$titlestringThe summary title.
$contentcallableA closure that emits the collapsible content.

Returns void

Div

UiContent::Div(string $divId, callable|null $content = null): void

Render a div with the given id, optionally filled by the closure.

NameTypeDescription
$divIdstringThe div id.
$contentcallable|nullAn optional closure emitting the div content.

Returns void

Footer

UiContent::Footer(Callable $content): void

Wrap content in a footer element.

NameTypeDescription
$contentCallableA closure that emits the footer content.

Returns void

Header

UiContent::Header(Callable $content): void

Wrap content in a header element.

NameTypeDescription
$contentCallableA closure that emits the header content.

Returns void

Icon

UiContent::Icon(string $icon): void

Render an icon name inside a span with the icon class.

NameTypeDescription
$iconstringThe icon name.

Returns void

Image

UiContent::Image(string $url, int $width, int $height): void

Render an image with an explicit width and height.

NameTypeDescription
$urlstringThe image url.
$widthintThe image width in pixels.
$heightintThe image height in pixels.

Returns void

UiContent::Link(string $text, string $url, bool $selected = false): void

Render a link; inside a menu it becomes a list item, marked selected when requested, otherwise a paragraph link.

NameTypeDescription
$textstringThe link text.
$urlstringThe link url.
$selectedboolWhether the menu item is selected.

Returns void

List

UiContent::List(callable $content): void

Wrap content in an unordered list.

NameTypeDescription
$contentcallableA closure that emits the list points.

Returns void

Main

UiContent::Main(callable $content): void

Wrap content in a main element without changing section depth.

NameTypeDescription
$contentcallableA closure that emits the main content.

Returns void

Menu

UiContent::Menu(Callable $content): void

Wrap content in a nav and ordered list, marking the enclosed links as menu items.

NameTypeDescription
$contentCallableA closure that emits the menu links.

Returns void

Panel

UiContent::Panel(callable $content): void

Wrap content in a panel element, increasing section depth for the content.

NameTypeDescription
$contentcallableA closure that emits the panel content.

Returns void

Point

UiContent::Point(string $text): void

Render a list item with escaped text.

NameTypeDescription
$textstringThe list item text.

Returns void

Script

UiContent::Script(Callable $content): void

Wrap content in a script element.

NameTypeDescription
$contentCallableA closure that emits the script body.

Returns void

Section

UiContent::Section(callable $content, string|null $id = null): void

Wrap content in a section, optionally with an id, increasing section depth for the content.

NameTypeDescription
$contentcallableA closure that emits the section content.
$idstring|nullAn optional id for the section element.

Returns void

Text

UiContent::Text(string $text, ?string $optionalText2 = null, ?string $optionalText3 = null, ?string $optionalText4 = null, ?string $optionalText5 = null, ?string $optionalText6 = null, ?string $optionalText7 = null, ?string $optionalText8 = null): void

Render a paragraph from one or more text fragments, concatenated in order.

NameTypeDescription
$textstringThe first text fragment.
$optionalText2?stringAn additional fragment appended in order.
$optionalText3?stringAn additional fragment appended in order.
$optionalText4?stringAn additional fragment appended in order.
$optionalText5?stringAn additional fragment appended in order.
$optionalText6?stringAn additional fragment appended in order.
$optionalText7?stringAn additional fragment appended in order.
$optionalText8?stringAn additional fragment appended in order.

Returns void

TextCarousel

UiContent::TextCarousel(array $prompts): void

Render a paragraph that types through the given prompts in turn using an inline script.

NameTypeDescription
$promptsarrayThe list of prompt strings to cycle through.

Returns void

Title

UiContent::Title(string $text, ?string $optionalText2 = null, ?string $optionalText3 = null, ?string $optionalText4 = null, ?string $optionalText5 = null, ?string $optionalText6 = null, ?string $optionalText7 = null, ?string $optionalText8 = null): void

Render a heading from one or more text fragments; the heading level follows the current section depth.

NameTypeDescription
$textstringThe first text fragment.
$optionalText2?stringAn additional fragment appended in order.
$optionalText3?stringAn additional fragment appended in order.
$optionalText4?stringAn additional fragment appended in order.
$optionalText5?stringAn additional fragment appended in order.
$optionalText6?stringAn additional fragment appended in order.
$optionalText7?stringAn additional fragment appended in order.
$optionalText8?stringAn additional fragment appended in order.

Returns void

UiForm

Forms and their fields: plain and action forms, hidden values, text, number, range, password, textarea, dropdown, checkbox, read-only, file and image inputs, a submit button and an action button.

ActionForm

UiForm::ActionForm(string $formName, callable $formContents, callable $formAction, bool $enableFileupload = false): void

Render a form that posts back to the same url with a ui_form_action query parameter, and run the action callback when that name is posted. The form name must be unique on the page.

NameTypeDescription
$formNamestringA unique form name, also the action value.
$formContentscallableA closure that emits the form fields.
$formActioncallableA closure run when the form is submitted.
$enableFileuploadboolTrue to allow file uploads.

Returns void

ButtonAction

UiForm::ButtonAction(string $label, callable $action, ?string $optionalFormName = null): void

Render a button that triggers an inline form action when clicked; the action runs on submission. A unique form name is generated when none is given.

NameTypeDescription
$labelstringThe button label.
$actioncallableThe action run on submission.
$optionalFormName?stringAn optional custom form name.

Returns void

Checkbox

UiForm::Checkbox(string $name, string $label, bool $value): void

Render a labelled checkbox, checked when the value is true, showing any validation error.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$valueboolWhether the box starts checked.

Returns void

Dropdown

UiForm::Dropdown(string $name, string $label, $value, array $options): void

Render a labelled select, with the current value selected, showing any validation error.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$valueThe currently selected option value.
$optionsarrayA map of option value to option label.

Returns void

EmptyForm

UiForm::EmptyForm(string $formId, callable $formContents): void

Render a form element with the given id and no action attribute.

NameTypeDescription
$formIdstringThe form id.
$formContentscallableA closure that emits the form fields.

Returns void

File

UiForm::File(string $label, string $name, string $accept = ""): void

Render a labelled file input, optionally restricted by an accept filter, showing any validation error.

NameTypeDescription
$labelstringThe field label.
$namestringThe field name.
$acceptstringAn optional accept filter for allowed file types.

Returns void

Form

UiForm::Form(string $actionUrl, callable $formContents, bool $enableFileupload = false): void

Render a form that posts to the given action url, optionally allowing file uploads.

NameTypeDescription
$actionUrlstringThe url the form posts to.
$formContentscallableA closure that emits the form fields.
$enableFileuploadboolTrue to allow file uploads.

Returns void

Hidden

UiForm::Hidden(string $name, mixed $value): void

Render a hidden input with a value of any type.

NameTypeDescription
$namestringThe field name.
$valuemixedThe hidden value.

Returns void

HiddenID

UiForm::HiddenID(string $name, int $value): void

Render a hidden input holding an integer id.

NameTypeDescription
$namestringThe field name.
$valueintThe id value.

Returns void

Image

UiForm::Image(string $label, string $name): void

Render a labelled file input that accepts images only, showing any validation error.

NameTypeDescription
$labelstringThe field label.
$namestringThe field name.

Returns void

Number

UiForm::Number(string $name, string $label, $value = "", $step = 1): void

Render a labelled number input with an optional step, showing any validation error and preserving a previous value.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$valueThe initial value.
$stepThe numeric step; omitted when 1.

Returns void

Password

UiForm::Password(string $name, string $label): void

Render a labelled password input with a show/hide toggle, showing any validation error.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.

Returns void

PasswordPlain

UiForm::PasswordPlain(string $name, string $label): void

Render a labelled password input without a show/hide toggle, showing any validation error.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.

Returns void

Range

UiForm::Range(string $name, string $label, int $min, int $max, int $value = 0): void

Render a labelled range slider between a minimum and maximum, showing any validation error.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$minintThe lowest allowed value.
$maxintThe highest allowed value.
$valueintThe initial value.

Returns void

ReadOnly

UiForm::ReadOnly(string $label, mixed $value): void

Render a labelled, disabled text input showing a fixed value.

NameTypeDescription
$labelstringThe field label.
$valuemixedThe value shown.

Returns void

Submit

UiForm::Submit($label): void

Render a submit button with the given label.

NameTypeDescription
$labelThe button label.

Returns void

Text

UiForm::Text(string $name, string $label, string|null $optionalValue = ''): void

Render a labelled text input, showing any validation error and preserving a previous value.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$optionalValuestring|nullThe initial value.

Returns void

TextArea

UiForm::TextArea(string $name, string $label, string|null $optionalValue = ''): void

Render a labelled multi-line text area, showing any validation error and preserving a previous value.

NameTypeDescription
$namestringThe field name.
$labelstringThe field label.
$optionalValuestring|nullThe initial value.

Returns void

UiHtml

The whole HTML document: capture the body content, then emit a page with the accumulated title, description, styles, scripts and meta tags, and a startup script that calls each script module's _start. Setters and public state accumulate what the page needs.

Capture

UiHtml::Capture(Callable $content): string

Run the closure with output buffering and return everything it echoed as a string.

NameTypeDescription
$contentCallableA closure whose output is captured.

Returns string The captured output.

Description

UiHtml::Description(string $description): void

Set the page description meta value.

NameTypeDescription
$descriptionstringThe description text.

Returns void

Meta

UiHtml::Meta(string $name, string $content): void

Add a named meta tag to render in the page head.

NameTypeDescription
$namestringThe meta tag name.
$contentstringThe meta tag content.

Returns void

Page

UiHtml::Page(Callable $content): void

Capture the content, then emit the full HTML document with head, accumulated title, description, meta tags, styles, scripts and a module startup script, and the captured body.

NameTypeDescription
$contentCallableA closure that emits the page body.

Returns void

Script

UiHtml::Script(string $script): void

Add a script source url to include in the page.

NameTypeDescription
$scriptstringThe script source url.

Returns void

Style

UiHtml::Style(string $style): void

Add a stylesheet url to include in the page.

NameTypeDescription
$stylestringThe stylesheet url.

Returns void

Title

UiHtml::Title(string $title): void

Set the page title.

NameTypeDescription
$titlestringThe page title.

Returns void

UiLayout

Layout wrappers: rows and columns, grids, overlays and stacks, fixed and flexible sizing. Size constants give common minimum widths for flexible boxes.

Constants

ConstantValueDescription
UiLayout::SIZE_100100A minimum width in pixels.
UiLayout::SIZE_200200A minimum width in pixels.
UiLayout::SIZE_300300A minimum width in pixels.
UiLayout::SIZE_400400A minimum width in pixels.
UiLayout::SIZE_500500A minimum width in pixels.
UiLayout::SIZE_600600A minimum width in pixels.
UiLayout::SIZE_700700A minimum width in pixels.
UiLayout::SIZE_800800A minimum width in pixels.
UiLayout::SIZE_900900A minimum width in pixels.
UiLayout::SIZE_10001000A minimum width in pixels.
UiLayout::SIZE_11001100A minimum width in pixels.
UiLayout::SIZE_12001200A minimum width in pixels.
UiLayout::SIZE_13001300A minimum width in pixels.
UiLayout::SIZE_14001400A minimum width in pixels.
UiLayout::SIZE_15001500A minimum width in pixels.
UiLayout::SIZE_16001600A minimum width in pixels.

Column

UiLayout::Column(callable $content)

Wrap content in a column.

NameTypeDescription
$contentcallableA closure that emits the column content.

Columns

UiLayout::Columns(callable $content)

Wrap content in a row so children are laid out as columns.

NameTypeDescription
$contentcallableA closure that emits the columns.

Flex

UiLayout::Flex(?int $minWidth, ?int $maxWidth, callable $content)

Wrap content in a flex box with optional minimum and maximum width classes.

NameTypeDescription
$minWidth?intA minimum width, or null for none.
$maxWidth?intA maximum width, or null for none.
$contentcallableA closure that emits the flex content.

Grid

UiLayout::Grid(int $columns, callable $content)

Wrap content in a grid with the given number of columns.

NameTypeDescription
$columnsintThe number of grid columns.
$contentcallableA closure that emits the grid content.

Height

UiLayout::Height(float $height, callable $content)

Wrap content in a div with a fixed pixel height.

NameTypeDescription
$heightfloatThe height in pixels.
$contentcallableA closure that emits the content.

Overlay

UiLayout::Overlay(callable $content)

Wrap content in an overlay.

NameTypeDescription
$contentcallableA closure that emits the overlay content.

Padding

UiLayout::Padding(callable $content)

Wrap content in a padding element.

NameTypeDescription
$contentcallableA closure that emits the padded content.

Row

UiLayout::Row(callable $content)

Wrap content in a row.

NameTypeDescription
$contentcallableA closure that emits the row content.

Rows

UiLayout::Rows(callable $content)

Wrap content in a column so children stack as rows.

NameTypeDescription
$contentcallableA closure that emits the rows.

Size

UiLayout::Size(float $width, float $height, callable $content)

Wrap content in a div with a fixed pixel width and height.

NameTypeDescription
$widthfloatThe width in pixels.
$heightfloatThe height in pixels.
$contentcallableA closure that emits the content.

Smaller

UiLayout::Smaller(callable $content)

Wrap content in a smaller element.

NameTypeDescription
$contentcallableA closure that emits the content.

Stack

UiLayout::Stack(callable $content)

Wrap content in a stack.

NameTypeDescription
$contentcallableA closure that emits the stacked content.

Stretch

UiLayout::Stretch(callable|null $content = null)

Wrap optional content in a stretch element.

NameTypeDescription
$contentcallable|nullAn optional closure emitting the content.

Width

UiLayout::Width(float $width, callable $content)

Wrap content in a div with a fixed pixel width.

NameTypeDescription
$widthfloatThe width in pixels.
$contentcallableA closure that emits the content.

UiNavigation

A navigation menu built from items: collect items in a menu, then render them as a list, marking any that are selected.

Functions

Item

UiNavigation::Item(string $label, bool $selected, string $url): void

Add an item to the menu currently being built.

NameTypeDescription
$labelstringThe item label.
$selectedboolWhether the item is selected.
$urlstringThe item url.

Returns void

Menu

UiNavigation::Menu(Callable $content): void

Collect the items added by the closure and render them as a menu list.

NameTypeDescription
$contentCallableA closure that adds items with Item.

Returns void

UiObject

Display an object as a two-column field and value table. Open a display, then add typed field rows for text, code, numbers, booleans, datetimes, JSON and nested objects. The optional variants show italic none when a value is null. Field methods must be called inside the display callback.

Display

UiObject::Display(string $fieldColumnTitle, string $valueColumnTitle, callable $contentCallback): void

Render an object as a table with a field column and a value column; the callback adds field rows.

NameTypeDescription
$fieldColumnTitlestringThe field column heading.
$valueColumnTitlestringThe value column heading.
$contentCallbackcallableA closure that adds field rows.

Returns void

FieldBoolean

UiObject::FieldBoolean(string $name, ?bool $value = null): void

Add a boolean field row, shown as Yes or No.

NameTypeDescription
$namestringThe field name.
$value?boolThe boolean value.

Returns void

FieldCode

UiObject::FieldCode(string $name, ?string $value = null): void

Add a code field row.

NameTypeDescription
$namestringThe field name.
$value?stringThe code value.

Returns void

FieldCodeOptional

UiObject::FieldCodeOptional(string $name, ?string $value = null): void

Add a code field row, showing italic none when the value is null.

NameTypeDescription
$namestringThe field name.
$value?stringThe code value, or null.

Returns void

FieldDateTime

UiObject::FieldDateTime(string $name, ?CalendarDateTimeData $value = null): void

Add a datetime field row, formatted as human-readable text.

NameTypeDescription
$namestringThe field name.
$value?CalendarDateTimeDataThe datetime value.

Returns void

FieldDateTimeOptional

UiObject::FieldDateTimeOptional(string $name, ?int $value = null): void

Add a datetime field row from a Unix timestamp, showing italic none when null.

NameTypeDescription
$namestringThe field name.
$value?intThe Unix timestamp, or null.

Returns void

FieldJson

UiObject::FieldJson(string $name, mixed $value): void

Add a JSON field row, encoding the value to JSON when it is not already a string.

NameTypeDescription
$namestringThe field name.
$valuemixedThe value to display as JSON.

Returns void

FieldJsonOptional

UiObject::FieldJsonOptional(string $name, mixed $value = null): void

Add a JSON field row, showing italic none when the value is null.

NameTypeDescription
$namestringThe field name.
$valuemixedThe value to display as JSON, or null.

Returns void

FieldNumber

UiObject::FieldNumber(string $name, int|float|null $value = null): void

Add a number field row; integers are formatted with grouping.

NameTypeDescription
$namestringThe field name.
$valueint|float|nullThe number value.

Returns void

FieldNumberOptional

UiObject::FieldNumberOptional(string $name, int|float|null $value = null): void

Add a number field row, showing italic none when the value is null.

NameTypeDescription
$namestringThe field name.
$valueint|float|nullThe number value, or null.

Returns void

FieldText

UiObject::FieldText(string $name, ?string $value = null): void

Add a text field row.

NameTypeDescription
$namestringThe field name.
$value?stringThe text value.

Returns void

FieldTextOptional

UiObject::FieldTextOptional(string $name, ?string $value = null): void

Add a text field row, showing italic none when the value is null.

NameTypeDescription
$namestringThe field name.
$value?stringThe text value, or null.

Returns void

ObjectField

UiObject::ObjectField(string $name, string $fieldColumnTitle, string $valueColumnTitle, callable $objectFieldsClosure): void

Add a row whose value column holds a nested field and value table.

NameTypeDescription
$namestringThe field name.
$fieldColumnTitlestringThe nested field column heading.
$valueColumnTitlestringThe nested value column heading.
$objectFieldsClosurecallableA closure that adds the nested field rows.

Returns void

UiPage

A minimal HTML page shell that loads React, ReactDOM and Babel and renders the content into a root body.

Functions

Html

UiPage::Html(string $title, string $description, Callable $content): void

Emit an HTML document with the given title and description, React scripts, and the content rendered into the root body.

NameTypeDescription
$titlestringThe page title.
$descriptionstringThe page description.
$contentCallableA closure that emits the body content.

Returns void

UiPaging

Pagination: route to a page number, render a numbered paging bar, render id-based menu items, and produce or render previous and next navigation for id-based views.

Aside

UiPaging::Aside(int $currentId, int $maxId, string $baseUrl, ?string $optionalAsideTitle = null): void

Render an aside with Previous and Next buttons for id-based pagination; unavailable buttons are shown disabled. Previous is the higher id, Next the lower.

NameTypeDescription
$currentIdintThe id currently being viewed.
$maxIdintThe highest id value.
$baseUrlstringThe base url for the links.
$optionalAsideTitle?stringAn optional title for the aside.

Returns void

Bar

UiPaging::Bar(int $currentPage, int $totalItems, int $itemsPerPage, string $baseUrl): void

Render a numbered paging bar with Prev and Next links, windowed around the current page. Nothing is rendered when there is a single page.

NameTypeDescription
$currentPageintThe current page number.
$totalItemsintThe total number of items.
$itemsPerPageintThe number of items per page.
$baseUrlstringThe base url for the page links.

Returns void

BarInMenu

UiPaging::BarInMenu(int $currentId, int $maxId, string $baseUrl): void

Render a paging bar as menu list items, showing ids with a # prefix counting down from the highest id.

NameTypeDescription
$currentIdintThe id currently being viewed.
$maxIdintThe highest id value.
$baseUrlstringThe base url for the links.

Returns void

GetPrevNextUrls

UiPaging::GetPrevNextUrls(int $currentId, int $maxId, string $baseUrl): object

Return an object with prevUrl, nextUrl, showPrev and showNext for id-based navigation. Previous is the higher id, Next the lower.

NameTypeDescription
$currentIdintThe id currently being viewed.
$maxIdintThe highest id value.
$baseUrlstringThe base url for the links.

Returns object An object with prevUrl, nextUrl, showPrev and showNext.

Route

UiPaging::Route(callable $routeCallback, ...$args): void

Route an optional trailing page number to the callback, defaulting to page 1, passing on any extra arguments.

NameTypeDescription
$routeCallbackcallableThe callback run with the page number.
...$argsExtra arguments passed to the callback.

Returns void

UiStatus

Render a success or error status message read from the request's status_type and status_message query parameters.

Functions

StatusMessage

UiStatus::StatusMessage()

Read status_type and status_message from the query string and render a success or error message box accordingly.

UiTable

Tables and their contents: a header with columns, rows, a helper to iterate items into rows, a raw cell, and typed cells for text, code, buttons, booleans, integers, numbers and text sizes. An empty table shows a none row.

Cell

UiTable::Cell(callable $cellContent): void

Render a table cell whose content is emitted by the closure.

NameTypeDescription
$cellContentcallableA closure that emits the cell content.

Returns void

CellBoolean

UiTable::CellBoolean(bool|null $optionalBoolean): void

Render a cell showing Yes or No; null is treated as No.

NameTypeDescription
$optionalBooleanbool|nullThe boolean value, or null.

Returns void

CellButton

UiTable::CellButton(string $url, string $text): void

Render a cell containing a button link.

NameTypeDescription
$urlstringThe button url.
$textstringThe button label.

Returns void

CellCode

UiTable::CellCode(string|null $optionalText): void

Render a cell containing code text; null becomes empty.

NameTypeDescription
$optionalTextstring|nullThe code text, or null.

Returns void

CellInteger

UiTable::CellInteger(int|null $optionalInteger): void

Render a cell showing an integer with grouping; null becomes zero.

NameTypeDescription
$optionalIntegerint|nullThe integer value, or null.

Returns void

CellNumber

UiTable::CellNumber(float|null $optionalNumber, int $decimalPlaces = 2): void

Render a cell showing a number to a number of decimal places; null becomes empty.

NameTypeDescription
$optionalNumberfloat|nullThe number value, or null.
$decimalPlacesintThe number of decimal places.

Returns void

CellText

UiTable::CellText(string|null $optionalText, ?int $truncateLength = null): void

Render a cell showing text; null becomes empty and text is optionally truncated with an ellipsis.

NameTypeDescription
$optionalTextstring|nullThe text value, or null.
$truncateLength?intA maximum length to truncate to, or null.

Returns void

CellTextSize

UiTable::CellTextSize(string $text): void

Render a cell showing the byte length of the text.

NameTypeDescription
$textstringThe text to measure.

Returns void

CellTextSizeOptional

UiTable::CellTextSizeOptional(string|null $optionalText): void

Render a cell showing the byte length of the text, or italic none when null.

NameTypeDescription
$optionalTextstring|nullThe text to measure, or null.

Returns void

Header

UiTable::Header(array $columns, callable $tableContents): void

Render a table with the given column headings; the callback adds rows, and an empty table shows a none row.

NameTypeDescription
$columnsarrayThe column headings.
$tableContentscallableA closure that adds the rows.

Returns void

Row

UiTable::Row(callable $rowContents): void

Render a table row whose cells are emitted by the closure.

NameTypeDescription
$rowContentscallableA closure that emits the cells.

Returns void

Rows

UiTable::Rows(array $items, callable $callback): void

Call the callback once per item, typically to render a row for each.

NameTypeDescription
$itemsarrayThe items to iterate.
$callbackcallableA closure called with each item.

Returns void

UiTabs

Tab sets: a horizontal or vertical group of tabs, each with a label, an optional url and content. The tab matching the current request path is marked selected.

Functions

Horizontal

UiTabs::Horizontal(Callable $content)

Render a horizontal tab set; the content closure declares the tabs and is run once for buttons and once for panes.

NameTypeDescription
$contentCallableA closure that declares the tabs.

Tab

UiTabs::Tab(string|null $label, string|null $url, Callable $content)

Declare a tab; in the button pass it renders a button or link, in the pane pass it renders the content. Selected when its url matches the current path.

NameTypeDescription
$labelstring|nullThe tab label.
$urlstring|nullAn optional url; null renders a non-clickable button.
$contentCallableA closure that emits the tab's pane content.

Vertical

UiTabs::Vertical(Callable $content)

Render a vertical tab set; the content closure declares the tabs and is run once for buttons and once for panes.

NameTypeDescription
$contentCallableA closure that declares the tabs.

UiThemeBackgroundStyleData

Immutable background style: a gradient, corner radius, border colour and width, and padding. Fields and constructor only.

Properties

PropertyTypeDescription
$style->gradientUiThemeGradientDataThe background gradient (readonly).
$style->radiusintThe corner radius in pixels (readonly).
$style->borderColorstringThe border colour (readonly).
$style->borderWidthintThe border width in pixels (readonly).
$style->paddingintThe padding in pixels (readonly).
Functions

__construct

new UiThemeBackgroundStyleData(readonly UiThemeGradientData $gradient = new UiThemeGradientData(), readonly int $radius = 8, readonly string $borderColor = '#990099', readonly int $borderWidth = 1, readonly int $padding = 16)

Construct a background style from a gradient, radius, border colour, border width and padding.

NameTypeDescription
$gradientUiThemeGradientDataThe background gradient.
$radiusintThe corner radius in pixels.
$borderColorstringThe border colour.
$borderWidthintThe border width in pixels.
$paddingintThe padding in pixels.

UiThemeButtonData

Immutable button styling: a text style and a background style. Fields and constructor only.

Properties

PropertyTypeDescription
$button->textStyleUiThemeTextStyleDataThe button text style.
$button->backgroundStyleUiThemeBackgroundStyleDataThe button background style.
Functions

__construct

new UiThemeButtonData(UiThemeTextStyleData $textStyle, UiThemeBackgroundStyleData $backgroundStyle)

Construct a button style from a text style and a background style.

NameTypeDescription
$textStyleUiThemeTextStyleDataThe button text style.
$backgroundStyleUiThemeBackgroundStyleDataThe button background style.

UiThemeContextData

Immutable resolved theme context for the current UI: styles for titles and text, resolved button, panel, section, error and input variants, a background style, spacing and padding, and the current theme name. Fields and constructor only.

Properties

PropertyTypeDescription
$context->titleStyleUiThemeTextStyleDataThe title text style (readonly).
$context->textStyleUiThemeTextStyleDataThe body text style (readonly).
$context->buttonPrimaryThemeUiThemeVariantDataThe primary button variant (readonly).
$context->buttonSecondaryThemeUiThemeVariantDataThe secondary button variant (readonly).
$context->panelThemeUiThemeVariantDataThe panel variant (readonly).
$context->sectionThemeUiThemeVariantDataThe section variant (readonly).
$context->errorTheme?UiThemeVariantDataThe optional error variant (readonly).
$context->inputTheme?UiThemeVariantDataThe optional input variant (readonly).
$context->backgroundStyleUiThemeBackgroundStyleDataThe background style (readonly).
$context->spacingfloatThe spacing between elements (readonly).
$context->paddingfloatThe padding (readonly).
$context->currentThemeNamestringThe current theme name (readonly).
Functions

__construct

new UiThemeContextData(readonly UiThemeTextStyleData $titleStyle, readonly UiThemeTextStyleData $textStyle, readonly UiThemeVariantData $buttonPrimaryTheme, readonly UiThemeVariantData $buttonSecondaryTheme, readonly UiThemeVariantData $panelTheme, readonly UiThemeVariantData $sectionTheme, readonly ?UiThemeVariantData $errorTheme, readonly ?UiThemeVariantData $inputTheme, readonly UiThemeBackgroundStyleData $backgroundStyle, readonly float $spacing, readonly float $padding, readonly string $currentThemeName)

Construct a resolved theme context from title and text styles, button, panel, section, error and input variants, a background style, spacing, padding and the theme name.

UiThemeData

A named theme container: a name, a map of named variants, a default variant name, and optional nested-title fonts and gradients. The constructor throws when the default variant is not present. Provides readers for the default variant and a variant by name.

Properties

PropertyTypeDescription
$theme->namestringThe theme name (readonly).
$theme->variantsarrayA map of variant name to variant data (readonly).
$theme->defaultVariantNamestringThe default variant name (readonly).
$theme->optionalContentTitleNestedFont?stringThe font for nested titles when set (readonly).
$theme->optionalContentTitleNestedPanelGradient?UiThemeGradientDataThe nested-title gradient with a panel ancestor (readonly).
$theme->optionalContentTitleNestedMainGradient?UiThemeGradientDataThe nested-title gradient for section-only nesting (readonly).

__construct

new UiThemeData(readonly string $name, readonly array $variants, readonly string $defaultVariantName, readonly ?string $optionalContentTitleNestedFont = null, readonly ?UiThemeGradientData $optionalContentTitleNestedPanelGradient = null, readonly ?UiThemeGradientData $optionalContentTitleNestedMainGradient = null)

Construct a theme container from a name, a variants map, a default variant name and optional nested-title styling. Throws when the default variant is not in the map.

getDefaultVariant

$theme->getDefaultVariant(): UiThemeVariantData

Return the default variant.

Returns UiThemeVariantData The default variant.

getVariant

$theme->getVariant(string $variantName): ?UiThemeVariantData

Return the variant with the given name, or null when absent.

NameTypeDescription
$variantNamestringThe variant name to look up.

Returns ?UiThemeVariantData The variant, or null.

UiThemeGradientData

Immutable gradient of one or two colours. Fields and constructor only.

Properties

PropertyTypeDescription
$gradient->colour1stringThe first colour (readonly).
$gradient->colour2string|nullThe optional second colour (readonly).
Functions

__construct

new UiThemeGradientData(readonly string $colour1 = '#FF00FF', readonly string|null $colour2 = null)

Construct a gradient from a first colour and an optional second colour.

NameTypeDescription
$colour1stringThe first colour.
$colour2string|nullThe optional second colour.

UiThemeInputStyleData

Immutable input styling: label, field, error and field-error text styles, field and field-error background styles, and spacing. Fields and constructor only.

Properties

PropertyTypeDescription
$input->labelTextStyleUiThemeTextStyleDataThe label text style (readonly).
$input->fieldTextStyleUiThemeTextStyleDataThe field text style (readonly).
$input->fieldBackgroundStyleUiThemeBackgroundStyleDataThe field background style (readonly).
$input->fieldErrorTextStyleUiThemeTextStyleDataThe field error text style (readonly).
$input->fieldErrorBackgroundStyleUiThemeBackgroundStyleDataThe field error background style (readonly).
$input->errorTextStyleUiThemeTextStyleDataThe error message text style (readonly).
$input->spacingfloatThe spacing between input parts (readonly).
Functions

__construct

new UiThemeInputStyleData(readonly UiThemeTextStyleData $labelTextStyle = new UiThemeTextStyleData(), readonly UiThemeTextStyleData $fieldTextStyle = new UiThemeTextStyleData(), readonly UiThemeBackgroundStyleData $fieldBackgroundStyle = new UiThemeBackgroundStyleData(), readonly UiThemeTextStyleData $fieldErrorTextStyle = new UiThemeTextStyleData(), readonly UiThemeBackgroundStyleData $fieldErrorBackgroundStyle = new UiThemeBackgroundStyleData(), readonly UiThemeTextStyleData $errorTextStyle = new UiThemeTextStyleData(), readonly float $spacing = 8.0)

Construct input styling from label, field, error and field-error text styles, field and field-error background styles, and spacing.

UiThemeService

The theme service: read the current theme context, build default themes and variants, validate and resolve variant references, merge a variant into a context, and produce CSS strings and a full stylesheet.

BackgroundStyleString

UiThemeService::BackgroundStyleString(?UiThemeBackgroundStyleData $backgroundStyle = null): string

Return a CSS declaration string for a background style, using the current theme's background when none is given.

NameTypeDescription
$backgroundStyle?UiThemeBackgroundStyleDataThe background style, or null for the current one.

Returns string A CSS declaration string.

Current

UiThemeService::Current(): UiThemeContextData

Return the current theme context from context.

Returns UiThemeContextData The current theme context.

DefaultContextTheme

UiThemeService::DefaultContextTheme(): UiThemeContextData

Return the hardcoded default theme context.

Returns UiThemeContextData The default theme context.

DefaultTheme

UiThemeService::DefaultTheme(): UiThemeData

Return the default theme container, with its name, variants and default variant name.

Returns UiThemeData The default theme container.

DefaultThemes

UiThemeService::DefaultThemes(): array

Return the default variants map. A legacy alias of DefaultVariants.

Returns array A map of variant name to variant data.

DefaultVariants

UiThemeService::DefaultVariants(): array

Return the default theme variants map.

Returns array A map of variant name to variant data.

GenerateStylesheet

UiThemeService::GenerateStylesheet(): string

Generate a complete CSS stylesheet from the current theme context, targeting generic HTML tags.

Returns string The generated stylesheet.

MergeTheme

UiThemeService::MergeTheme(UiThemeContextData $existingContext, UiThemeVariantData $theme, array $themeRegistry, string $currentThemeName): UiThemeContextData

Merge a variant into an existing context, resolving its nested variant names from the registry and falling back for optional error and input variants.

NameTypeDescription
$existingContextUiThemeContextDataThe context to merge into.
$themeUiThemeVariantDataThe variant to apply.
$themeRegistryarrayThe registry of variants to resolve names against.
$currentThemeNamestringThe name to record as the current theme.

Returns UiThemeContextData The merged theme context.

ResolveThemeByName

UiThemeService::ResolveThemeByName(string $themeName, array $themeRegistry): UiThemeVariantData

Return the variant with the given name from the registry, throwing when it is absent.

NameTypeDescription
$themeNamestringThe variant name to resolve.
$themeRegistryarrayThe registry of variants.

Returns UiThemeVariantData The resolved variant.

TextStyleString

UiThemeService::TextStyleString(?UiThemeTextStyleData $textStyle = null): string

Return a CSS declaration string for a text style, using the current theme's text style when none is given.

NameTypeDescription
$textStyle?UiThemeTextStyleDataThe text style, or null for the current one.

Returns string A CSS declaration string.

ValidateThemes

UiThemeService::ValidateThemes(array $themes): void

Validate that every variant referenced by the given variants exists, throwing when a reference is missing.

NameTypeDescription
$themesarrayThe map of variants to validate.

Returns void

UiThemeStyleData

Immutable paired styling: a text style and a background style. Fields and constructor only.

Properties

PropertyTypeDescription
$style->textStyleUiThemeTextStyleDataThe text style.
$style->backgroundStyleUiThemeBackgroundStyleDataThe background style.
Functions

__construct

new UiThemeStyleData(UiThemeTextStyleData $textStyle, UiThemeBackgroundStyleData $backgroundStyle)

Construct a paired style from a text style and a background style.

NameTypeDescription
$textStyleUiThemeTextStyleDataThe text style.
$backgroundStyleUiThemeBackgroundStyleDataThe background style.

UiThemeTextStyleData

Immutable text style: a colour gradient, font, size, all-caps, underline, bold, italic and alignment. Fields and constructor only, with alignment constants.

Constants

ConstantValueDescription
UiThemeTextStyleData::LEFT'left'Left alignment.
UiThemeTextStyleData::CENTER'center'Centre alignment.
UiThemeTextStyleData::RIGHT'right'Right alignment.

Properties

PropertyTypeDescription
$text->gradientUiThemeGradientDataThe text colour gradient (readonly).
$text->fontstringThe font family (readonly).
$text->sizefloatThe font size (readonly).
$text->allCapsboolWhether the text is uppercased (readonly).
$text->underlineboolWhether the text is underlined (readonly).
$text->boldboolWhether the text is bold (readonly).
$text->italicboolWhether the text is italic (readonly).
$text->alignmentstringThe alignment, one of the constants (readonly).
Functions

__construct

new UiThemeTextStyleData(readonly UiThemeGradientData $gradient = new UiThemeGradientData(), readonly string $font = 'Arial', readonly float $size = 16.0, readonly bool $allCaps = false, readonly bool $underline = false, readonly bool $bold = false, readonly bool $italic = false, readonly string $alignment = self::LEFT)

Construct a text style from a gradient, font, size, all-caps, underline, bold, italic and alignment.

UiThemeVariantData

Immutable styling for one theme variant: title and text styles, the names of the button, panel and section variants, optional error and input variant names, a background style, spacing and padding. Fields and constructor only.

Properties

PropertyTypeDescription
$variant->titleStyleUiThemeTextStyleDataThe title text style (readonly).
$variant->textStyleUiThemeTextStyleDataThe body text style (readonly).
$variant->buttonPrimaryVariantNamestringThe primary button variant name (readonly).
$variant->buttonSecondaryVariantNamestringThe secondary button variant name (readonly).
$variant->panelVariantNamestringThe panel variant name (readonly).
$variant->sectionVariantNamestringThe section variant name (readonly).
$variant->optionalErrorVariantName?stringThe optional error variant name (readonly).
$variant->optionalInputVariantName?stringThe optional input variant name (readonly).
$variant->backgroundStyleUiThemeBackgroundStyleDataThe background style (readonly).
$variant->spacingfloatThe spacing between elements (readonly).
$variant->paddingfloatThe padding (readonly).
Functions

__construct

new UiThemeVariantData(readonly UiThemeTextStyleData $titleStyle, readonly UiThemeTextStyleData $textStyle, readonly string $buttonPrimaryVariantName, readonly string $buttonSecondaryVariantName, readonly string $panelVariantName, readonly string $sectionVariantName, readonly ?string $optionalErrorVariantName = null, readonly ?string $optionalInputVariantName = null, readonly UiThemeBackgroundStyleData $backgroundStyle = new UiThemeBackgroundStyleData(), readonly float $spacing = 10.0, readonly float $padding = 10.0)

Construct a theme variant from title and text styles, the button, panel and section variant names, optional error and input variant names, a background style, spacing and padding.