Skip to content

Conversation

@elnelson575
Copy link
Contributor

@elnelson575 elnelson575 commented Nov 12, 2025

Fixes #1248

Adds buttons suitable for inclusion in toolbars.

Buttons:

  • Inherit font sizing from their toolbar parent element
  • Can have icons, text, or both
  • Default to no border, but can have a border
  • Can be deactivated or active
  • Check & format toolbar.R
  • Scss changes
  • Add tests
  • Example app
  • Regenerate docs + check

To-do:

  • Ensure that the toolbar doesn't change height based on button sizes, but that the buttons have a good default, legible size
  • Make sure there's no awkward gap between icon and label
  • Verify spacing between buttons is good
  • Fix footer
Example with active/disabled button

Before click activate button:
Screenshot 2025-11-20 at 1 41 17 PM

library(shiny)
library(bslib)

ui <- page_fillable(
  tags$head(
    tags$link(rel = "stylesheet", type = "text/css", href = "styles.css")
  ),
  card(
    card_header(
      icon("star"),
      "Card 1 header",
      toolbar(
        align = "right",
        toolbar_input_button(id = "see", icon = icon("eye")),
        toolbar_input_button(id = "save", icon = icon("save")),
        toolbar_input_button(id = "edit", icon = icon("pencil")),
        toolbar_input_button(
          id = "calendar",
          label = "Schedule",
          icon = icon("calendar"),
          disabled = TRUE
        )
      )
    ),
    p("Card 1 body"),
    actionButton("activate_schedule", "Activate Schedule"),
    max_height = "500px",
    card_footer(
      toolbar(
        align = "left",
        toolbar_input_button(id = "go", label = "Go"),
        toolbar_input_button(id = "Exit", label = "Exit")
      )
    )
  ),
  toolbar(
    align = "left",
    toolbar_input_button(
      id = "test2",
      icon = icon("star"),
      tooltip = "Favorite"
    ),
    toolbar_input_button(id = "love2", icon = icon("heart"), tooltip = "Like"),
    toolbar_input_button(
      id = "comment2",
      icon = icon("comment"),
      tooltip = "Comment"
    )
  ),
  card(
    card_header(
      "Card 2 header",
      toolbar(
        align = "right",
        downloadLink(
          "download2",
          "Download",
        )
      ),
    ),
    p("Card 2 body"),
    actionButton("activate_schedule2", "Activate Schedule"),
    max_height = "500px",
    card_footer(
      toolbar(
        align = "right",
        toolbar_input_button(
          id = "paragraph2",
          icon = icon("paragraph")
        )
      )
    )
  ),
  toolbar(
    align = "left",
    gap = "10",
    toolbar_input_button(id = "test", icon = icon("star")),
    toolbar_input_button(id = "love", icon = icon("heart")),
    toolbar_input_button(id = "comment", icon = icon("comment"))
  )
)

server <- function(input, output) {
  observeEvent(input$activate_schedule, {
    updateActionButton(
      inputId = "calendar",
      disabled = FALSE
    )
  })
}


shinyApp(ui = ui, server = server)

@elnelson575 elnelson575 linked an issue Nov 12, 2025 that may be closed by this pull request
Comment on lines +29 to +31
>.fa,
>.bi,
>.glyphicon {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative, maybe we should put the icon in a <span class="toolbar-icon"> and then use this?

Suggested change
>.fa,
>.bi,
>.glyphicon {
> .toolbar-icon > * {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@gadenbuie gadenbuie Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to get there is roughly:

# In this PR
usethis::use_dev_package("shiny")

This adds a Remotes field to DESCRIPTION so that dev bslib uses dev shiny, plus a min version requirement on shiny.

Then after shiny v1.12.0 release, we'll update the record here in bslib.

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolbar: Toolbar Button

3 participants