Screenplay layouts and templates: compose shared UI
A Screenplay layout defines the application shell; templates give screens reusable regions to fill. Use a screen template for content inside the shell and a dialog template for content that opens over it. This keeps shared navigation and framing separate from each screen’s data and actions.
| Word | What it is | Where it belongs |
|---|---|---|
| Layout | The application shell, with regions such as a top bar, navigation, content and footer. | Selected by a UI profile. |
| Screen template | A reusable structure inside the shell. | Declared on a module. |
| Dialog template | A reusable structure for content that opens over the application. | Declared on a module. |
| Screen | The content that fills a template’s named regions. | Declared inside a slice. |
Layouts and templates declare slots: named regions where content belongs. An optional arrangement positions those slots. Start by naming the regions you need; add placement rules when the structure needs them.
layout — the application’s shell
Section titled “layout — the application’s shell”A layout is a top level declaration, alongside ui profile and theme:
layout AppShell topbar navigation panel content page routed primary footer
outlet Navigation of navigation in navigation
arrangement flow column topbar height 56 row navigation width 240 content grow footer height 32- Each plain line in the body declares a slot: a region content is placed in.
- A slot line can say what the slot is for, after its name and in this order: a role (
page,paneorpanel),routedorrouted by <param>,primaryandoptional. See Slot roles. category <name>andtype <name>provide catalog metadata for designers and renderers. Every layout and template needs acategory(PLAY0720).exposes <name> [<Type>]names a value the structure makes available to descendants or package tooling.slot <name>declares a recursive fill point for package components and design-time tools. Screenplay 5 wrote itoutlet <name>; that form is now an error (PLAY0893) - runscreenplay migrate --from 5 --to 6.outlet <name> of actions|filters|tabs|stats|navigation [for item|for screen] [in <slot>]declares an outlet: a list of items the structure offers, with itsdefaultitems. A module, feature or screen inherits, extends or overrides it, andcontribute to <name>adds to it from anywhere - see Outlets. The application’s own navigation - a logo and items with targets, slots and sub-items - is a navigation outlet on the layout; see Navigation.arrangementsays how those slots share the space. It is optional: a layout that only names its slots is a complete declaration.
An application selects its layout from a ui profile, the same way it selects its theme:
layout AppShell category application type masterDetail exposes selectedItem String slot details content
ui profile Desktop target platform web root template AppShellSlot roles
Section titled “Slot roles”A slot’s role tells a renderer and a designer what kind of content goes in it. The words follow the slot’s name, and each is optional:
| Word | Meaning |
|---|---|
page |
The slot holds a whole page. |
pane |
The slot holds a pane beside the page, such as a detail view. |
panel |
The slot holds a panel within the page. |
routed |
What the slot shows is part of the address. |
routed by <param> |
The slot is addressed by a route parameter, such as the key of the selected row. |
primary |
The slot is the main one of its structure. |
optional |
The slot may be left empty. |
layout AppShell category application topbar content page routed primary
module Catalog screen template ListPage category Catalog fits slot content header main detail pane routed by sku optionalA slot without a role is still a slot; the role only adds meaning. A slice’s screen lists the roles it fits (fits pane, dialog), and a hook that opens it in slot <name> needs a slot whose role the screen fits - see Placement. A template slot can show another screen for what is selected on this one with show <Screen> by <param> from <element>.selection. Screenplay 6 calls every region content is placed in a slot: the Screenplay 5 forms outlet <name> and destination outlet <name> are errors whose message names screenplay migrate --from 5 --to 6.
A document may declare more than one layout, so that different profiles can select different shells — but each profile selects exactly one, and a profile naming a layout the document does not declare is reported.
screen template — a shape inside the shell
Section titled “screen template — a shape inside the shell”A screen template is declared inside a module, and says which slot of its parent it fills:
module Invoicing screen template MasterDetail fits slot content
sidebar main
arrangement flow row gap 16 sidebar width 280 main grow
when width compact column main sidebarfits slot content places MasterDetail in a parent’s slot named content. Matching uses the slot name, not the template’s declaration location. The parent can be the application layout or another template, so nested structures use the same placement rule.
Declare templates on a module; features and slices use them rather than declaring their own.
You can omit fits slot. The template remains valid, and the renderer decides where to place it.
dialog template — a shape over the application
Section titled “dialog template — a shape over the application”A dialog template declares slots for content that opens over the application. It does not declare fits slot, because it does not occupy a region of the structure beneath it:
module Invoicing dialog template RegisterInvoiceDialog category Dialog body footer outlet actions of actions in footer default cancel title "Cancel" runs close default register title "Register" emphasis primary runs submitA dialog or drawer template declares its buttons as an actions outlet. The built-ins runs close and runs submit close the dialog and submit the screen’s command; see Outlets.
Writing fits slot on a dialog template — or on a layout — is a compile-time error.
screen — filling a template
Section titled “screen — filling a template”A screen names the structure it fills with template <Name>, and provides the content of each slot:
module Invoicing screen template MasterDetail sidebar main
feature InvoiceManagement slice StateView InvoiceDetails query GetInvoice => InvoiceDetailsReadModel
screen InvoiceDetails template MasterDetail sidebar data InvoiceDetailsReadModel via query GetInvoice main section lineItems table lineItems column lineNumberTo fill a dialog, name its dialog template with the same template directive. Here the screen supplies a title in body and a command action in actions:
module Invoicing dialog template RegisterInvoiceDialog body actions
feature InvoiceManagement slice StateChange RegisterInvoice command RegisterInvoice invoiceId Uuid
screen RegisterInvoiceScreen template RegisterInvoiceDialog body title "Register invoice" actions action RegisterInvoiceA screen names its content template, not the application’s layout. A ui profile selects the shell once per build, so individual screens do not choose the application-wide frame.
Own and blueprint templates
Section titled “Own and blueprint templates”Use an own template when you declare the structure in the application. To reuse a packaged structure, reference a blueprint: a package listed under packages in a ui profile that supplies layouts, screen templates or dialog templates. The reference identifies which source to use:
template MasterDetailtemplate blueprint Crm CustomerDetailtemplate blueprint Crm CustomerDetail version "^1.4"template <Name>names an own template.template blueprint <Blueprint> <Name> [version "<range>"]names the template<Name>of the blueprint package<Blueprint>. The optionalversionlimits the accepted package versions using Scene’s supported semantic-version ranges:*, an exact version, or a^,~,>=,>,<=or<range overmajor[.minor[.patch]]. A range Scene cannot read isPLAY0721. Leaving it out accepts any version.- Both forms are valid wherever
templateis: as an assignment at application, module, feature or slice scope, and inside a screen. Scene resolves a reference withresolveTemplateReference(C#TemplateReferenceResolver.Resolve):UnknownBlueprint,VersionNotSatisfied(the installed blueprint has drifted outside the range) andUnknownTemplateare reported where the blueprint is installed, because the compiler has no visibility into a package’s catalog. - When at least one
ui profilelists packages, a blueprint reference whose blueprint no profile lists isPLAY0722, the same rulePLAY0632applies to components. - The same reference names the application’s shell inside a
ui profile:root template <reference>(with itsoptionlines), and the template a new screen starts from,new screens use template <reference>. See UI profile. - A blueprint reference is not checked against the document’s own
scopesor nesting - the blueprint’s templates carry their own metadata, which Scene checks withApplicableTemplates.
Inheriting a template choice
Section titled “Inheriting a template choice”A bare template <Name> can also appear at application, module, feature or slice scope. It assigns the default template for the declarations below that scope until a more specific scope overrides it:
template AppShell
module Invoicing template FeatureShell
feature InvoiceManagement template FeatureShell
slice StateView InvoiceDetails template FeatureShellUse scoped template assignments when a whole feature area shares the same shape. Use a screen-local template <Name> body when the screen fills slots directly. The assignment is preserved as authored metadata; a renderer that cannot apply a scoped template must report that limitation instead of falling back to an unstructured screen.
Template content and picker metadata
Section titled “Template content and picker metadata”A screen or dialog template can provide its own chrome for a slot with content <slot>, and say how a template picker presents it:
module Invoicing screen template MasterDetail display "Master / detail" description "A list beside the selected item" scopes feature, slice
header list details
content header title "Invoices"content <slot>holds screen directives the template renders in that slot itself. The slot must be one the template declares (PLAY0629). Content may use another template, but templates cannot nest in a cycle (PLAY0656).displayanddescriptionare the name and one-line description a picker shows.scopesrestricts where the template may be used:application,module,feature,subfeatureorslice(optionally with slice kinds, see below), ornone. Without it the structural role decides. Using a restricted template outside its scopes isPLAY0631. A layout may declarescopestoo.
These map to Scene’s ScreenTemplate.Content, DisplayName, Description and Metadata.Scopes and Metadata.SliceKinds.
Category and picker metadata
Section titled “Category and picker metadata”Every layout, screen template and dialog template declares a category - the group a template picker lists it under, such as category Workspace or category "Business / List". A template without one is PLAY0720, a warning. A blueprint package is built with warnings as errors, so there a missing category fails the build; an own template only warns until the author gives it one. The category is a free string; one a picker does not know is kept and shown as written. It never decides where a template may be used - scopes does.
Applicability: scopes and slice kinds
Section titled “Applicability: scopes and slice kinds”scopes restricts where a template may be used. At slice scope it can also name the slice kinds the template is for:
module Invoicing screen template InvoiceList category List scopes slice stateview
dialog template RegisterInvoiceDialog category Dialog scopes slice statechange
screen template Workspace category Workspace scopes module, feature, subfeaturescopes slice stateviewallows the template on a state view slice only,scopes slice statechangeon a state change slice only,scopes slice statechange|stateviewon either.scopes slicealone allows any slice that presents something. Kind names are case-insensitive and print lower-case.- A slice that presents nothing - an automation or translate slice - takes no template: using a restricted template there is
PLAY0631, as is using one on a slice kind it excludes. - A template that declares no
scopesis not restricted: the structural role decides, and the compiler accepts it wherever it is used.
Scene’s ApplicableTemplates uses scopes and sliceKinds metadata in place of its per-level defaults when deciding where a template applies. An Automation slice has no presentation. Use these restrictions to keep a template meant for one kind of task, such as a state-change dialog, out of unrelated template choices.
exposure — letting a template be configured
Section titled “exposure — letting a template be configured”Declare an exposure when screens should be able to configure part of a shared template without changing the template itself. It names the component property that can change and, for collections, which operations are allowed. Put the declaration at the top level and name the layout or template that owns the component:
exposure for MasterDetail property navigation.items label "Navigation" operations add, reorder fields label, icon property "invoices:list".pageSize label "Page size"
exposure for DetailPane property navigation.items reexposes MasterDetail operations add- The component is an identifier or a quoted exact stable id, followed by the property path.
operationsmarks the property as a collection and grantsadd,remove,reorderandedit-fieldsone by one (operations nonegrants nothing). Withoutoperationsthe property is a single value.fieldsrestricts which item fields a consumer may change.reexposes <Owner>passes an outer owner’s exposure through a nested template. The outer owner must expose the same property (PLAY0624), and re-exposures may not form a cycle (PLAY0623).
The owner must be a layout, screen template or dialog template (PLAY0622).
instance — configuring what was exposed
Section titled “instance — configuring what was exposed”After the owner exposes a property, a screen or nested template can store its configuration in an instance. This example sets a page size and adds a navigation item:
instance InvoiceList set "invoices:list".pageSize = 50 items navigation.items item open label = "Open" icon = "folder"set <component>.<path> = <value>stores a typed literal for a single-value exposure.items <component>.<path>adds items to a collection exposure; eachitem <id>holds<field> = <value>lines.
The instance must be a screen, screen template or dialog template (PLAY0626). Storing a value no exposure exposes is PLAY0627; using set on a collection or items on a single value is PLAY0628. These map to Scene’s ExposureDeclaration and InstanceContribution.
Once the slots and template choices are in place, arrange them to control how they share space, or fill them from a screen.
See also
Section titled “See also”- Layout arrangement — how a layout or template arranges the slots it declares.
- Screens — the three levels a screen is expressible at, and how its names resolve.
- Contributions — the many-to-one counterpart of a slot.
- Outlets — item lists a layout or template offers, which lower levels inherit, extend, override, hide and reorder.
- Navigation — the topbar and sidebar of the shell as navigation outlets.
- UI profile — where a build selects its layout, theme, platforms and packages.