Notice
Present persistent contextual guidance with independent color, visual treatment, and accessible announcement policy.
Default
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let informationNotice =
fveNotice {
_id "notice-information"
_label "Before you submit"
p { "Check the contact name and email address before sending." }
}On this page
Installation
Copy this component and its required dependencies into the consumer-owned Components project.
dotnet fve add notice --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 informationNotice =
fveNotice {
_id "notice-information"
_label "Before you submit"
p { "Check the contact name and email address before sending." }
}Colors
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let noticeColorExamples =
div {
_class "grid w-full min-w-0 grid-cols-[repeat(auto-fit,minmax(min(100%,20rem),1fr))] gap-4"
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
fveNotice {
_id ("notice-color-" + label.ToLowerInvariant())
_label label
p { "Review your details before continuing." }
_color color
}
}Variants
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let noticeVariantExamples =
div {
_class "grid w-full min-w-0 grid-cols-[repeat(auto-fit,minmax(min(100%,20rem),1fr))] gap-4"
for label, variant in
[ "Solid", NoticeVariant.Solid
"Soft", NoticeVariant.Soft
"Outline", NoticeVariant.Outline
"Ghost", NoticeVariant.Ghost ] do
fveNotice {
_id ("notice-variant-" + label.ToLowerInvariant())
_label label
p { "Review your details before continuing." }
_variant variant
fveNoticeActions {
fveLink {
_variant LinkVariant.Plain
_href "/components/notice"
_class "underline underline-offset-2"
"Read guidance"
}
}
}
}Success with download
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let successNotice =
fveNotice {
_id "notice-success"
_label "Export ready"
p { "Your export is ready to download." }
_color Color.Success
fveNoticeActions {
fveLink {
_variant LinkVariant.Plain
_href "data:text/csv;charset=utf-8,Name%2CStatus%0AProject%20notes%2CActive"
_attr ("download", "items.csv")
_class "underline underline-offset-2"
"Download"
}
}
}Warning
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let warningNotice =
fveNotice {
_id "notice-warning"
_label "Review required"
p { "Two items need review before they can be published." }
_color Color.Warning
}Error with recovery link
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let criticalNotice =
fveNotice {
_id "notice-error"
_label "Details need attention"
p { "Correct the highlighted fields and validate the form again." }
_color Color.Error
fveNoticeActions {
fveLink {
_variant LinkVariant.Plain
_href "/components/error-summary"
_class "underline underline-offset-2"
"Review highlighted fields"
}
}
}Announce an update
open System
open FSharp.ViewEngine
open Acme.Components
open type Html
open type Svg
open type Datastar
let noticeAnnouncementExample =
div {
_class "grid gap-4"
_dataSignals "{_noticeStatus: ''}"
fveButton {
_class "justify-self-start"
_dataOn ("click", "$_noticeStatus = 'Ready to continue.'")
"Update status"
}
fveNotice {
_id "notice-announcement"
_label "Status"
_announcement LiveAnnouncement.Polite
span { _dataText "$_noticeStatus" }
}
}This example also uses Button. See their Installation sections for any additional setup.
Ordinary persistent notices use LiveAnnouncement.Static. Use Polite for status updates, as shown here; reserve Assertive for urgent changes that need immediate attention.
API reference
type LiveAnnouncement =
| Static
| Polite
| Assertive
type NoticeVariant =
| Solid
| Soft
| Outline
| Ghost
module NoticeDsl =
val fveNotice : ComponentElementBuilder
val fveNoticeActions : ComponentElementBuilder
module NoticeAttributes =
val Html._variant.Static : value:NoticeVariant -> HtmlAttribute