alert: Alert boxes

View source: R/alert.R

alertR Documentation

Alert boxes

Description

Use an alert element to let the user know of successes or to call attention to problems.

Usage

alert(..., dismissible = TRUE, fade = TRUE)

Arguments

...

Character strings specifying the text of the alert or additional named arguments passed as HTML attributes to the alert element.

dismissible

One of TRUE or FALSE specifying if the alert may be dismissed by the user, defaults to TRUE.

fade

One of TRUE or FALSE specifying if the alert fades out or immediately disappears when dismissed, defaults to TRUE.

Details

Dismissible alerts

With dismissible = TRUE you can allow the user to remove an alert. By default, alerts are dismissible, well suited for one-time messages or warnings.

alert(
  .style %>%
    background("primary"),
  "I'm around till you say goodbye"
)

Static alerts

If you do want to keep an alert or control an alert with renderUI() you can then use dismissible = FALSE.

alert(
  .style %>%
    background("warning"),
  dismissible = FALSE,  # <-
  "I'm calling attention to something, forever."
)

Contextual content

Alerts include a few contextual variations. Links and headings are both styled differently inside an alert.

alert(
  .style %>%
    background("success"),
  h5("Success!"),
  "Your results can be found",
  a(href = "#", "here")
)

If you want to avoid these automatic styles you can use tags$a, tags$h1, tags$h2, etc.

alert(
  .style %>%
    background("light") %>%
    border("dark"),
  tags$h6("Default heading"),
  h6("Alert heading"),
  hr(),
  tags$a(href = "#", "Default link"),
  a(href = "#", "Alert link")
)

Like the a() tag elements, yonder’s linkInput()s also receive contextual styling.

alert(
  .style %>%
    background("danger"),
  h5("Problem"),
  hr(),
  linkInput(
    id = "rerun",
    label = "Click to run again"
  )
)

See Also

Other components: badge(), blockquote(), card(), collapsePane(), d1(), dropdown(), img(), jumbotron(), modal(), navContent(), popover(), pre(), toast()


nteetor/yonder documentation built on June 8, 2022, 1:36 p.m.