Screens
What goes on a screen, and how components are written.
A screen
Each screen has a name, and its components, top to bottom:
"sign-out": {
"attributes": { "background": "modal" },
"components": [
{ "type": "heading", "attributes": { "level": "1", "size": "title-1" }, "text": "Are you sure you want to sign out?" },
{ "type": "text", "text": "If you’re using Face ID or Touch ID to unlock the app, this will be turned off." },
{
"type": "button-stack",
"slot": "footer",
"children": [
{ "type": "button", "attributes": { "variant": "destructive" }, "text": "Sign out", "action": { "go": "signed-out", "history": "reset" } },
{ "type": "button", "attributes": { "variant": "grouped-secondary" }, "text": "Cancel", "action": "back" }
]
}
]
}
The screen is the library’s screen, and its attributes are that component’s, such as background. A navigation bar goes at the top and sticks there, a tab bar floats at the bottom, and anything with "slot": "footer" is pinned below the content.
"status-bar": "light" makes the status bar white, for a screen that’s dark at its top, such as Home under its green header.
Components
The components are the component library’s. Its docs say what each one is for, how it looks and what it takes. A prototype writes the same component as JSON instead of HTML:
| In the library’s HTML | In a prototype |
|---|---|
The element, <govuk-app-text-field> |
"type": "text-field", its name without govuk-app- |
Its attributes, label="Postcode" |
"attributes": { "label": "Postcode" }, with true or false for one that’s on or off |
| What goes between its tags | "text" |
| The elements inside it | "children", each a component |
slot="footer" |
"slot": "footer" |
So this, from the library:
<govuk-app-button-stack slot="footer">
<govuk-app-button variant="destructive">Sign out</govuk-app-button>
</govuk-app-button-stack>
is written:
{
"type": "button-stack",
"slot": "footer",
"children": [
{ "type": "button", "attributes": { "variant": "destructive" }, "text": "Sign out" }
]
}
The schema is made from the library’s own definitions, so a prototype can use only the components, attributes and values the library has, and only put a component where the library says it can go.
What makes a prototype work is the engine’s, not the library’s, and is kept apart from the attributes:
action: what pressing it does, on anything that can be pressed, such as a button or a link. See moving between screens.nameandvalidation: what it holds, on anything that holds a value, such as a field or a toggle. See values and conditions.chosen: the attributes it has while it’s the one chosen, on one of several choices.when: shows it only while a condition holds, on any component.
Text
Text may show a value, by writing its path in double braces: "Your postcode {{ postcode }} is shared by more than one local council." Only a path may go inside the braces, never an expression.
Where the library allows it, text can be a list, of text and the elements that go around a few words of it:
{ "type": "text", "attributes": { "size": "subheadline" }, "text": [{ "type": "strong", "text": "Expired" }, " 28 March 2026"] }
Groups
A group holds other components, with no appearance of its own, so one when can show or hide them together. A group can go wherever its children could. With each, it shows its children once for each item of a list: see lists and the data bank.