Skip to content

feat: Add toolbar spacer#1265

Merged
elnelson575 merged 18 commits intofeat/toolbar-epicfrom
feat/add-toolbar-spacer
Dec 12, 2025
Merged

feat: Add toolbar spacer#1265
elnelson575 merged 18 commits intofeat/toolbar-epicfrom
feat/add-toolbar-spacer

Conversation

@elnelson575
Copy link
Contributor

@elnelson575 elnelson575 commented Dec 8, 2025

Fixes #1259

Goal:
Give users control over spacing in toolbars.
Enable both:

  • Dividers with lines
  • Spacers that are blank

Allow users to:

  • Change width of blank spacer
  • Change width of spacer with divider (via the spacing around the line)
  • Change width of divider line (via function arg)
  • Change color of divider line (via bootstrap var, defaults to the border color)

Additional Considerations:

  • Should not read anything in VoiceOver (verified)
  • Should work if switched to dark mode
Dark Mode Verification Screenshot 2025-12-08 at 11 06 43 AM

Decision Log:
How to we want to make a toolbar like this particular (split) case?
Screenshot 2025-12-05 at 12 43 04 PM
This can be accomplished right now via creating two toolbars, one with align = "left" and one with align = "right".
Question: Should we make it possible such that you have ONE toolbar (vs two with different alignments) and put a spacer in the middle to split half of it to the left and half of it to the right?
No. In the future, we could consider creating an align="stretch" if we wanted to enable this, but for now, let's just go with the two toolbars.

Example App:
Screenshot 2025-12-10 at 3 42 39 PM

Code
library(shiny)
library(bslib)

ui <- page_fillable(
  h2("Toolbar Divider Examples"),

  layout_columns(
    # Example 1: Divider and gap widths
    card(
      card_header(
        "Dividers (Default and Custom Width)",
        toolbar(
          toolbar_input_button(
            id = "btn1",
            label = "Home",
            icon = icon("home")
          ),
          toolbar_divider(), # Default divider
          toolbar_input_button(
            id = "btn2",
            label = "Settings",
            icon = icon("gear")
          ),
          toolbar_divider(gap = "4rem"), # Custom gap
          toolbar_input_button(
            id = "btn3",
            label = "Notifications",
            icon = icon("bell"),
          ),
          toolbar_divider(width = "4px"), # Custom divider width
          toolbar_input_button(
            id = "btn4",
            label = "Profile",
            icon = icon("user")
          ),
          # Custom divider width and gap
          toolbar_divider(width = "4px", gap = "4rem")
        )
      ),
      pre(code(
        "toolbar(
          toolbar_input_button('btn1', 'Home', icon('home')),
          toolbar_divider(), # Default divider
          toolbar_input_button('btn2', 'Settings', icon('gear')),
          toolbar_divider(gap = '4rem'), # Custom gap
          toolbar_input_button('btn3', 'Notifications', icon('bell')),
          toolbar_divider(width = '4px'), # Custom divider width
          toolbar_input_button('btn4', 'Profile', icon('user')),
          # Custom divider width and gap
          toolbar_divider(width = '4px', gap = '4rem')
        )"
      )),
    ),

    # Example 2: And now in a footer
    card(
      card_header(
        "All the excitement is in the footer",
      ),
      pre(code(
        "toolbar(
          toolbar_input_button('btn1f', 'Home', icon('home')),
          toolbar_divider(),
          toolbar_input_button('btn2f', 'Settings', icon('gear')),
          toolbar_divider(gap = '4rem'),
          toolbar_input_button('btn3f', 'Notifications', icon('bell')),
          toolbar_divider(width = '4px'),
          toolbar_input_button('btn4f', 'Profile', icon('user')),
          toolbar_divider(width = '4px', gap = '4rem')
)"
      )),
      card_footer(
        toolbar(
          toolbar_input_button(
            id = "btn1f",
            label = "Home",
            icon = icon("home")
          ),
          toolbar_divider(), # Default divider
          toolbar_input_button(
            id = "btn2f",
            label = "Settings",
            icon = icon("gear")
          ),
          toolbar_divider(gap = "4rem"), # Custom gap
          toolbar_input_button(
            id = "btn3f",
            label = "Notifications",
            icon = icon("bell")
          ),
          toolbar_divider(width = "4px"), # Custom divider width
          toolbar_input_button(
            id = "btn4f",
            label = "Profile",
            icon = icon("user")
          ),
          # Custom divider width and gap
          toolbar_divider(width = "4px", gap = "4rem")
        )
      )
    ),
  ),

  # Example 3: Split toolbars and gap spacing
  card(
    card_header(
      toolbar(
        align = "left",
        toolbar_input_button(
          id = "add",
          label = "Add",
          icon = icon("plus"),
        ),
        toolbar_divider(),
        toolbar_input_button(
          id = "remove",
          label = "Remove",
          icon = icon("minus"),
        )
      ),
      toolbar(
        align = "right",
        toolbar_input_button(id = "save", label = "Save", icon = icon("save")),
        toolbar_divider(width = "0px", gap = "2rem"),
        toolbar_input_button(
          id = "edit",
          label = "Edit",
          icon = icon("pencil")
        ),
        toolbar_divider(width = "0px", gap = "2rem"),
        toolbar_input_button(
          id = "delete",
          label = "Delete",
          icon = icon("trash")
        )
      )
    ),
    p("This example shows split toolbars with gap spacing between buttons."),
    pre(code(
      "toolbar(
        align = 'right',
        gap = '0.5rem',
        toolbar_input_button(id = 'save', label = 'Save', icon = icon('save')),
        toolbar_divider(width = '0px', gap = '2rem'),
        toolbar_input_button(id = 'edit', label = 'Edit', icon = icon('pencil')),
        toolbar_divider(width = '0px', gap = '2rem'),
        toolbar_input_button(id = 'delete', label = 'Delete', icon = icon('trash'))
      )"
    ))
  )
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Remaining To-Do:

  • Check unit test coverage
  • Add an entry to NEWS.md concisely describing what you changed.

