How do I align a form input vertically centered within a grid?

As per title, I have a form element that should be aligned center, but because it's not, looks quite odd.
Solution:
Best thing you can do is use ->extraAttributes() to add a margin top to the component. There’s no feasible way to do this through php because aligning center will not always work if you have descriptions or errors.
Jump to solution
6 Replies
Chris
Chris2y ago
VerticalAlignment may help too
Oddman
OddmanOP2y ago
This isn't for actions - and those methods aren't available on form elements, either. Trying to vertically align a toggle.
Solution
awcodes
awcodes2y ago
Best thing you can do is use ->extraAttributes() to add a margin top to the component. There’s no feasible way to do this through php because aligning center will not always work if you have descriptions or errors.
awcodes
awcodes2y ago
The recommended approach for things like toggles is to have them on their own row.
Oddman
OddmanOP2y ago
Ah okay. Cheers!

Did you find this page helpful?