Skip to content

feat: Add toolbar_download_button()#1298

Draft
elnelson575 wants to merge 10 commits intomainfrom
feat/toolbar-download-button
Draft

feat: Add toolbar_download_button()#1298
elnelson575 wants to merge 10 commits intomainfrom
feat/toolbar-download-button

Conversation

@elnelson575
Copy link
Contributor

@elnelson575 elnelson575 commented Mar 16, 2026

Summary

Adds toolbar_download_button() to the toolbar component family, providing a download button styled consistently with other toolbar inputs for use in card headers, footers, and other toolbar contexts.

Closes #1292

  • Adds toolbar_download_button() R function that creates an <a> tag with Shiny's download machinery
  • Adds update_toolbar_download_button() for dynamically updating the disabled state
  • Adds TypeScript input binding for receiving update messages
  • Adds SCSS styles matching toolbar_input_button() patterns
  • Includes comprehensive tests with HTML snapshots

Usage

card(
  card_header(
    "Flower Data",
    toolbar(
      align = "right",
      toolbar_download_button("download_data", label = "Download")
    )
  ),
  card_body(
    reactable::reactable(iris)
  )
)

Test Plan

  • All 162 toolbar tests pass
  • TypeScript compiles without errors
  • HTML structure matches spec
  • Manual verification in Shiny app with downloadHandler()

elnelson575 and others added 5 commits March 16, 2026 11:57
Addresses issue #1292 - adds a download button styled for toolbars.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add base styles and data-type attribute selectors for .bslib-toolbar-download-button to match the existing toolbar input button styling. This includes hover/focus/active states, disabled state, and responsive sizing for label-only, icon-only, and combined icon+label button layouts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds comprehensive test coverage for toolbar_download_button():
- Basic structure validation (classes, button types)
- show_label parameter behavior
- disabled state with accessibility attributes
- border parameter (border-0 vs border-1)
- tooltip parameter (default, custom, and disabled)
- custom icon support

All tests follow existing patterns from toolbar_input_button() tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@elnelson575 elnelson575 marked this pull request as draft March 16, 2026 19:03
elnelson575 and others added 5 commits March 16, 2026 19:09
- Fix border=TRUE to use Bootstrap's 'border' class instead of 'border-1' (border-1 only sets width, not style) for both toolbar_input_button and toolbar_download_button
- Add rel="noopener noreferrer" to target="_blank" anchor tag
- Add @examplesIf block to toolbar_download_button docs
- Add NEWS.md entry under new "New features" section
- Update snapshots to reflect border and rel changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines +31 to +42
receiveMessage(el: HTMLElement, message: ToolbarDownloadButtonMessage) {
if (hasDefinedProperty(message, "disabled")) {
if (message.disabled) {
el.classList.add("disabled");
el.setAttribute("aria-disabled", "true");
el.setAttribute("tabindex", "-1");
} else {
el.classList.remove("disabled");
el.removeAttribute("aria-disabled");
el.removeAttribute("tabindex");
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use Shiny.addCustomMessageHandler("handler1", doAwesomeThing1); instead, see https://shiny.posit.co/r/articles/build/js-send-message/

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_download_button()

2 participants