Skip to main content

Popover

Present labelled interactive content adjacent to a trigger with focus and dismissal ownership.

Default

On this page

Installation

Copy this component and its required dependencies into the consumer-owned Components project.

dotnet fve add popover --config src/Acme.Components/fve.json

The CLI resolves dependencies and preserves consumer-authored files. See Installation for project initialization and Tailwind source detection.

Usage

open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar

let profilePopover =
    Popover.create "profile-popover" "Account details" (span { "Account details" }) "Account details" (p { "Signed in as Alex Morgan." })
    |> Popover.render

Initial content focus

Side and alignment

API reference

type PopoverSide =
    | Top
    | Bottom
    | Start
    | End

type PopoverAlignment =
    | Start
    | Center
    | End

type PopoverConfig

module Popover =
    val create : id:string -> triggerLabel:string -> trigger:HtmlElement -> contentLabel:string -> content:HtmlElement -> PopoverConfig
    val withSide : side:PopoverSide -> config:PopoverConfig -> PopoverConfig
    val withAlignment : alignment:PopoverAlignment -> config:PopoverConfig -> PopoverConfig
    val focusContentOnOpen : config:PopoverConfig -> PopoverConfig
    val withTriggerAttributes : attributes:HtmlAttribute list -> config:PopoverConfig -> PopoverConfig
    val withAttributes : attributes:HtmlAttribute list -> config:PopoverConfig -> PopoverConfig
    val render : config:PopoverConfig -> HtmlElement