commit c9afed1
Author: E Nelson <[email protected]>
Date:   Fri Dec 5 17:15:42 2025 -0500

    Updates to function signature

commit a475b8e
Author: E Nelson <[email protected]>
Date:   Fri Dec 5 14:54:30 2025 -0500

    Update name

commit f6a559f
Merge: d08117e 342ea78
Author: E Nelson <[email protected]>
Date:   Fri Dec 5 12:38:40 2025 -0500

    Merge branch 'feat/toolbar-spacer' of https://github.com/rstudio/bslib into feat/toolbar-spacer

commit d08117e
Author: E Nelson <[email protected]>
Date:   Fri Dec 5 12:37:41 2025 -0500

    Cleanup

commit 20efc97
Author: E Nelson <[email protected]>
Date:   Wed Nov 26 11:05:26 2025 -0500

    Start of a spacer

commit 06ede8a
Author: E Nelson <[email protected]>
Date:   Fri Dec 5 10:04:01 2025 -0500

    Update comment

commit edd40c5
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 23:01:24 2025 -0500

    Syntax change to reflect this is helpful regardless of if show_label is False

commit 6fc2aff
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 18:02:22 2025 -0500

    Update comments

commit 75c308a
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 17:57:28 2025 -0500

    Fixing private seed

commit 7da07ad
Merge: 5a17493 a56c081
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 17:24:49 2025 -0500

    Merge branch 'feature/add-buttons' of https://github.com/rstudio/bslib into feature/add-buttons

commit 5a17493
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 17:24:46 2025 -0500

    Update scss and minor polish

commit a56c081
Author: E Nelson <[email protected]>
Date:   Thu Dec 4 17:23:18 2025 -0500

    Update btn type logic

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit d0320ee
Author: E Nelson <[email protected]>
Date:   Wed Dec 3 16:39:06 2025 -0500

    Updates to labels

commit b074585
Author: E Nelson <[email protected]>
Date:   Wed Dec 3 10:25:53 2025 -0500

    Updated label

commit 691edba
Author: E Nelson <[email protected]>
Date:   Wed Dec 3 09:33:25 2025 -0500

    Remove aria labels from icons when they're in labels

commit f902a26
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 18:55:30 2025 -0500

    Updates - pending final validation

commit a00ca8c
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 18:37:31 2025 -0500

    Update tooltip wording

commit f85fb88
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 18:35:01 2025 -0500

    Updated button type determination

commit 7db177c
Merge: 704bfad e69b102
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 18:26:29 2025 -0500

    Merge branch 'feature/add-buttons' of https://github.com/rstudio/bslib into feature/add-buttons

commit 704bfad
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 18:26:27 2025 -0500

    Update toolbar.R

