Modal
DModal wraps the native <dialog> element. A tiny optional JS module
only calls showModal()/close() and reports native closes back to
@bind-Open. Escape and backdrop clicks close the dialog natively and
update the bound value. Under pure static SSR (no JS) the dialog simply stays closed.
Basic modal— Open it from code, close it with Escape or the backdrop
<DButton Color="DaisyColor.Primary" @onclick="() => _basicOpen = true">Open modal</DButton>
<DModal @bind-Open="_basicOpen" Title="Are you sure?">
<p>This is a native <code><dialog></code> styled with daisyUI. Try pressing
<kbd class="kbd kbd-xs">Esc</kbd> or clicking outside the box.</p>
<div class="modal-action">
<DButton @onclick="() => _basicOpen = false">Cancel</DButton>
<DButton Color="DaisyColor.Primary" @onclick="() => _basicOpen = false">Confirm</DButton>
</div>
</DModal>
@code {
private bool _basicOpen;
}Custom title slot— TitleContent is a RenderFragment — anything goes in the header
<DButton Color="DaisyColor.Secondary" @onclick="() => _customOpen = true">Open custom modal</DButton>
<DModal @bind-Open="_customOpen" BoxClass="max-w-md">
<TitleContent>
<div class="mb-3 flex items-center gap-2">
<DBadge Color="DaisyColor.Accent">new</DBadge>
<h3 class="text-lg font-bold">Custom title slot</h3>
</div>
</TitleContent>
<ChildContent>
<p>TitleContent is a RenderFragment, so you can put anything in the header.</p>
<div class="modal-action">
<DButton Color="DaisyColor.Primary" @onclick="() => _customOpen = false">Nice</DButton>
</div>
</ChildContent>
</DModal>
@code {
private bool _customOpen;
}
Basic modal currently open: False · custom: False
API
DModal
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Open | bool | False | @bind-Open | Whether the modal is open. Supports two-way binding (@bind-Open). |
| Title | string | — | — | Simple text title rendered inside the modal box. |
| TitleContent | RenderFragment | — | — | Custom title markup; takes precedence over Title . |
| ChildContent | RenderFragment | — | — | Modal body content. Put action buttons in a <div class="modal-action">. |
| BoxClass | string | — | — | Extra classes for the inner .modal-box element. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DButton
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Type | string | button | — | The native type attribute: button , submit or reset . |
| Color | DaisyColor | Default | — | Contextual color (e.g. btn-primary , btn-ghost ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. btn-outline , btn-soft ); Default emits no class. DefaultOutlineDashSoftLink |
| Size | DaisySize | Medium | — | Size (e.g. btn-xs , btn-lg ); Medium emits no class. ExtraSmallSmallMediumLargeExtraLarge |
| Disabled | bool | False | — | Disables the button (native disabled ). |
| IconStart | DaisyIcon | — | — | Icon rendered before the button content (daisy's btn gap handles spacing). |
| IconEnd | DaisyIcon | — | — | Icon rendered after the button content. |
| IconSize | DaisySize? | — | — | Icon size; defaults to the button Size when null . ExtraSmallSmallMediumLargeExtraLarge |
| Shape | DaisyButtonShape | Default | — | btn-square / btn-circle — use with an icon and no text for icon-only buttons. DefaultSquareCircle |
| Wide | bool | False | — | btn-wide : widens the button to width:100% of its container, capped at 16rem . When both Wide and Block are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity) and the button fills its container, still capped at 16rem by btn-wide 's max-width . |
| Block | bool | False | — | btn-block : the button fills the full width of its container ( width:100% ). When both Block and Wide are set, btn-block wins on width (it is declared later in daisyUI's cascade at equal specificity). |
| ChildContent | RenderFragment | — | — | The button's inner text and content. |
| OnClick | EventCallback<MouseEventArgs> | — | — | Invoked when the button is clicked. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DBadge
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Color | DaisyColor | Default | — | Contextual color (e.g. badge-primary , badge-ghost ); Default emits no class. DefaultPrimarySecondaryAccentInfoSuccessWarningErrorGhostNeutral |
| Variant | DaisyVariant | Default | — | Style variant (e.g. badge-outline ); Default emits no class. DefaultOutlineDashSoftLink |
| Size | DaisySize | Medium | — | Size (e.g. badge-xs , badge-lg ); Medium emits no class. ExtraSmallSmallMediumLargeExtraLarge |
| Shape | DaisyShape | Default | — | Corner shape ( badge-circle , badge-rect ); Default emits no class. DefaultCircleRect |
| IconStart | DaisyIcon | — | — | Icon rendered before the badge content. |
| IconEnd | DaisyIcon | — | — | Icon rendered after the badge content. |
| IconSize | DaisySize? | — | — | Icon size; defaults to the badge Size when null . ExtraSmallSmallMediumLargeExtraLarge |
| ChildContent | RenderFragment | — | — | The badge's inner text and content. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |