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

Make Liveview's root divs transparent for layout purposes. #6052

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

derekkraan
Copy link

I suspect this PR might be a slightly hard sell, but I will do my best to motivate my reasons for proposing its inclusion.

LiveView generates non-optional wrapper divs. This presents challenges for using LiveViews in certain layouts. For example, if you want your LiveView to be a flex child, then your best course of action is to add container: {:div, style: "display: contents"} when rendering the LiveView. display: contents makes the element invisible for layout purposes, so the child of the wrapper div effectively replaces the wrapper div in the layout.

Another option is to make this the global default for your wrapper divs. This can be done in CSS with the following line:

[data-phx-root-id] { display: contents }

Adding this to an existing project might be tricky, because it can negate the impact of the :container option. But adding it at the beginning of a project seems without risk. And it is nice to have this in place from the beginning, because when you need it you will probably pull your hair out for a day before you figure out how to make the layout work that you want.

I think including this PR would be a nice developer experience improvement.

(h/t to @LostKobrakai and @tmjoen for helping me find this solution in Slack)

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

Successfully merging this pull request may close these issues.

2 participants