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

Add helpers for @container queries #8265

Open
Zacqary opened this issue Jan 9, 2025 · 2 comments
Open

Add helpers for @container queries #8265

Zacqary opened this issue Jan 9, 2025 · 2 comments
Assignees

Comments

@Zacqary
Copy link
Contributor

Zacqary commented Jan 9, 2025

Is your feature request related to a problem? Please describe.
In Kibana, we're trying to implement designs for a form that can appear in the context of both a full page and inside a flyout. We want to design responsively for these two contexts, and make the flyout UI look almost identical to a breakpoint s full page UI.

EUI currently supports responsive design only for full-screen breakpoints. Applying the same design for both a small screen and a UI embedded within a flyout on a large screen requires the use of CSS @container queries in external SCSS files.

We can do this for now, but I'd prefer to have EUI dictate standard practices for doing this.

Describe the solution you'd like

  • Add a set of equivalent helpers like <EuiShowFor> and <EuiHideFor> which target containers instead of screen sizes
  • Add container-type: inline-size to outer wrappers for <EuiModal> and <EuiFlyout> to simplify responsive design within these contexts.
  • Possibly add container properties to other elements like <EuiPanel> or other EUI page components. This is probably more of an overall design question, to determine which parts of the UI should be containerized and which parts shouldn't.

Describe alternatives you've considered
We could continue specifying @container queries within SCSS files in Kibana, but that seems frowned upon and only as a last resort

Desired timeline
No rush, really. Workarounds exist for the time being.

@tkajtoch
Copy link
Member

Hi @Zacqary! Thanks for reaching out and proposing solutions!
I completely agree; we should add support for container queries to EUI. We might start small and update our RWD helpers first, but accepting additional layout control props in EUI components is on our radar, and we will hopefully add them someday :D

I'll make sure to plan the work needed and will keep you updated to make sure our solutions match your needs.

@tkajtoch tkajtoch self-assigned this Jan 10, 2025
@Zacqary
Copy link
Contributor Author

Zacqary commented Jan 10, 2025

In the work I've been doing I noticed there isn't currently an easy way in Javascript to determine which container an element is in, which could add some difficulty in adding equivalent ShowFor/HideFor components.

w3c/csswg-drafts#6205 for an element.matchContainer API is currently proposed but unresolved. Firefox and Chrome are working on implementing this but it's not yet finished.

A workaround until then could be:

  • Render an invisible helper element with a CSS class that responds to @container queries, with something like display: none; visibility: {visible or hidden depending on container size}
  • Use JS to determine if this helper element has visibility: visible or visibility: hidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants