You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello Phoenix Team 👋
This is a minor issue with the input component from the core_components.ex file (used in phx.gen.live)
A margin top is added by default for the spacing between the label and the input.
However it is not removed if a label is not provided. Which causes alignment issue when combining the input component with other elements on our UI.
Of course this can be fixed easily by modifying the core_component in my project but I guess this can be a quick win improvement to update the core_components.ex directly in Phoenix. I can propose a PR if you think it's worth making a small update 🙏
Expected behavior
Avoid adding a margin to the input if a label is not provided to the input component.
Fix: one idea could be to put the mt-2 class behind a condition, e.g:
NTurchi
changed the title
Remove margin top on the input component if no label is provided in core_component.ex
Remove margin top on the input component if no label is provided in core_components.exJun 4, 2024
Not sure whether the error should have the same margin as the label and textarea have between each other. If that‘s the case, you could make use of the gap classes that work with either flex or grid.
Here, you could slap some Tailwind classes onto the surrounding div and the spacing would „just“ happen between the different children, no matter if a specific one is present or not: <div class="flex flex-col gap-2">… 😊
EDIT: this article lays out in more detail why avoiding margin is overall better in composition of components: https://mxstbr.com/thoughts/margin
Environment
1.7.12
Actual behavior
Hello Phoenix Team 👋
This is a minor issue with the input component from the
core_components.ex
file (used inphx.gen.live
)A margin top is added by default for the spacing between the label and the input.
phoenix/priv/templates/phx.gen.live/core_components.ex
Lines 357 to 361 in 69685f7
However it is not removed if a label is not provided. Which causes alignment issue when combining the input component with other elements on our UI.
Of course this can be fixed easily by modifying the
core_component
in my project but I guess this can be a quick win improvement to update thecore_components.ex
directly in Phoenix. I can propose a PR if you think it's worth making a small update 🙏Expected behavior
Avoid adding a margin to the input if a
label
is not provided to the input component.Fix: one idea could be to put the
mt-2
class behind a condition, e.g:The text was updated successfully, but these errors were encountered: