Phone
Frame rendered content in a neutral responsive phone viewport.
Default
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let defaultPhone =
fvePhone {
div {
_class "grid h-full place-items-center p-[12px] text-center"
"Screen preview"
}
}On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add phone --config src/Acme.Components/fve.jsonNo additional JavaScript import is required.
The CLI resolves dependencies and preserves consumer-authored files. See Installation for project initialization, Tailwind, the shared runtime, and building/loading your app entry.
Usage
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let defaultPhone =
fvePhone {
div {
_class "grid h-full place-items-center p-[12px] text-center"
"Screen preview"
}
}With screen content
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let phoneWithContent =
fvePhone {
div {
_class "grid h-full content-center gap-3 p-[12px] text-center"
strong {
_class "text-lg"
"Notes"
}
p {
_class "text-sm text-[var(--fve-muted-text)]"
"Confirm arrival time."
}
}
}
// Host-owned review links; installed frames supply slots and viewport presentation only.Review controls and expansion
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let fixtureWindowControl (navigation: HtmlAttribute list) (path: string) (id: string) (expanded: bool) =
let label =
(if expanded then "Restore " else "Expand ")
+ (if id = "browser-review" then
"Browser fixture"
else
"Phone fixture")
let separator = if path.Contains('?') then "&" else "?"
fveLink {
_id ("fve-fixture-" + id + (if expanded then "-restorer" else "-launcher"))
yield! navigation
_variant LinkVariant.Outline
_color Color.Neutral
_size Size.Small
_href (
if expanded then
path + separator + "fveAppReturn=" + id
else
path + separator + "expanded=1"
)
_ariaLabel label
_title label
if expanded then
_data ("fve-app-mode-exit", "true")
else
_data ("review-expand", "true")
_dataInit (
"if (new URL(location.href).searchParams.get('fveAppReturn') === "
+ System.Text.Json.JsonSerializer.Serialize id
+ ") { el.focus({preventScroll:true}); el.scrollIntoView({block:'center'}) }"
)
fveIcon {
_name (if expanded then IconName.ArrowsPointingIn else IconName.ArrowsPointingOut)
_variant IconVariant.Mini
}
}
let fixtureAppearance (id: string) =
let signal = "_" + id.Replace('-', '_') + "_mode"
div {
_dataSignals (signal, ["ifmissing"], "window.fveColorMode.current()")
_dataInit $"${signal} = window.fveColorMode.current()"
_dataOn ("fve-color-mode", ["window"], $"${signal} = window.fveColorMode.current()")
fveDropdownMenu {
_id id
fveDropdownMenuTrigger {
_ariaLabel "Choose fixture theme"
fveButton {
_variant ButtonVariant.Outline
_size Size.Small
"Theme"
}
}
for value, caption in [ "system", "System"; "light", "Light"; "dark", "Dark" ] do
let isChecked = value = "system"
fveDropdownMenuItem {
_role "menuitemradio"
_ariaChecked isChecked
_dataAttr ("aria-checked", $"${signal} == '{value}' ? 'true' : 'false'")
_dataOn ("click", $"window.fveColorMode.set('{value}')")
caption
}
}
}
let phoneReviewFrame navigation expanded =
fvePhone {
_expanded expanded
div {
_class "flex h-full min-h-0 flex-col"
div {
_class "shrink-0 border-b border-[var(--fve-border)] p-4 text-center font-semibold"
"Messages"
}
div {
_class "min-h-0 flex-1 overflow-auto p-4"
p {
_class "rounded-lg bg-[var(--fve-surface-hover)] p-3 text-base"
"Confirm arrival time."
}
}
div {
_class "shrink-0 border-t border-[var(--fve-border)] p-4 text-sm text-[var(--fve-muted-text)]"
"Message preview"
}
}
fvePhoneToolbar {
div {
_class "flex min-w-0 flex-wrap items-center gap-3"
fixtureWindowControl navigation "/components/phone" "phone-review" expanded
span {
_class "min-w-0 flex-1 text-sm font-medium"
"Phone preview"
}
fixtureAppearance "phone-review-theme"
}
}
}
let phoneWithControls = phoneReviewFrame [] falseThis example also uses Icon. See their Installation sections for any additional setup.
Install color-mode and dropdown-menu, and initialize ColorMode.assets once in the host head as shown in Theming. withToolbar places consumer-owned review controls above the device. withExpanded retains desktop proportions and presents edge-to-edge content on narrow or short screens, without a fabricated browser address. Controls and destinations remain host-owned.
API reference
module PhoneDsl =
val fvePhone : ComponentElementBuilder
val fvePhoneToolbar : ComponentElementBuilder