Link
Use the Link component in typed F# interfaces.
Default
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let basicLink =
fveLink {
_href "/components"
"Read documentation"
}On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add link --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 basicLink =
fveLink {
_href "/components"
"Read documentation"
}Text underline
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let textUnderlineExamples =
div {
_class "flex flex-wrap items-center justify-center gap-3"
fveLink {
_href "/components"
_underline LinkUnderline.Always
"Always underlined"
}
fveLink {
_href "/components"
_underline LinkUnderline.OnInteraction
"Underline on interaction"
}
}Text links default to LinkUnderline.Always. Use _underline LinkUnderline.OnInteraction to show the underline only on hover or keyboard focus. Both retain the same keyboard focus ring.
Inherited presentation
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let plainLink =
fveNotice {
_label "Inherited presentation"
_color Color.Info
_variant NoticeVariant.Solid
fveLink {
_href "/components/notice"
_variant LinkVariant.Plain
_class "underline"
"Read notice documentation"
}
}Plain retains native navigation and a current-color keyboard outline without imposing typography, color or control geometry. Use it for branded/card links and links inside an already colored surface; the consumer owns that composition.
Sizes
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let linkSizeExamples =
div {
_class "flex flex-wrap items-center justify-center gap-3"
for label, size in [ "Extra small", Size.ExtraSmall; "Small", Size.Small; "Medium", Size.Medium; "Large", Size.Large; "Extra large", Size.ExtraLarge ] do
fveLink {
_variant LinkVariant.Solid
_size size
_href "/examples"
label
}
}Uniform padding
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let uniformPaddingLinks =
div {
_class "flex flex-wrap items-center justify-center gap-4"
for size, label in [ Size.ExtraSmall, "Extra small"; Size.Small, "Small"; Size.Medium, "Medium"; Size.Large, "Large"; Size.ExtraLarge, "Extra large" ] do
for variant, treatment in [ "Outline", LinkVariant.Outline; "Ghost", LinkVariant.Ghost ] do
fveLink {
_href "/examples/application/settings"
_variant treatment
_size size
_padding Padding.Uniform
_ariaLabel (label + " " + variant + " settings")
fveIcon { _name IconName.Cog6Tooth; _size Size.Small }
}
}This example also uses Icon. See their Installation sections for any additional setup.
Padding.Uniform uses the size’s vertical inset on every side, producing a square control around a square child. Default padding is unchanged. Uniform applies to control variants; Text remains an inline link without control padding.
Colors
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let linkColorExamples =
div {
_class "flex flex-wrap items-center justify-center gap-3"
for label, palette in
[ "Primary", Color.Primary
"Secondary", Color.Secondary
"Success", Color.Success
"Warning", Color.Warning
"Error", Color.Error
"Info", Color.Info
"Neutral", Color.Neutral ] do
fveLink {
_color palette
_href "/components"
label
}
}Variants
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let linkVariantExamples =
div {
_class "flex flex-wrap items-center justify-center gap-3"
for label, treatment in
[ "Text", LinkVariant.Text
"Solid", LinkVariant.Solid
"Soft", LinkVariant.Soft
"Outline", LinkVariant.Outline
"Ghost", LinkVariant.Ghost ] do
fveLink {
_variant treatment
_href "/components"
label
}
}Ghost links stay flat, without a decorative shadow at rest, on hover or while pressed. Their subtle state backgrounds, keyboard focus ring and native navigation behavior are retained.
All color variants
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let actionColors =
[ Color.Primary, "Primary"; Color.Secondary, "Secondary"; Color.Success, "Success"
Color.Warning, "Warning"; Color.Error, "Error"; Color.Info, "Info"; Color.Neutral, "Neutral" ]
let actionPaletteGrid (rows: (string * HtmlElement list) list) =
div {
_class "grid min-w-0 w-full gap-6"
for label, controls in rows do
div {
_data("action-variant", label.ToLowerInvariant())
_class "grid min-w-0 gap-3"
h3 { _class "text-sm font-semibold"; label }
div { _class "flex min-w-0 flex-wrap items-center gap-3"; yield! controls }
}
}
let linkPaletteExamples =
[ for variant, treatment in [ "Text", LinkVariant.Text; "Solid", LinkVariant.Solid; "Soft", LinkVariant.Soft; "Outline", LinkVariant.Outline; "Ghost", LinkVariant.Ghost ] do
variant,
[ for color, label in actionColors do
fveLink {
_href "/components/link"
_variant treatment; _color color
_ariaLabel (variant + " " + label)
_data("action-color", label.ToLowerInvariant())
label
} ] ]
|> actionPaletteGridHover and press retain native link behavior. Text links strengthen their foreground/underline; control-like variants use the same action palette as Button, including visibly tinted built-in light-mode Soft fills. Custom palettes and soft-color token overrides retain their authored values.
Icon-only variants
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let linkIconVariants =
div {
_class "flex flex-wrap items-center justify-center gap-6"
for label, variant in [ "Text", LinkVariant.Text; "Solid", LinkVariant.Solid; "Soft", LinkVariant.Soft; "Outline", LinkVariant.Outline; "Ghost", LinkVariant.Ghost ] do
div {
_class "grid justify-items-center gap-3"
fveLink {
_href "/examples/application/settings"
_variant variant; _color Color.Neutral; _size Size.Medium
_ariaLabel (label + " settings")
fveIcon { _name IconName.Cog6Tooth; _variant IconVariant.Mini }
}
span { _class "text-sm"; label }
}
}This example also uses Icon. See their Installation sections for any additional setup.
Icon-only sizes
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let linkIconSizes =
div {
_class "flex flex-wrap items-center justify-center gap-6"
for size, label in [ Size.ExtraSmall, "Extra small"; Size.Small, "Small"; Size.Medium, "Medium"; Size.Large, "Large"; Size.ExtraLarge, "Extra large" ] do
div {
_class "grid justify-items-center gap-3"
fveLink {
_href "/examples/application/settings"; _variant LinkVariant.Outline; _size size
_ariaLabel (label + " settings")
fveIcon { _name IconName.Cog6Tooth; _variant IconVariant.Micro }
}
span { _class "text-sm"; label }
}
}This example also uses Icon. See their Installation sections for any additional setup.
Use an ordinary Link with a square Icon child and an accessible name. Control variants use the same horizontal/vertical padding and minimum height as Button; Text keeps the icon's own dimensions without control padding. Icon-only links retain native navigation, modified clicks and focus behavior.
Native new-tab navigation
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let newTabLink =
fveLink {
_variant LinkVariant.Outline
_href "/examples"
_target "_blank"
_rel "noopener"
"Open examples in a new tab"
}API reference
type LinkVariant =
| Text
| Plain
| Solid
| Soft
| Outline
| Ghost
type LinkUnderline =
| Always
| OnInteraction
type LinkBuilder
module LinkDsl =
val fveLink : LinkBuilder