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
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
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
Frame(src: "/showcase", title: "The showcase", allow: "fullscreen").lazy
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
src: | String | none | The address of the page it shows |
srcdoc: | String | none | The HTML it draws in place of an address, sandboxed as |
title: | String | none | What it shows, in a few words: its accessible name ( |
sandbox: | String | none | What the framed page may do: |
allow: | String | none | The browser features it may use, a permissions policy: |
loading: | one of its cases | none: at once | When the browser fetches the framed page. Written as a flag,
|
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
| Event | Sends | Meaning |
|---|---|---|
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.