Badge
Label compact metadata and semantic states with typed colors and presentation variants.
Default
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let badgeExample = fveBadge { "Internal" }On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add badge --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 badgeExample = fveBadge { "Internal" }Colors
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let badgeColorExamples =
div {
_class "flex flex-wrap items-center gap-3"
for label, color in
[ "Primary", Color.Primary
"Secondary", Color.Secondary
"Success", Color.Success
"Warning", Color.Warning
"Error", Color.Error
"Info", Color.Info
"Neutral", Color.Neutral ] do
fveBadge {
_color color
label
}
}Soft semantic badges blend their fill and text with the surrounding theme for quieter status cues. Neutral and Custom palettes retain their supplied colors; Solid, Outline and Ghost are unchanged.
Variants
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let badgeVariantExamples =
div {
_class "flex flex-wrap items-center gap-3"
for label, variant in
[ "Solid", BadgeVariant.Solid
"Soft", BadgeVariant.Soft
"Outline", BadgeVariant.Outline
"Ghost", BadgeVariant.Ghost ] do
fveBadge {
_color Color.Success
_variant variant
label
}
}API reference
type BadgeVariant =
| Solid
| Soft
| Outline
| Ghost
module BadgeDsl =
val fveBadge : ComponentElementBuilder