Reference

Frame

Another page, shown inside this one: an iframe — the page at src:, or the HTML srcdoc: gives it, sandboxed as sandbox: says. on message(m) hears what that page posts to this one (m.data), and nothing any other page posts. Without title: it draws an A17 warning: a frame is announced by its title.

Frame(src: String, srcdoc: String, title: String, …)

Since 5.9.0

title

loading

lazy

eager

Frame says: nothing yet

Example

wf

state version = 2 state heard = "nothing yet" Stack(gap: .sm) { Row(gap: .sm) { Button("Version 1") { on click { version = 1 } } Button("Version 2") { on click { version = 2 } } } Frame(srcdoc: "<p style='font-family:sans-serif'>Release notes, version {version}</p>", title: "Release notes preview", sandbox: "") { style { width: 100%; height: 120px; border: 1px solid $color-border; border-radius: 8px } on load { heard = "version {version} loaded" } } Text("Frame says: {heard}").muted.sm }

A page of the site, and what it posts

wf

state heard = "" Frame(src: "/playground", title: "The playground", sandbox: "allow-scripts allow-same-origin") { on message(m) { heard = JSON.stringify(m.data) } }

Loaded only when scrolled near, allowed full screen

wf

Frame(src: "/showcase", title: "The showcase", allow: "fullscreen").lazy

Props

Props of Frame
PropTypeUnsetMeaning

src:

String

none

The address of the page it shows

srcdoc:

String

none

The HTML it draws in place of an address, sandboxed as sandbox: says; a value that reads state draws the new HTML as it changes

title:

String

none

What it shows, in a few words: its accessible name (A17 without it)

sandbox:

String

none

What the framed page may do: "allow-scripts allow-forms"; "", nothing. Unset, no sandbox, except srcdoc: from a value, which gets ""

allow:

String

none

The browser features it may use, a permissions policy: "fullscreen; clipboard-write"

loading:

one of its cases

none: at once

When the browser fetches the framed page. Written as a flag, .lazy, or by name, loading: .lazy.

  • .lazy: When it nears the viewport
  • .eager: At once

Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.

Flags and cases

A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.

.lazy

.eager

Events

Events of Frame
EventSendsMeaning
on message—
on load—

Every element also takes the props, the events and the attribute families listed on every element.

Slots

It takes no slots.

Renders with the class wf-frame, stable across releases, so a stylesheet may target it.