Tooltip
Provide delayed supplementary text for a labelled control without replacing its accessible name.
Default
On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add tooltip --config src/Acme.Components/fve.jsonThe 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 basicTooltip =
Tooltip.create "archive-tooltip" "Moves the account out of active lists." (fun descriptionId ->
Button.create (ButtonContent.Text "Archive")
|> Button.withAttributes [ _ariaDescribedby descriptionId ]
|> Button.render)
|> Tooltip.renderExisting description
Bottom placement
API reference
type TooltipSide =
| Top
| Bottom
| Start
| End
type TooltipConfig
/// Apply the trigger renderer's description ID to the focusable control's aria-describedby.
/// Append existing description IDs and retain the control's accessible name.
/// Tooltip content must not contain interactive controls or information unavailable elsewhere.
module Tooltip =
val create : id:string -> description:string -> trigger:(string -> HtmlElement) -> TooltipConfig
val withSide : side:TooltipSide -> config:TooltipConfig -> TooltipConfig
val withDelay : milliseconds:int -> config:TooltipConfig -> TooltipConfig
val withAttributes : attributes:HtmlAttribute list -> config:TooltipConfig -> TooltipConfig
val render : config:TooltipConfig -> HtmlElement