Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
374f757
Initial toolbar container
elnelson575 Nov 3, 2025
ed1a07e
Updates
elnelson575 Nov 3, 2025
04bd68b
Minor updates
elnelson575 Nov 3, 2025
8f6d6f1
Added tests
elnelson575 Nov 3, 2025
6389307
Updated news
elnelson575 Nov 3, 2025
c7d70e6
Removing example:
elnelson575 Nov 3, 2025
3f8b630
Adding snaps
elnelson575 Nov 5, 2025
1abed04
Adding a few comments
elnelson575 Nov 5, 2025
5fd9254
Update to toolbar testing
elnelson575 Nov 5, 2025
c2289a3
Fix dots in toolbar function
elnelson575 Nov 5, 2025
b23fc17
updates to dots
elnelson575 Nov 5, 2025
d2eb240
Merge branch 'feat/toolbar-container' of https://github.com/rstudio/b…
elnelson575 Nov 5, 2025
0836374
Update R/toolbar.R
elnelson575 Nov 5, 2025
a55d03f
Update inst/components/scss/toolbar.scss
elnelson575 Nov 5, 2025
0afabf4
Update inst/components/scss/toolbar.scss
elnelson575 Nov 5, 2025
e6e9d88
Update inst/components/scss/toolbar.scss
elnelson575 Nov 5, 2025
478f5e1
Merge remote-tracking branch 'origin/main' into feat/toolbar-container
elnelson575 Nov 13, 2025
0340d21
Merge remote-tracking branch 'origin/main' into feat/toolbar-container
elnelson575 Nov 13, 2025
f898670
Updated code
elnelson575 Nov 14, 2025
899b644
minor formatting changes
elnelson575 Nov 14, 2025
6a3ccfe
Adding footer back
elnelson575 Nov 14, 2025
88f00d8
Docs changes
elnelson575 Nov 14, 2025
df309bf
Updating footer, updating tests
elnelson575 Nov 14, 2025
68b7006
chore: air format tests/testthat/test-toolbar.R
gadenbuie Nov 14, 2025
3a9b59e
Merge 'origin/main' into branch feat/toolbar-container
gadenbuie Nov 14, 2025
12db810
Spacing
elnelson575 Nov 14, 2025
10ba431
Merge branch 'feat/toolbar-container' of https://github.com/rstudio/b…
elnelson575 Nov 14, 2025
87cbf1d
Updating comments
elnelson575 Nov 14, 2025
6be96cb
Removed select formatting to be addressed in select input PR
elnelson575 Nov 17, 2025
d16f727
Update tests/testthat/test-toolbar.R
elnelson575 Nov 17, 2025
3d7d9f0
Update tests/testthat/test-toolbar.R
elnelson575 Nov 17, 2025
3cc95fe
Updated tests
elnelson575 Nov 17, 2025
d9a5bf0
Updating formatting
elnelson575 Nov 17, 2025
9357091
Update tests/testthat/test-toolbar.R
elnelson575 Nov 18, 2025
e147457
Updated blocking
elnelson575 Nov 18, 2025
7b81e5d
Updated tests
elnelson575 Nov 18, 2025
1aaa67b
Dealing with merge conflicts
elnelson575 Nov 18, 2025
d03af3d
Update markdown headers in bs-theme-preset.md
elnelson575 Nov 18, 2025
6a79efe
Update header format in bs-theme-preset-builtin.md
elnelson575 Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Collate:
'sidebar.R'
'staticimports.R'
'toast.R'
'toolbar.R'
'tooltip.R'
'utils-deps.R'
'utils-shiny.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export(toggle_popover)
export(toggle_sidebar)
export(toggle_switch)
export(toggle_tooltip)
export(toolbar)
export(tooltip)
export(update_popover)
export(update_submit_textarea)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

