Native way to center button

New-UDButton -Text 'Message Box' -Style @{"margin" = "auto"; "display" = "block"} works to center a button. But is there a more Universalish way to do it? Like -Align "center" used on others.

Doesn’t really help you and it’s much the same (and actually, less native as it requires an external module from the UD marketplace), but just for information’s sake … New-UDStyle maybe?

New-UDStyle -Style '		
    margin: auto;
    display: block;
' -Content {
    New-UDButton -Id 'btnMessageBox' -Text "Message Box" -OnClick {
        Show-UDToast -Message "clicked"
    }
}

For UDStyle: https://marketplace.universaldashboard.io/Dashboard/UniversalDashboard.Style

And in your script: Import-Module ‘C:\ProgramData\PowerShellUniversal\Dashboard\Components\UniversalDashboard.Style\1.0.0\UniversalDashboard.Style.psm1’ (or your path to where the module is)

Your way actually seems quite concise. It depends on where you put the button, in UD 2.9 I think you can use -textalignment center on a new-udcard, although i’ve not tested this with the placement of buttons too.
I’ve been pretty much using new-udelement -tag div and then adding the styling to that to make things central aligned in modals etc, not the best way but your way seems cleaner.
Otherwise you could stick it on a new row and use new-udcolumn to offset it into the center.

Oh sweet, the div idea is great! Very reusable. I think I’ll go with that. Thanks!