F
Filament16mo ago
Oddman

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
HerrChris
HerrChris16mo ago
VerticalAlignment may help too
Oddman
OddmanOP16mo ago
This isn't for actions - and those methods aren't available on form elements, either. Trying to vertically align a toggle.
Solution
awcodes
awcodes16mo 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
awcodes16mo ago
The recommended approach for things like toggles is to have them on their own row.
Oddman
OddmanOP16mo ago
Ah okay. Cheers!

Did you find this page helpful?