Provide breakpoints according to parent instead of viewport #8293
rhythmbhiwani
started this conversation in
Ideas
Replies: 3 comments 8 replies
-
It's way too early to implement container queries into Tailwind at this point, in my opinion. As much as I want the same thing as you, I would still stick to traditional media queries for now. |
Beta Was this translation helpful? Give feedback.
3 replies
-
Looks like this is fully supported across desktop browsers now! Time to revisit? |
Beta Was this translation helpful? Give feedback.
3 replies
-
Just in case anyone else is looking for a solution - https://github.com/tailwindlabs/tailwindcss-container-queries |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
the breakpoints we currently use
sm:
md:
etc. works with respect to the viewport width which is a very useful feature. But in some cases, width of a particular container is dependent on width of sibling containers which migth change (example, expending a menu sideways). Then if the sibling container width is increased, the main container width gets decreased.For a better UI design to handle UI based on the width available of the parent container would be much better to decide how to layout elements with respect to the available width of the parent. So we could assign a class to the parent container, and add some breakpoints to child elements which will react to the width of the element with parent class.
I'm not sure if this is possible just with css, or can be integrated in tailwind css, but would love to know more about it.
edit: Found this article on MDN about container query which is somewhat exactly I want but is in experimental stage. But I think it could be achieved using some javascript maybe.
Beta Was this translation helpful? Give feedback.
All reactions