DButton
Every card below shows a live demo in the Preview tab and the exact Razor code that produced it in the Razor tab — switch tabs to compare, and use the Copy button to take the snippet with you.
Colors
<DButton>Default</DButton>
<DButton Color="DaisyColor.Primary">Primary</DButton>
<DButton Color="DaisyColor.Secondary">Secondary</DButton>
<DButton Color="DaisyColor.Accent">Accent</DButton>
<DButton Color="DaisyColor.Info">Info</DButton>
<DButton Color="DaisyColor.Success">Success</DButton>
<DButton Color="DaisyColor.Warning">Warning</DButton>
<DButton Color="DaisyColor.Error">Error</DButton>Variants
<DButton Color="DaisyColor.Primary">Solid</DButton>
<DButton Color="DaisyColor.Primary" Variant="DaisyVariant.Outline">Outline</DButton>
<DButton Color="DaisyColor.Primary" Variant="DaisyVariant.Dash">Dash</DButton>
<DButton Color="DaisyColor.Primary" Variant="DaisyVariant.Soft">Soft</DButton>
<DButton Color="DaisyColor.Primary" Variant="DaisyVariant.Link">Link</DButton>Sizes
<DButton Color="DaisyColor.Secondary" Size="DaisySize.ExtraSmall">Extra small</DButton>
<DButton Color="DaisyColor.Secondary" Size="DaisySize.Small">Small</DButton>
<DButton Color="DaisyColor.Secondary">Medium</DButton>
<DButton Color="DaisyColor.Secondary" Size="DaisySize.Large">Large</DButton>
<DButton Color="DaisyColor.Secondary" Size="DaisySize.ExtraLarge">Extra large</DButton>Width— Wide (btn-wide: full container width capped at 16rem) and Block (btn-block: full container width). When both are set, btn-block wins on width.
<DButton Color="DaisyColor.Primary">Normal</DButton>
<DButton Color="DaisyColor.Primary" Wide="true">Wide</DButton>
<DButton Color="DaisyColor.Secondary" Block="true">Block — fills the container</DButton>States
<DButton Disabled="true">Disabled</DButton>Button group (DButtonGroup)
<DButtonGroup>
<DButton Color="DaisyColor.Primary">Left</DButton>
<DButton Color="DaisyColor.Primary">Middle</DButton>
<DButton Color="DaisyColor.Primary">Right</DButton>
</DButtonGroup>
<DButtonGroup Vertical="true">
<DButton Color="DaisyColor.Secondary">Top</DButton>
<DButton Color="DaisyColor.Secondary">Bottom</DButton>
</DButtonGroup>With icons— IconStart / IconEnd take a DaisyIcon (built-in or CDN); icon size follows the button Size unless IconSize is set.
<DButton Color="DaisyColor.Warning" IconStart="@DaisyIcons.Warning">Warning</DButton>
<DButton Color="DaisyColor.Error" IconStart="@DaisyIcons.Trash">Delete</DButton>
<DButton Color="DaisyColor.Success" IconStart="@DaisyIcons.Check">Save</DButton>
<DButton Color="DaisyColor.Primary" IconEnd="@DaisyIcon.FromUrl("arrow-right", "https://api.iconify.design/lucide/arrow-right.svg")">Next</DButton>
<DButton Size="DaisySize.Small" IconStart="@DaisyIcons.Plus">Small + xs icon</DButton>
<DButton Size="DaisySize.Small" IconStart="@DaisyIcons.Plus" IconSize="DaisySize.Large">Small + lg icon</DButton>
<DButton Shape="DaisyButtonShape.Square" IconStart="@DaisyIcons.Search" aria-label="Search" />
<DButton Color="DaisyColor.Primary" Shape="DaisyButtonShape.Circle" IconStart="@DaisyIcons.Plus" aria-label="Add" />
<DButton Color="DaisyColor.Error" Variant="DaisyVariant.Soft" Shape="DaisyButtonShape.Circle" IconStart="@DaisyIcons.Trash" aria-label="Delete" />
<DButton Color="DaisyColor.Info" Variant="DaisyVariant.Outline" Shape="DaisyButtonShape.Square" Size="DaisySize.Large" IconStart="@DaisyIcon.FromUrl("rocket", "https://api.iconify.design/lucide/rocket.svg")" aria-label="Launch" />Click counter
n/a
<DButton Color="DaisyColor.Primary" OnClick="IncrementAsync">Click me</DButton>
<span class="badge badge-lg badge-primary gap-1">@(IsInteractive ? Clicks : "n/a")</span>
@code {
private int Clicks { get; set; }
private bool IsInteractive { get; set; }
private Task IncrementAsync()
{
Clicks++;
return Task.CompletedTask;
}
protected override void OnAfterRender(bool firstRender)
{
if (firstRender && !IsInteractive)
{
IsInteractive = true;
StateHasChanged();
}
}
}API
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. |
DButtonGroup
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Vertical | bool | False | — | Stacks the grouped buttons vertically ( join-vertical ). |
| ChildContent | RenderFragment | — | — | The grouped buttons. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |