Bootstrap v4 drops the .btn-group-justified
class, see https://github.com/twbs/bootstrap/issues/17631
How to justify the button for:
<div class="btn-group btn-group-justified" role="group" aria-label="Justified button group">
<a class="btn btn-primary" href="#" role="button">Left</a>
<a class="btn btn-primary" href="#" role="button">Middle</a>
<a class="btn btn-primary" href="#" role="button">Right</a>
</div>
Indeed the nav-justify class is missing. You can add it yourself based on TB3's code for now:
SCSS code
compiled CSS code
HTML
The above HTML code now will look like that shown in the figure beneath:
Handling borders
display: table-cell
), the borders between them are doubled. In regular button groups,margin-left: -1px
is used to stack the borders instead of removing them. However,margin
doesn't work withdisplay: table-cell
. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.Links acting as buttons
<a>
elements are used to act as buttons – triggering in-page functionality, rather than navigating to another document or section within the current page – they should also be given an appropriaterole="button"
.Dropdowns
Use the following HTML code for dropdown buttons:
The justified button group with dropdown button should look like that shown in the figure below:
With
<button>
elements<button>
elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to<button>
elements, but since we support button dropdowns, we can work around that.HTML
The above HTML code used to justified button groups with
<button>
elements should look like that shown in the figure beneath:For anyone finding this after Bootstrap 4 Beta was released...
Building on Bass Jobsen's great answer, here is the same functionality using flexbox instead of
display: table;
SCSS code
HTML
Please refer to Bass Jobsen's answer for more details on usage with dropdowns, HTML Links and more.
When using with
class="dropdown-menu"
with Bootstrap V4.0, based on Chris Baswell' solution above and Bootstrap Documentation: https://getbootstrap.com/docs/4.0/components/button-group/#nesting