* Added toast notifications based on [Bootstrap's Toast component](https://getbootstrap.com/docs/5.3/components/toasts/): Use `toast()` to create customizable toast objects, `show_toast()` to display a toast message, `hide_toast()` for manual dismissal, and `toast_header()` for structured headers with icons and status indicators. (#1246)

* Added a new `toolbar()` component for creating Bootstrap toolbars that can contain buttons, text, and other elements. (#1247)

## Improvements and bug fixes

* `card_header()` is now flex by default and gains a `gap` argument to better support complex header layouts. (#1253)
Expand Down
28 changes: 28 additions & 0 deletions R/toolbar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#' Toolbar component
#'
#' @description
#' A toolbar which can contain buttons, inputs, and other UI elements in a small
#' form suitable for inclusion in card headers, footers, and other small places.
#'
#' @param ... UI elements for the toolbar.
#' @param align Determines if toolbar should be aligned to the `"right"` or
#' `"left"`.
#' @return Returns a toolbar element.
#'
#' @export
toolbar <- function(
...,
align = c("right", "left")
) {
align <- rlang::arg_match(align)

tag <- div(
class = "bslib-toolbar bslib-gap-spacing",
"data-align" = align,
...,
component_dependencies()
)

tag_require(tag, version = 5, caller = "toolbar()")
as_fragment(tag)
}
36 changes: 36 additions & 0 deletions inst/components/scss/toolbar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Toolbar */
.bslib-toolbar {
display: flex;
align-items: center;

/* ---- Toolbar options ---- */

&[data-align="left"] {
margin-right: auto;
}

&[data-align="right"] {
margin-left: auto;
}

/* ---- Adjustments to other elements ---- */

// Ensures uniformity of font sizing in elements and sub-elements (e.g., input select)
&,
& * {
font-size: 0.8rem;
}

&>* {
margin-bottom: 0 !important;
width: auto;
align-self: center;
}

// Card header is flex by default, but card footer is not and must be in order for
// toolbar alignment to work
.card-footer:has(> &) {
display: flex;
align-items: center;
}
}
21 changes: 21 additions & 0 deletions man/toolbar.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions tests/testthat/_snaps/toolbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# toolbar() basic attributes and defaults

Code
show_raw_html(toolbar("Item 1", "Item 2"))
Output
<div class="bslib-toolbar bslib-gap-spacing" data-align="right">
Item 1
Item 2
</div>

# toolbar() aligns correctly

Code
show_raw_html(toolbar("Item 1", "Item 2", align = "left"))
Output
<div class="bslib-toolbar bslib-gap-spacing" data-align="left">
Item 1
Item 2
</div>

---

Code
show_raw_html(toolbar("Item 1", "Item 2", align = "right"))
Output
<div class="bslib-toolbar bslib-gap-spacing" data-align="right">
Item 1
Item 2
</div>

9 changes: 9 additions & 0 deletions tests/testthat/helper-html.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
show_raw_html <- function(x) {
cat(format(x))
}

expect_snapshot_html <- function(x, .envir = parent.frame()) {
x_str <- deparse(substitute(x))
code <- parse(text = sprintf("expect_snapshot(show_raw_html(%s))", x_str))
eval(code, envir = .envir)
}
20 changes: 20 additions & 0 deletions tests/testthat/test-toolbar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_that("toolbar() basic attributes and defaults", {
tb <- as.tags(toolbar(htmltools::span("Test")))
expect_match(htmltools::tagGetAttribute(tb, "class"), "bslib-toolbar")
expect_match(htmltools::tagGetAttribute(tb, "data-align"), "right")
expect_snapshot_html(
toolbar("Item 1", "Item 2")
)
})

test_that("toolbar() aligns correctly", {
tb <- as.tags(toolbar(align = "left"))
expect_equal(htmltools::tagGetAttribute(tb, "data-align"), "left")
expect_snapshot_html(
toolbar("Item 1", "Item 2", align = "left")
)
expect_snapshot_html(
toolbar("Item 1", "Item 2", align = "right")
)
expect_error(toolbar("x", align = "center"))
})