Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

HTML layouts

How an HTML layout is built so ScreensPro clients can load, show and control it.

HTML is the native layout format of ScreensPro Native. An HTML layout is a plain .html file in the layout folder (or a subfolder). ScreensPro clients load it by its name, exactly as they load a XAML layout from ScreensPro Server: a packet asking for Lower.xaml or Lower loads Lower.html when there is one, else Lower.xaml. So existing client configurations keep working when you replace a XAML layout with an HTML one.

Everything the layout uses - stylesheets, scripts, images, fonts, videos - is in the layout folder and referenced with relative paths.

The minimum

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Lower third</title>
<script src="/screenspro/layout.js"></script>
<style>
  html, body { margin: 0; width: 100vw; height: 100vh; overflow: hidden; background: transparent;
               font-family: "Segoe UI", sans-serif; }

  .bar { position: absolute; left: 120px; bottom: 120px; padding: 24px 48px; color: #fff;
         background: rgba(8, 28, 72, 0.92); transform: translateX(-130%); }

  /* StoryboardIn / StoryboardOut */
  html.sp-in  .bar { animation: slide-in 0.6s ease-out forwards; }
  html.sp-out .bar { animation: slide-out 0.4s ease-in forwards; }
  @keyframes slide-in  { from { transform: translateX(-130%); } to { transform: none; } }
  @keyframes slide-out { from { transform: none; } to { transform: translateX(-130%); } }

  /* AnimateStoryboard "Flash" */
  .Flash { animation: flash 0.5s 2; }
  @keyframes flash { 50% { background: #f5b700; } }
</style>
</head>
<body>
  <div class="bar" id="Bar">
    <div id="Name" data-bind="Name">Name Surname</div>
    <div id="Title" data-bind="Title">Title</div>
  </div>
</body>
</html>

What makes it a ScreensPro layout:

Rule
Why

Transparent background on html and body

Everything without a background is keyed out (fill + key on NDI and SDI). A full-screen layout simply sets its own background

The layout fills the output: 100vw × 100vh, overflow: hidden

The layout is shown at the size of the video format (1920 × 1080 for 1080p). Use pixels for that size, or vw / vh to scale with any format

id on every element a client controls

The id (or data-name) is the x:Name of XAML: the element name of SetProperty, CallMethod and AnimateStoryboard

In and out animations on html.sp-in / html.sp-out

ScreensPro Native adds sp-in when the layout is shown and sp-out when it is unloaded, and waits for those CSS animations and transitions to finish, like StoryboardIn / StoryboardOut

<script src="/screenspro/layout.js">

The ScreensPro layout API and the custom elements. ScreensPro Native adds it to a layout that doesn't include it; include it yourself when your own scripts use screens while the layout loads

Before it is shown, a loaded layout is in the preview: its elements are there, but sp-in is not set yet. Hide what should come in (as transform: translateX(-130%) above) so the layout doesn't flash before its in animation.

How packets reach the layout

ScreensPro
In an HTML layout

x:Name

id (or data-name). * in a packet's element name matches the beginning: Row* reaches Row1, Row2…

StoryboardIn / StoryboardOut

CSS on html.sp-in / html.sp-out; also promises returned by screens.onIn() / screens.onOut()

SetProperty Text

The element's text

SetProperty Visibility

Visible, Hidden (visibility: hidden), Collapsed (display: none)

SetProperty Foreground, Background, Fill, Stroke

color, background, fill / stroke. WPF colors like #AARRGGBB work

SetProperty Source, Path, Filename, Uri, Url

src of an img / video / iframe (a file of the layout folder), else the background image

SetProperty Width, Height, FontSize

The CSS property, in pixels when the value is a number

SetProperty, any other name

The element's property of that name (custom elements have the ScreensPro names: TargetTime, Items…), else its CSS property, else an attribute

CallMethod

The element's method (Start, Stop, Play…). Without an element name: a function of the layout (window.MyFunction)

AnimateStoryboard

A function of the layout by that name, else the CSS class of that name restarted on the element (or on html without an element name)

SetDataContextProperty

The layout's local data: data-bind and the other bindings, screens.local

SetGlobal

screens.globals, Globals.X in bindings

ElementFinished

screens.finished('Name')

Bindings

Bindings are attributes; ScreensPro Native updates the elements whenever the data changes. Paths are relative to the element's data context - the layout's local data, or what data-context or a list row sets. Globals.X, Local.X and Sources.X always start at the top. A name that is not in the local data is looked up in the globals.

Attribute
XAML equivalent
Does

data-bind="Lastname"

Text="{Binding Lastname}"

The element's text (img / video / iframe: its source). The element's own content is the FallbackValue, shown while the path doesn't exist

data-context="Left"

DataContext="{Binding Local.Left}"

The data context of the element and everything in it

data-show="Subline"

ObjectToVisibility- / BoolToVisibilityConverter

Shown when the value is there (not null, empty or false). data-show-default="false" hides it while the path doesn't exist

data-hide="IsHidden"

The opposite of data-show

data-src="images/flags/{Nation}.png"

ImageElement Path + Filename

An attribute from a template; hidden while a part is empty. {PortraitName}[.png] adds the extension only when the value has none

data-set-targettime="TargetTime"

other bound properties

Sets a property of the element (here TargetTime of <sp-targettime>)

data-class-review="IsUnderReview"

DataTrigger

The class review while the value is there

data-fit

TextTrimming="Scale" + MaxWidth

Text wider than the CSS max-width is condensed. data-fit="size": a smaller font instead

data-styled

Runs, G-Studio's TextStyle2D

The text is HTML (see below)

Example with a data context {"Left": {"Firstname": "Jane", "Lastname": "Doe", "Nation": "GER"}, "Rows": [...]}:

Styled text

With data-styled the text - from a binding, from SetProperty Text or written in the layout - is HTML: Hello <b>Mr</b> President, any tags and attributes, style="color:red" and <style> rules (they apply to the whole layout). Write &lt; and &amp; for < and &; <script> doesn't run.

Parts of a text in a class of the layout: Welcome \Style:red\Mr\Style\ President shows "Mr" in the class red (several classes: \Style:red big\). G-Studio's \tsmaller;DANNY\t; MARTIN works the same way. In JSON each \ is written \\.

The screens API

layout.js gives every layout a screens object for its own scripts:

Member
Does

screens.onIn(fn) / screens.onOut(fn)

Called with the in / out animation. A returned promise is waited for

screens.onState(fn)

The layout's state: Preview (loaded) → OnAir → None

screens.onData(fn)

Globals, local data or a data source changed

screens.globals, screens.local, screens.sources

The data

screens.get('Globals.Score')

A value by its path

screens.finished('Name')

Sends ElementFinished to the clients (also counts for sequences)

screens.bind(element)

Applies the bindings to elements you added yourself

screens.setText(element, text)

Sets a text as a binding does (with data-fit, data-styled)

screens.log(text)

A line in the channel's ScreensPro log

screens.state

The current state

The events screens:data and screens:state are also dispatched on window.

CasparCG templates

CasparCG HTML templates work too: ScreensPro Native calls their update(json) with each new data context and waits for play() / stop() like for the in and out animations.

Fonts, images and videos

  • Put fonts next to the layout and load them with @font-face, or use installed fonts.

  • Images and other files are referenced relative to the layout: images/flags/GER.png.

  • Videos and NDI sources are shown with <sp-video> and <sp-ndi>: the application decodes and composites them at full quality.

Reloading

With Reload layouts when their files change on, a layout loads again as soon as you save it - even on air. A changed stylesheet, script, image or font reloads all loaded layouts. A reloaded layout keeps its state and gets what the clients set on it again, without the in animation. This makes it easy to work on a layout in an editor while it is on air in the control window.

XAML layouts

The XAML layouts of ScreensPro Server (WPF .xaml files) keep working: ScreensPro Native renders them with its HTML engine, with the XAML features they use. Copy them, their Styles.xaml, fonts, images and videos into the layout folder. A Name.xaml without a Name.html next to it is a layout; clients use the same layout names, element names and data as with ScreensPro Server.

  • StoryboardIn (or In) runs when the layout is shown, StoryboardOut (or Out) when it is unloaded, EventTriggers on Loaded when it is loaded.

  • Local is the layout's data context, Globals the global values, Sources the data sources.

  • Styles.xaml next to the layout, else in the layout folder, is the application's resources; the dbnetsoft converters (ObjectToVisibilityConverter, BoolToVisibilityConverter…) are there.

  • A layout made for another size is scaled to the output.

  • Panels, shapes, brushes, effects (drop shadow, blur), transforms, styles, triggers, bindings and storyboards work as in WPF; so do the Screens.Controls elements (TextElement, ImageElement, ClockElement, StopwatchElement, TargetTimeElement, ListElement, ItemsElement, SlideshowElement, VideoElement, NdiElement, WebbrowserElement, FlagWaveEffect).

  • Font files in the layout folder (Fonts\*.ttf, .otf) are found by their family names without installing them.

Not supported in XAML layouts: code-behind (x:Class is ignored, as ScreensPro Server does), controls of other assemblies, 3D, LayoutTransform and input controls. Unknown elements are left empty with a warning in the ScreensPro log. Text is laid out by the HTML engine, so a line may come out a pixel wider or narrower than in WPF.