Skip to content

fix: ensure field labels render correctly in MudBlazor dialogs#88

Merged
phmatray merged 1 commit intomainfrom
fix/31-dialog-labels-not-showing
Feb 26, 2026
Merged

fix: ensure field labels render correctly in MudBlazor dialogs#88
phmatray merged 1 commit intomainfrom
fix/31-dialog-labels-not-showing

Conversation

@phmatray
Copy link
Owner

Summary

  • Adds ShrinkLabel="true" to all MudBlazor input components used by FormCraft, fixing label clipping when forms are rendered inside MudDialog
  • The root cause is a known MudBlazor issue (MudBlazor/MudBlazor#9497) where Margin.Dense + Variant.Outlined inside dialog content causes overflow:auto to clip the floating label
  • Setting ShrinkLabel=true forces labels to always render in the shrunk (above-border) position, avoiding the clipping

Changes

  • FormCraftComponent.razor.cs: Added ShrinkLabel=true to AddCommonFieldAttributes (the RenderTreeBuilder-based rendering path used by all standard field types)
  • MudBlazorTextFieldComponent.razor: Added ShrinkLabel="true"
  • MudBlazorNumericFieldComponent.razor: Added ShrinkLabel="true"
  • MudBlazorSelectFieldComponent.razor: Added ShrinkLabel="true"
  • MudBlazorDateTimeFieldComponent.razor: Added ShrinkLabel="true"
  • MudBlazorColorPickerComponent.razor: Added ShrinkLabel="true"

Components not affected (labels render differently, not as floating input labels):

  • MudBlazorBooleanFieldComponent (uses MudSwitch with inline label)
  • MudBlazorFileUploadFieldComponent (uses MudText above the upload area)
  • MudBlazorSliderComponent (uses MudText above the slider)
  • MudBlazorRatingComponent (uses MudText above the rating)

Testing

  • All 553 existing unit tests pass
  • Build succeeds with no new errors
  • Manual verification: render FormCraft form inside MudDialog and confirm labels are visible

Fixes #31

Add ShrinkLabel="true" to all MudBlazor input components (MudTextField,
MudNumericField, MudSelect, MudDatePicker, MudColorPicker) and to the
RenderTreeBuilder-based rendering path in FormCraftComponent.

The root cause is a known MudBlazor issue (MudBlazor/MudBlazor#9497)
where Margin.Dense + Variant.Outlined inside MudDialog causes the
DialogContent's overflow:auto to clip the floating label. Setting
ShrinkLabel=true forces the label to always render in the shrunk
position above the field border, avoiding the clipping.

Fixes #31
@phmatray phmatray merged commit c3615fd into main Feb 26, 2026
1 check passed
@phmatray phmatray deleted the fix/31-dialog-labels-not-showing branch February 26, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with the dialog labels

1 participant