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.
Ui- override or redirect the buffered response and exit.UiCard- cards and card lists.UiCode- preformatted code blocks.UiContent- page content: titles, text, sections, links, menus and buttons.UiForm- forms and form fields.UiHtml- the full HTML document, with title, description, styles, scripts and meta tags.UiLayout- rows, columns, grids and sizing wrappers.UiNavigation- a navigation menu of items.UiObject- display an object as a field and value table.UiPage- a React-hosting HTML page shell.UiPaging- pagination routing, bars and prev/next navigation.UiStatus- render a success or error status message from the query string.UiTable- tables, rows and typed cells.UiTabs- horizontal and vertical tab sets.UiThemeBackgroundStyleData- background style: gradient, radius, border and padding.UiThemeButtonData- a button's text and background styles.UiThemeContextData- the resolved theme context for the current UI.UiThemeData- a named theme container of variants.UiThemeGradientData- one or two colours forming a gradient.UiThemeInputStyleData- styles for input labels, fields and errors.UiThemeService- build, resolve and apply themes, and generate CSS.UiThemeStyleData- a paired text and background style.UiThemeTextStyleData- text style: gradient, font, size, weight and alignment.UiThemeVariantData- styling for one theme variant.
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.
| Name | Type | Description |
|---|---|---|
$content | string | The content to send to the browser. |
$contentType | ?string | An optional content type header. |
$httpStatusCode | ?int | An 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.
| Name | Type | Description |
|---|---|---|
$url | string | The 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.
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.
| Name | Type | Description |
|---|---|---|
$title | string | The card heading. |
$info | string | An info paragraph; omitted when empty. |
$link | string | The url the card links to. |
$optionalImageUrl | string | An 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.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the cards. |
Returns void
RawCard
UiCard::RawCard(Callable $content): void
Render a card wrapping arbitrary content emitted by the closure.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure that emits the card body. |
Returns void
UiCode
A preformatted code block that emits its content unescaped.
Pre
UiCode::Pre(string $content)
Emit the content inside a pre element, without escaping.
| Name | Type | Description |
|---|---|---|
$content | string | The 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.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the area content. |
Returns void
Aside
UiContent::Aside(Callable $content): void
Wrap content in an aside element.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure that emits the aside content. |
Returns void
Button
UiContent::Button(string $u_url, string $text): void
Render a link styled as a button.
| Name | Type | Description |
|---|---|---|
$u_url | string | The url the button links to. |
$text | string | The button label. |
Returns void
ButtonLink
UiContent::ButtonLink(string $u_url, callable $content): void
Render a button-styled link whose contents are emitted by the closure.
| Name | Type | Description |
|---|---|---|
$u_url | string | The url the button links to. |
$content | callable | A closure that emits the button contents. |
Returns void
Buttons
UiContent::Buttons(Callable $buttonsUi): void
Wrap a group of buttons in a buttons container.
| Name | Type | Description |
|---|---|---|
$buttonsUi | Callable | A closure that emits the buttons. |
Returns void
Code
UiContent::Code(string $text): void
Render escaped text inside a pre element.
| Name | Type | Description |
|---|---|---|
$text | string | The 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.
| Name | Type | Description |
|---|---|---|
$initiallyCollapsed | bool | True to start closed, false to start open. |
$title | string | The summary title. |
$content | callable | A 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.
| Name | Type | Description |
|---|---|---|
$divId | string | The div id. |
$content | callable|null | An optional closure emitting the div content. |
Returns void
Footer
UiContent::Footer(Callable $content): void
Wrap content in a footer element.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure that emits the footer content. |
Returns void
Header
UiContent::Header(Callable $content): void
Wrap content in a header element.
| Name | Type | Description |
|---|---|---|
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$icon | string | The icon name. |
Returns void
Image
UiContent::Image(string $url, int $width, int $height): void
Render an image with an explicit width and height.
| Name | Type | Description |
|---|---|---|
$url | string | The image url. |
$width | int | The image width in pixels. |
$height | int | The image height in pixels. |
Returns void
Link
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.
| Name | Type | Description |
|---|---|---|
$text | string | The link text. |
$url | string | The link url. |
$selected | bool | Whether the menu item is selected. |
Returns void
List
UiContent::List(callable $content): void
Wrap content in an unordered list.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the list points. |
Returns void
Main
UiContent::Main(callable $content): void
Wrap content in a main element without changing section depth.
| Name | Type | Description |
|---|---|---|
$content | callable | A 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.
| Name | Type | Description |
|---|---|---|
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the panel content. |
Returns void
Point
UiContent::Point(string $text): void
Render a list item with escaped text.
| Name | Type | Description |
|---|---|---|
$text | string | The list item text. |
Returns void
Script
UiContent::Script(Callable $content): void
Wrap content in a script element.
| Name | Type | Description |
|---|---|---|
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the section content. |
$id | string|null | An 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.
| Name | Type | Description |
|---|---|---|
$text | string | The first text fragment. |
$optionalText2 | ?string | An additional fragment appended in order. |
$optionalText3 | ?string | An additional fragment appended in order. |
$optionalText4 | ?string | An additional fragment appended in order. |
$optionalText5 | ?string | An additional fragment appended in order. |
$optionalText6 | ?string | An additional fragment appended in order. |
$optionalText7 | ?string | An additional fragment appended in order. |
$optionalText8 | ?string | An 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.
| Name | Type | Description |
|---|---|---|
$prompts | array | The 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.
| Name | Type | Description |
|---|---|---|
$text | string | The first text fragment. |
$optionalText2 | ?string | An additional fragment appended in order. |
$optionalText3 | ?string | An additional fragment appended in order. |
$optionalText4 | ?string | An additional fragment appended in order. |
$optionalText5 | ?string | An additional fragment appended in order. |
$optionalText6 | ?string | An additional fragment appended in order. |
$optionalText7 | ?string | An additional fragment appended in order. |
$optionalText8 | ?string | An 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.
| Name | Type | Description |
|---|---|---|
$formName | string | A unique form name, also the action value. |
$formContents | callable | A closure that emits the form fields. |
$formAction | callable | A closure run when the form is submitted. |
$enableFileupload | bool | True 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.
| Name | Type | Description |
|---|---|---|
$label | string | The button label. |
$action | callable | The action run on submission. |
$optionalFormName | ?string | An 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$value | bool | Whether 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$value | | The currently selected option value. |
$options | array | A 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.
| Name | Type | Description |
|---|---|---|
$formId | string | The form id. |
$formContents | callable | A 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.
| Name | Type | Description |
|---|---|---|
$label | string | The field label. |
$name | string | The field name. |
$accept | string | An 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.
| Name | Type | Description |
|---|---|---|
$actionUrl | string | The url the form posts to. |
$formContents | callable | A closure that emits the form fields. |
$enableFileupload | bool | True to allow file uploads. |
Returns void
Hidden
UiForm::Hidden(string $name, mixed $value): void
Render a hidden input with a value of any type.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | mixed | The hidden value. |
Returns void
HiddenID
UiForm::HiddenID(string $name, int $value): void
Render a hidden input holding an integer id.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | int | The 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.
| Name | Type | Description |
|---|---|---|
$label | string | The field label. |
$name | string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$value | | The initial value. |
$step | | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$min | int | The lowest allowed value. |
$max | int | The highest allowed value. |
$value | int | The initial value. |
Returns void
ReadOnly
UiForm::ReadOnly(string $label, mixed $value): void
Render a labelled, disabled text input showing a fixed value.
| Name | Type | Description |
|---|---|---|
$label | string | The field label. |
$value | mixed | The value shown. |
Returns void
Submit
UiForm::Submit($label): void
Render a submit button with the given label.
| Name | Type | Description |
|---|---|---|
$label | | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$optionalValue | string|null | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$label | string | The field label. |
$optionalValue | string|null | The 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.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure whose output is captured. |
Returns string The captured output.
Description
UiHtml::Description(string $description): void
Set the page description meta value.
| Name | Type | Description |
|---|---|---|
$description | string | The description text. |
Returns void
Meta
UiHtml::Meta(string $name, string $content): void
Add a named meta tag to render in the page head.
| Name | Type | Description |
|---|---|---|
$name | string | The meta tag name. |
$content | string | The 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.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure that emits the page body. |
Returns void
Script
UiHtml::Script(string $script): void
Add a script source url to include in the page.
| Name | Type | Description |
|---|---|---|
$script | string | The script source url. |
Returns void
Style
UiHtml::Style(string $style): void
Add a stylesheet url to include in the page.
| Name | Type | Description |
|---|---|---|
$style | string | The stylesheet url. |
Returns void
Title
UiHtml::Title(string $title): void
Set the page title.
| Name | Type | Description |
|---|---|---|
$title | string | The 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
| Constant | Value | Description |
|---|---|---|
UiLayout::SIZE_100 | 100 | A minimum width in pixels. |
UiLayout::SIZE_200 | 200 | A minimum width in pixels. |
UiLayout::SIZE_300 | 300 | A minimum width in pixels. |
UiLayout::SIZE_400 | 400 | A minimum width in pixels. |
UiLayout::SIZE_500 | 500 | A minimum width in pixels. |
UiLayout::SIZE_600 | 600 | A minimum width in pixels. |
UiLayout::SIZE_700 | 700 | A minimum width in pixels. |
UiLayout::SIZE_800 | 800 | A minimum width in pixels. |
UiLayout::SIZE_900 | 900 | A minimum width in pixels. |
UiLayout::SIZE_1000 | 1000 | A minimum width in pixels. |
UiLayout::SIZE_1100 | 1100 | A minimum width in pixels. |
UiLayout::SIZE_1200 | 1200 | A minimum width in pixels. |
UiLayout::SIZE_1300 | 1300 | A minimum width in pixels. |
UiLayout::SIZE_1400 | 1400 | A minimum width in pixels. |
UiLayout::SIZE_1500 | 1500 | A minimum width in pixels. |
UiLayout::SIZE_1600 | 1600 | A minimum width in pixels. |
Column
UiLayout::Column(callable $content)
Wrap content in a column.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the column content. |
Columns
UiLayout::Columns(callable $content)
Wrap content in a row so children are laid out as columns.
| Name | Type | Description |
|---|---|---|
$content | callable | A 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.
| Name | Type | Description |
|---|---|---|
$minWidth | ?int | A minimum width, or null for none. |
$maxWidth | ?int | A maximum width, or null for none. |
$content | callable | A closure that emits the flex content. |
Grid
UiLayout::Grid(int $columns, callable $content)
Wrap content in a grid with the given number of columns.
| Name | Type | Description |
|---|---|---|
$columns | int | The number of grid columns. |
$content | callable | A closure that emits the grid content. |
Height
UiLayout::Height(float $height, callable $content)
Wrap content in a div with a fixed pixel height.
| Name | Type | Description |
|---|---|---|
$height | float | The height in pixels. |
$content | callable | A closure that emits the content. |
Overlay
UiLayout::Overlay(callable $content)
Wrap content in an overlay.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the overlay content. |
Padding
UiLayout::Padding(callable $content)
Wrap content in a padding element.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the padded content. |
Row
UiLayout::Row(callable $content)
Wrap content in a row.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the row content. |
Rows
UiLayout::Rows(callable $content)
Wrap content in a column so children stack as rows.
| Name | Type | Description |
|---|---|---|
$content | callable | A 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.
| Name | Type | Description |
|---|---|---|
$width | float | The width in pixels. |
$height | float | The height in pixels. |
$content | callable | A closure that emits the content. |
Smaller
UiLayout::Smaller(callable $content)
Wrap content in a smaller element.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the content. |
Stack
UiLayout::Stack(callable $content)
Wrap content in a stack.
| Name | Type | Description |
|---|---|---|
$content | callable | A closure that emits the stacked content. |
Stretch
UiLayout::Stretch(callable|null $content = null)
Wrap optional content in a stretch element.
| Name | Type | Description |
|---|---|---|
$content | callable|null | An optional closure emitting the content. |
Width
UiLayout::Width(float $width, callable $content)
Wrap content in a div with a fixed pixel width.
| Name | Type | Description |
|---|---|---|
$width | float | The width in pixels. |
$content | callable | A 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.
Item
UiNavigation::Item(string $label, bool $selected, string $url): void
Add an item to the menu currently being built.
| Name | Type | Description |
|---|---|---|
$label | string | The item label. |
$selected | bool | Whether the item is selected. |
$url | string | The item url. |
Returns void
Menu
UiNavigation::Menu(Callable $content): void
Collect the items added by the closure and render them as a menu list.
| Name | Type | Description |
|---|---|---|
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$fieldColumnTitle | string | The field column heading. |
$valueColumnTitle | string | The value column heading. |
$contentCallback | callable | A 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?bool | The boolean value. |
Returns void
FieldCode
UiObject::FieldCode(string $name, ?string $value = null): void
Add a code field row.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?CalendarDateTimeData | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?int | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | mixed | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | mixed | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | int|float|null | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | int|float|null | The number value, or null. |
Returns void
FieldText
UiObject::FieldText(string $name, ?string $value = null): void
Add a text field row.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$value | ?string | The 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.
| Name | Type | Description |
|---|---|---|
$name | string | The field name. |
$fieldColumnTitle | string | The nested field column heading. |
$valueColumnTitle | string | The nested value column heading. |
$objectFieldsClosure | callable | A 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.
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.
| Name | Type | Description |
|---|---|---|
$title | string | The page title. |
$description | string | The page description. |
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$currentId | int | The id currently being viewed. |
$maxId | int | The highest id value. |
$baseUrl | string | The base url for the links. |
$optionalAsideTitle | ?string | An 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.
| Name | Type | Description |
|---|---|---|
$currentPage | int | The current page number. |
$totalItems | int | The total number of items. |
$itemsPerPage | int | The number of items per page. |
$baseUrl | string | The 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.
| Name | Type | Description |
|---|---|---|
$currentId | int | The id currently being viewed. |
$maxId | int | The highest id value. |
$baseUrl | string | The 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.
| Name | Type | Description |
|---|---|---|
$currentId | int | The id currently being viewed. |
$maxId | int | The highest id value. |
$baseUrl | string | The 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.
| Name | Type | Description |
|---|---|---|
$routeCallback | callable | The callback run with the page number. |
...$args | | Extra 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.
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.
| Name | Type | Description |
|---|---|---|
$cellContent | callable | A 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.
| Name | Type | Description |
|---|---|---|
$optionalBoolean | bool|null | The boolean value, or null. |
Returns void
CellButton
UiTable::CellButton(string $url, string $text): void
Render a cell containing a button link.
| Name | Type | Description |
|---|---|---|
$url | string | The button url. |
$text | string | The button label. |
Returns void
CellCode
UiTable::CellCode(string|null $optionalText): void
Render a cell containing code text; null becomes empty.
| Name | Type | Description |
|---|---|---|
$optionalText | string|null | The code text, or null. |
Returns void
CellInteger
UiTable::CellInteger(int|null $optionalInteger): void
Render a cell showing an integer with grouping; null becomes zero.
| Name | Type | Description |
|---|---|---|
$optionalInteger | int|null | The 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.
| Name | Type | Description |
|---|---|---|
$optionalNumber | float|null | The number value, or null. |
$decimalPlaces | int | The 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.
| Name | Type | Description |
|---|---|---|
$optionalText | string|null | The text value, or null. |
$truncateLength | ?int | A 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.
| Name | Type | Description |
|---|---|---|
$text | string | The 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.
| Name | Type | Description |
|---|---|---|
$optionalText | string|null | The 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.
| Name | Type | Description |
|---|---|---|
$columns | array | The column headings. |
$tableContents | callable | A closure that adds the rows. |
Returns void
Row
UiTable::Row(callable $rowContents): void
Render a table row whose cells are emitted by the closure.
| Name | Type | Description |
|---|---|---|
$rowContents | callable | A 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.
| Name | Type | Description |
|---|---|---|
$items | array | The items to iterate. |
$callback | callable | A 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.
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.
| Name | Type | Description |
|---|---|---|
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$label | string|null | The tab label. |
$url | string|null | An optional url; null renders a non-clickable button. |
$content | Callable | A 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.
| Name | Type | Description |
|---|---|---|
$content | Callable | A closure that declares the tabs. |
UiThemeBackgroundStyleData
Immutable background style: a gradient, corner radius, border colour and width, and padding. Fields and constructor only.
Properties
| Property | Type | Description |
|---|---|---|
$style->gradient | UiThemeGradientData | The background gradient (readonly). |
$style->radius | int | The corner radius in pixels (readonly). |
$style->borderColor | string | The border colour (readonly). |
$style->borderWidth | int | The border width in pixels (readonly). |
$style->padding | int | The padding in pixels (readonly). |
__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.
| Name | Type | Description |
|---|---|---|
$gradient | UiThemeGradientData | The background gradient. |
$radius | int | The corner radius in pixels. |
$borderColor | string | The border colour. |
$borderWidth | int | The border width in pixels. |
$padding | int | The padding in pixels. |
UiThemeButtonData
Immutable button styling: a text style and a background style. Fields and constructor only.
Properties
| Property | Type | Description |
|---|---|---|
$button->textStyle | UiThemeTextStyleData | The button text style. |
$button->backgroundStyle | UiThemeBackgroundStyleData | The button background style. |
__construct
new UiThemeButtonData(UiThemeTextStyleData $textStyle, UiThemeBackgroundStyleData $backgroundStyle)
Construct a button style from a text style and a background style.
| Name | Type | Description |
|---|---|---|
$textStyle | UiThemeTextStyleData | The button text style. |
$backgroundStyle | UiThemeBackgroundStyleData | The 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
| Property | Type | Description |
|---|---|---|
$context->titleStyle | UiThemeTextStyleData | The title text style (readonly). |
$context->textStyle | UiThemeTextStyleData | The body text style (readonly). |
$context->buttonPrimaryTheme | UiThemeVariantData | The primary button variant (readonly). |
$context->buttonSecondaryTheme | UiThemeVariantData | The secondary button variant (readonly). |
$context->panelTheme | UiThemeVariantData | The panel variant (readonly). |
$context->sectionTheme | UiThemeVariantData | The section variant (readonly). |
$context->errorTheme | ?UiThemeVariantData | The optional error variant (readonly). |
$context->inputTheme | ?UiThemeVariantData | The optional input variant (readonly). |
$context->backgroundStyle | UiThemeBackgroundStyleData | The background style (readonly). |
$context->spacing | float | The spacing between elements (readonly). |
$context->padding | float | The padding (readonly). |
$context->currentThemeName | string | The current theme name (readonly). |
__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
| Property | Type | Description |
|---|---|---|
$theme->name | string | The theme name (readonly). |
$theme->variants | array | A map of variant name to variant data (readonly). |
$theme->defaultVariantName | string | The default variant name (readonly). |
$theme->optionalContentTitleNestedFont | ?string | The font for nested titles when set (readonly). |
$theme->optionalContentTitleNestedPanelGradient | ?UiThemeGradientData | The nested-title gradient with a panel ancestor (readonly). |
$theme->optionalContentTitleNestedMainGradient | ?UiThemeGradientData | The 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.
| Name | Type | Description |
|---|---|---|
$variantName | string | The variant name to look up. |
Returns ?UiThemeVariantData The variant, or null.
UiThemeGradientData
Immutable gradient of one or two colours. Fields and constructor only.
Properties
| Property | Type | Description |
|---|---|---|
$gradient->colour1 | string | The first colour (readonly). |
$gradient->colour2 | string|null | The optional second colour (readonly). |
__construct
new UiThemeGradientData(readonly string $colour1 = '#FF00FF', readonly string|null $colour2 = null)
Construct a gradient from a first colour and an optional second colour.
| Name | Type | Description |
|---|---|---|
$colour1 | string | The first colour. |
$colour2 | string|null | The 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
| Property | Type | Description |
|---|---|---|
$input->labelTextStyle | UiThemeTextStyleData | The label text style (readonly). |
$input->fieldTextStyle | UiThemeTextStyleData | The field text style (readonly). |
$input->fieldBackgroundStyle | UiThemeBackgroundStyleData | The field background style (readonly). |
$input->fieldErrorTextStyle | UiThemeTextStyleData | The field error text style (readonly). |
$input->fieldErrorBackgroundStyle | UiThemeBackgroundStyleData | The field error background style (readonly). |
$input->errorTextStyle | UiThemeTextStyleData | The error message text style (readonly). |
$input->spacing | float | The spacing between input parts (readonly). |
__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.
| Name | Type | Description |
|---|---|---|
$backgroundStyle | ?UiThemeBackgroundStyleData | The 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.
| Name | Type | Description |
|---|---|---|
$existingContext | UiThemeContextData | The context to merge into. |
$theme | UiThemeVariantData | The variant to apply. |
$themeRegistry | array | The registry of variants to resolve names against. |
$currentThemeName | string | The 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.
| Name | Type | Description |
|---|---|---|
$themeName | string | The variant name to resolve. |
$themeRegistry | array | The 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.
| Name | Type | Description |
|---|---|---|
$textStyle | ?UiThemeTextStyleData | The 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.
| Name | Type | Description |
|---|---|---|
$themes | array | The map of variants to validate. |
Returns void
UiThemeStyleData
Immutable paired styling: a text style and a background style. Fields and constructor only.
Properties
| Property | Type | Description |
|---|---|---|
$style->textStyle | UiThemeTextStyleData | The text style. |
$style->backgroundStyle | UiThemeBackgroundStyleData | The background style. |
__construct
new UiThemeStyleData(UiThemeTextStyleData $textStyle, UiThemeBackgroundStyleData $backgroundStyle)
Construct a paired style from a text style and a background style.
| Name | Type | Description |
|---|---|---|
$textStyle | UiThemeTextStyleData | The text style. |
$backgroundStyle | UiThemeBackgroundStyleData | The 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
| Constant | Value | Description |
|---|---|---|
UiThemeTextStyleData::LEFT | 'left' | Left alignment. |
UiThemeTextStyleData::CENTER | 'center' | Centre alignment. |
UiThemeTextStyleData::RIGHT | 'right' | Right alignment. |
Properties
| Property | Type | Description |
|---|---|---|
$text->gradient | UiThemeGradientData | The text colour gradient (readonly). |
$text->font | string | The font family (readonly). |
$text->size | float | The font size (readonly). |
$text->allCaps | bool | Whether the text is uppercased (readonly). |
$text->underline | bool | Whether the text is underlined (readonly). |
$text->bold | bool | Whether the text is bold (readonly). |
$text->italic | bool | Whether the text is italic (readonly). |
$text->alignment | string | The alignment, one of the constants (readonly). |
__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
| Property | Type | Description |
|---|---|---|
$variant->titleStyle | UiThemeTextStyleData | The title text style (readonly). |
$variant->textStyle | UiThemeTextStyleData | The body text style (readonly). |
$variant->buttonPrimaryVariantName | string | The primary button variant name (readonly). |
$variant->buttonSecondaryVariantName | string | The secondary button variant name (readonly). |
$variant->panelVariantName | string | The panel variant name (readonly). |
$variant->sectionVariantName | string | The section variant name (readonly). |
$variant->optionalErrorVariantName | ?string | The optional error variant name (readonly). |
$variant->optionalInputVariantName | ?string | The optional input variant name (readonly). |
$variant->backgroundStyle | UiThemeBackgroundStyleData | The background style (readonly). |
$variant->spacing | float | The spacing between elements (readonly). |
$variant->padding | float | The padding (readonly). |
__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.