I'm trying to create a row of three RadzenButtons that are horizontally aligned, where all buttons have the same width as the widest button. I prefer to avoid using JavaScript if possible. Here are my specific requirements:
The buttons should be placed side by side horizontally.
All buttons should have the same width.
The width of all buttons should be equal to the width of the button with the longest text.
The group of buttons should not extend beyond the necessary space (i.e., they should not occupy the full width of their container if it's not needed).
The solution should preferably use only CSS and/or Blazor C# code, without relying on JavaScript.
I've tried various CSS approaches using Flexbox, but I haven't been able to achieve the desired result. The buttons either end up with different widths or occupy the entire available space.
Here's a basic example of what I'm working with:
<div class="button-container">
<RadzenButton Text="Button 1" />
<RadzenButton Text="Button with long text" />
<RadzenButton Text="B3" />
</div>
Could you please provide guidance on how to implement this using Radzen components in Blazor, preferably with a CSS-only solution or a combination of CSS and Blazor C# code? If a JavaScript-free solution is not possible, please explain why and suggest the minimal JavaScript required.
I don't think that's possible. Unlike the example I shared in your other post where the DataGrid column will fit to the longest content nothing will force your buttons to have the width of the biggest button aligned horizontally.
I already tried this workaround, but RadzenStack fill all horizontal available space, making big buttons.
How can I limit RadzenStack width to button content?
Yes, grid layout is an option. Consider using class="rz-mx-auto rz-display-grid" instead as these are available with Radzen and do not require Bootstrap.