Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace .btn-block with utilities #31995

Merged
merged 2 commits into from Nov 9, 2020
Merged

Replace .btn-block with utilities #31995

merged 2 commits into from Nov 9, 2020

Conversation

mdo
Copy link
Member

@mdo mdo commented Oct 27, 2020

This now replaces .btn-block with .d-grid and .gap-* utilities. This enables responsive behaviors for the former .btn-block, while also making it much more customizable for responsive behaviors and more.


Moves .btn-block from a .btn modifier class to a parent wrapper, allowing us to more easily manipulate a group of buttons. For folks who want an individual button to be "block level", adding w-100 basically accomplishes that. This now makes it possible for a group of buttons to start off stacked and then go inline once a breakpoint is reached.

Unlike most of our responsive classes, these are built with media-breakpoint-down(), so they use max-width instead of min-width in their media queries. Anecdotally, this fits the pattern of responsiveness for a group of buttons—you stack them on narrow viewports and expand them into a single line when there's available space.

I think I need to take another pass at the copy in the docs still. Beyond that, I'm also considering changing this to .btn-stack or something similar. If we did that, we might be able to backport this to v4 as a new feature in v4.6.0. Thoughts?

Preview: https://deploy-preview-31995--twbs-bootstrap.netlify.app/docs/5.0/components/buttons/#block-buttons

@mdo mdo requested a review from a team as a code owner October 27, 2020 17:29
@mdo mdo mentioned this pull request Oct 27, 2020
@mdo mdo added this to Inbox in v5.0.0-alpha3 via automation Oct 28, 2020
@mdo mdo moved this from Inbox to Review in v5.0.0-alpha3 Oct 28, 2020
@voltaek
Copy link
Contributor

voltaek commented Oct 29, 2020

Is your intention with not applying any styling to the non-stacked buttons for utilities to get utilized for customization without having to fight built-in styling? For example, I could see wanting to always have the non-stacked buttons grow horizontally to fill their container (so whitespace is more consistent between stacked and not), but if we made that the default behavior and someone has a different idea for how they want the non-stacked buttons to work, then they'd have to use utilities to first fight that default behavior instead of just applying their own straight-away.

@MartijnCuppens
Copy link
Member

Not convinced of using this approach

  • Using CSS grid might be a little better instead of the + .btn approach, see https://codepen.io/MartijnCuppens/pen/JjKvxbV
  • Using .btn-block for a wrapper feels weird. In other BS components, the part after the dash indicates a modifier or a subcomponent while this is a wrapper.
  • The media-breakpoint-down implementation might also be a little confusing, since we use breakpoint modifiers in other components thee other way around.
  • I prefer to split layouting CSS from component CSS. Maybe we could have a look if we could add some flexibility to the grid PR which takes care of cases like these?

@mdo
Copy link
Member Author

mdo commented Nov 2, 2020

Do we leave this as custom CSS then, or provide helpers/utilities to enable those kind of layouts? See my comment at #32034 (comment) for something I've been thinking about since seeing that issue and another OSS project.

@mdo
Copy link
Member Author

mdo commented Nov 5, 2020

@MartijnCuppens Could we do something like this when #32066 ships? https://codepen.io/emdeoh/pen/zYBLbOM Wondering how to handle a .gap utility alongside the .g* utilities... just need a way to consume those CSS vars we have.

@MartijnCuppens
Copy link
Member

We can't combine the gap & gutter utilities (yet), since some browsers don't support flex gap yet (https://caniuse.com/flexbox-gap).

But we can indeed introduce new .gap-* utilities like this, I don't think we'll need additional CSS custom properties here: https://codepen.io/MartijnCuppens/pen/xxOawYK?editors=1100

@mdo mdo mentioned this pull request Nov 6, 2020
@mdo mdo changed the title Make .btn-block responsive Replace .btn-block with utilities Nov 9, 2020
@mdo
Copy link
Member Author

mdo commented Nov 9, 2020

@MartijnCuppens This is now completely revamped to use .d-grid and .gap classes, so no more .btn-block classes of any kind. Migration guide was updated, as were the button docs showing the examples.

v5.0.0-alpha3 automation moved this from Review to Approved Nov 9, 2020
@XhmikosR XhmikosR changed the title Replace .btn-block with utilities Replace .btn-block with utilities Nov 9, 2020
@XhmikosR XhmikosR merged commit fb3a57b into main Nov 9, 2020
v5.0.0-alpha3 automation moved this from Approved to Shipped Nov 9, 2020
@XhmikosR XhmikosR deleted the btn-block-responsive branch November 9, 2020 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
v5.0.0-alpha3
  
Shipped
Development

Successfully merging this pull request may close these issues.

None yet

4 participants