---
title: "ui — Getting Started"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.middag.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# ui — Getting Started

# Getting Started with ui

Requires PHP `^8.3` (8.3, 8.4 and 8.5 are supported; see [Platform](/libraries/reference/platform)). Install via Composer:

```bash
composer require middag-io/ui
```

Compose a form layout from immutable value objects — the result serializes to a JSON contract a renderer consumes:

```php
use Middag\Ui\Block\Section;
use Middag\Ui\Form\Group;

$section = Section::of('personal')
->label('Personal details')
->fields(
    $nameField,
    $emailField,
    Group::of('phone')->fields($countryField, $numberField),
);
```

That's the whole idea: you never write markup, you compose value objects — the same contract renders standalone, inside a Moodle plugin, or inside WordPress, by swapping the renderer downstream.

## Where it's consumed

| Consumer | How |
|---|---|
| `middag-io/framework` | Maps the contracts to its Inertia renderer and form pipeline. |
| Host adapters (Moodle, WordPress) | Render the contract through the host's UI, via the framework. |
| `@middag-io/react` (NPM) | Consumes the emitted JSON page contract on the client. |

## Next

- [Architecture](/framework/explanation/ui/architecture/) — the PageContract system, the composition levels, the concern-first layout, and why nothing here renders.
- [Page Composition Contract](/framework/reference/ui/composition-levels-and-capabilities/) — the verified L1-L3 PHP entry points and the `PageContract`/`BlockDescriptor` shape.

Source: https://docs.middag.dev/framework/tutorials/ui/getting-started/index.mdx