commit e69b102
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 17:11:08 2025 -0500

    Update R/toolbar.R

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit ebdade5
Author: E Nelson <[email protected]>
Date:   Tue Dec 2 14:39:09 2025 -0500

    Update based on comments

commit 5caa62d
Author: E Nelson <[email protected]>
Date:   Mon Dec 1 17:09:17 2025 -0500

    Make the buttons just a little bit smaller

commit 270262b
Author: E Nelson <[email protected]>
Date:   Mon Dec 1 17:05:17 2025 -0500

    Update padding

commit e40b9e7
Author: E Nelson <[email protected]>
Date:   Mon Dec 1 16:33:28 2025 -0500

    Updated function signature for buttons, updated scss for showing/hiding labels

commit 8159db8
Author: E Nelson <[email protected]>
Date:   Mon Dec 1 09:29:58 2025 -0500

    Update DESCRIPTION

commit 342ea78
Author: E Nelson <[email protected]>
Date:   Wed Nov 26 11:05:26 2025 -0500

    Start of a spacer

commit b8d66d5
Author: E Nelson <[email protected]>
Date:   Mon Nov 24 10:02:59 2025 -0500

    Updating with edits based on comments

commit 5531572
Author: E Nelson <[email protected]>
Date:   Fri Nov 21 09:08:39 2025 -0500

    Apply suggestions from code review

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit 85bad5e
Merge: 5ed4321 16acb76
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:50:12 2025 -0500

    Merge branch 'feature/add-buttons' of https://github.com/rstudio/bslib into feature/add-buttons

commit 5ed4321
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:49:50 2025 -0500

    Removing accidental legacy addition

commit 16acb76
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:46:34 2025 -0500

    Fixing diff

commit 37b9855
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:44:09 2025 -0500

    Clean up scss

commit c5d9e38
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:27:44 2025 -0500

    Slim down icon button formatting

commit e6fac9a
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:17:18 2025 -0500

    Fixing diff

commit 25c6027
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 13:10:39 2025 -0500

    Update card.scss

commit cc601fb
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 12:47:35 2025 -0500

    Fix tests

commit cd2a746
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 12:38:42 2025 -0500

    removing comment

commit c5f3dd6
Merge: b49322b 06177d6
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 12:37:07 2025 -0500

    Merge branch 'feature/add-buttons' of https://github.com/rstudio/bslib into feature/add-buttons

commit b49322b
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 12:37:03 2025 -0500

    Add back deleted file

commit 06177d6
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 12:35:34 2025 -0500

    Update header format in bs-theme-preset-builtin.md

commit fa866ba
Author: E Nelson <[email protected]>
Date:   Thu Nov 20 12:35:16 2025 -0500

    Update headings in bs-theme-preset.md

commit 8f3ab2d
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 12:24:56 2025 -0500

    Updating tests

commit a6250a6
Merge: cf585de 769a8fd
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 12:00:11 2025 -0500

    Updating tests

commit cf585de
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 20 09:56:50 2025 -0500

    Updated footer, updated gap

commit 3ce0b20
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 19 12:28:09 2025 -0500

    Updated card header and font sizing

commit 0c0f895
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 19 12:15:40 2025 -0500

    Fixed button sizing, changing to also incorperate label+icon

commit 652a061
Merge: 78372c1 0757592
Author: Liz Nelson <[email protected]>
Date:   Tue Nov 18 09:41:57 2025 -0500

    Merging in toolbar/epic

commit 78372c1
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 11:04:49 2025 -0500

    Reformat spacing

commit ef468d1
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 11:02:11 2025 -0500

    Updating button spacing

commit d69e3e8
Merge: 180319a df309bf
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 09:59:36 2025 -0500

    Merge branch 'feat/toolbar-container' into feature/add-buttons

commit df309bf
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 09:44:38 2025 -0500

    Updating footer, updating tests

commit 88f00d8
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 09:11:18 2025 -0500

    Docs changes

commit 6a3ccfe
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 09:10:31 2025 -0500

    Adding footer back

commit 899b644
Author: Liz Nelson <[email protected]>
Date:   Fri Nov 14 09:08:05 2025 -0500

    minor formatting changes

commit f898670
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 13 21:59:50 2025 -0500

    Updated code

commit 0340d21
Merge: 478f5e1 86ca69f
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 13 12:40:29 2025 -0500

    Merge remote-tracking branch 'origin/main' into feat/toolbar-container

