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 hardcoded breakpoint values with CSS custom properties for front-end styles #35808

Closed
cr0ybot opened this issue Oct 20, 2021 · 3 comments
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues.

Comments

@cr0ybot
Copy link
Contributor

cr0ybot commented Oct 20, 2021

What problem does this address?

The standard 600px hardcoded breakpoint for the core/columns block poses a not-insignificant problem for theme developers. We either have to work with that specific breakpoint, integrating it with our design system, completely remove core Gutenberg front-end styles, or otherwise hack around the CSS which no-one enjoys doing.

What is your proposed solution?

Issue #16911 has suggested using ems and/or providing a hook to change breakpoints, but I believe this is shortsighted. With the recent move to embracing CSS custom properties (CSS variables), I propose that the breakpoints used in front-end CSS be converted to custom properties.

If the front-end breakpoints were set as custom properties, it would not only be easy to override simply within a theme's styles, but it would even provide for an opportunity to alter that breakpoint based on context.

I realize this is a break with the effort to standardize breakpoints in the base-styles package. I think those values can still serve as default values, but the front-end styles should be more customizable without having to resort to bad hacks and workarounds.

Edit: This could also open the door for changing breakpoint values directly within theme.json.

@skorasaurus skorasaurus added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Oct 20, 2021
@skorasaurus
Copy link
Member

related previous discussion (#19460)

I too think this should be revisited.

@cr0ybot cr0ybot changed the title Replace hardcoded breakpoint values with CSS custom properties Replace hardcoded breakpoint values with CSS custom properties for front-end styles Oct 20, 2021
@cr0ybot
Copy link
Contributor Author

cr0ybot commented Oct 20, 2021

This may have been naive to propose without testing that this could work first. Apparently, CSS custom properties do not work in media queries (yet): https://bholmes.dev/blog/alternative-to-css-variable-media-queries/

The alternative might be to utilize container queries when those are ready, and drop global screen size media queries in front-end styles altogether.

@cr0ybot
Copy link
Contributor Author

cr0ybot commented Oct 21, 2021

I'm closing this issue since the proposed solution is just not possible, but I'd really like to determine if there is a way for theme developers to alter that pesky 600px breakpoint. I could edit it with a new proposal but I think I'd like it to stay here for anyone else who had a similar thought. We'll need a different solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues.
Projects
None yet
Development

No branches or pull requests

2 participants