commit 478f5e1
Merge: e6e9d88 7ba82cb
Author: Liz Nelson <[email protected]>
Date:   Thu Nov 13 12:37:16 2025 -0500

    Merge remote-tracking branch 'origin/main' into feat/toolbar-container

commit 180319a
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 12 09:48:10 2025 -0500

    Added disabled option

commit 626af55
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 12 09:09:44 2025 -0500

    Adding input buttons

commit e6e9d88
Author: E Nelson <[email protected]>
Date:   Wed Nov 5 17:15:28 2025 -0500

    Update inst/components/scss/toolbar.scss

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit 0afabf4
Author: E Nelson <[email protected]>
Date:   Wed Nov 5 17:15:21 2025 -0500

    Update inst/components/scss/toolbar.scss

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit a55d03f
Author: E Nelson <[email protected]>
Date:   Wed Nov 5 17:10:34 2025 -0500

    Update inst/components/scss/toolbar.scss

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit 0836374
Author: E Nelson <[email protected]>
Date:   Wed Nov 5 17:10:27 2025 -0500

    Update R/toolbar.R

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit d2eb240
Merge: b23fc17 c2289a3
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 5 13:57:37 2025 -0500

    Merge branch 'feat/toolbar-container' of https://github.com/rstudio/bslib into feat/toolbar-container

commit b23fc17
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 5 13:52:58 2025 -0500

    updates to dots

commit c2289a3
Author: E Nelson <[email protected]>
Date:   Wed Nov 5 13:52:14 2025 -0500

    Fix dots in toolbar function

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit 5fd9254
Author: Liz Nelson <[email protected]>
Date:   Wed Nov 5 13:31:58 2025 -0500

    Update to toolbar testing

commit 1abed04
Author: Liz Nelson <[email protected]>
Date:   Tue Nov 4 22:57:08 2025 -0500

    Adding a few comments

commit 3f8b630
Author: Liz Nelson <[email protected]>
Date:   Tue Nov 4 22:40:27 2025 -0500

    Adding snaps

commit c7d70e6
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 16:49:01 2025 -0500

    Removing example:

commit 6389307
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 16:29:12 2025 -0500

    Updated news

commit 8f6d6f1
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 16:09:43 2025 -0500

    Added tests

commit 04bd68b
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 11:31:31 2025 -0500

    Minor updates

commit ed1a07e
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 11:15:13 2025 -0500

    Updates

commit 374f757
Author: Liz Nelson <[email protected]>
Date:   Mon Nov 3 11:02:45 2025 -0500

    Initial toolbar container
@elnelson575 elnelson575 changed the base branch from main to feat/toolbar-epic December 8, 2025 14:21
@elnelson575 elnelson575 marked this pull request as ready for review December 8, 2025 16:59
@elnelson575 elnelson575 requested a review from gadenbuie December 8, 2025 16:59
Copy link
Member

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

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

Looking good! A few minor comments about CSS variables and how we can use them, plus one big "maybe we should rename this function" style question to consider.

Copy link
Member

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

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

Looks great, just one more tiny update to use the same pattern for the divider color that we're already using for height and width.

I could see an argument for letting users set the divider color in toolbar_divider() -- e.g. if you have a fixed header color and want a specific divider color to work with that color -- but I'll let you decide if it's worth adding.

Feel free to merge when you're ready!

@elnelson575 elnelson575 merged commit 6cf620b into feat/toolbar-epic Dec 12, 2025
1 check passed
@elnelson575 elnelson575 deleted the feat/add-toolbar-spacer branch December 12, 2025 22:23
elnelson575 added a commit that referenced this pull request Dec 18, 2025
commit a37f90a
Author: E Nelson <[email protected]>
Date:   Wed Dec 17 14:24:38 2025 -0500

    feat: Add toolbar input select (#1260)

    Adding an input select optimized for use in toolbars.

    Co-authored-by: Garrick Aden-Buie <[email protected]>

commit 6cf620b
Author: E Nelson <[email protected]>
Date:   Fri Dec 12 17:23:10 2025 -0500

    feat: Add toolbar spacer (#1265)

    Adding a dividing line and space option to allow for more customized toolbar spacing.

    Co-authored-by: Garrick Aden-Buie <[email protected]>
    Co-authored-by: elnelson575 <[email protected]>
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: Add toolbar spacer

2 participants