Filter
DFilter + DFilterOption wrap daisyUI's
Filter a list— Pick a framework, then click anywhere else (blur) to watch the unchosen options collapse
Routes
blazor
Components
blazor
<DFilter @bind-Value="_framework" ResetLabel="All">
<DFilterOption Value="svelte" Label="Svelte" />
<DFilterOption Value="vue" Label="Vue" />
<DFilterOption Value="react" Label="React" />
<DFilterOption Value="blazor" Label="Blazor" />
</DFilter>
<div class="flex flex-wrap gap-3">
@foreach (var item in _items.Where(i => _framework is null || i.Framework == _framework))
{
<div class="card card-sm bg-base-200 w-44">
<div class="card-body p-4 gap-1">
<span class="font-semibold">@item.Name</span>
<span class="badge badge-sm badge-primary">@item.Framework</span>
</div>
</div>
}
</div>
@code {
private string? _framework = "blazor";
private record Item(string Name, string Framework);
private readonly Item[] _items =
[
new("Routes", "blazor"),
new("Signals", "svelte"),
new("Reactivity", "vue"),
new("Server comps", "react"),
new("Components", "blazor"),
new("Runes", "svelte"),
];
}No reset button— ShowReset="false" — no CSS ×, so clearing is app-driven
Selected: (none)
<DFilter @key="_size" ShowReset="false" @bind-Value="_size">
<DFilterOption Value="sm" Label="Small" />
<DFilterOption Value="md" Label="Medium" />
<DFilterOption Value="lg" Label="Large" />
</DFilter>
<p class="mt-4 text-sm opacity-70">Selected: <code>@(_size ?? "(none)")</code></p>
<DButton Color="DaisyColor.Primary" Variant="DaisyVariant.Outline" Class="mt-2"
Disabled="@(_size is null)" onclick="@(() => _size = null)">Clear size</DButton>
@code {
private string? _size;
}Tips
- The reset (×) is itself a radio in the same group — choosing it natively unchecks every option, and CSS hides it again while nothing is selected.
@bind-Value gives the selected option'sValue (null after reset).- With
ShowReset="false"there is no CSS way back to “none” (radios cannot be unclicked) — clear from app code and put an@keyon the filter: after a user click the browser ignoreschecked-attribute removal, so the inputs must be recreated to uncheck.
API
DFilter
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Value | string | — | @bind-Value | Value of the selected option ( null = nothing selected / "all"). Use with @bind-Value . Programmatic changes do not re-check the native radios (browser radio groups are user-owned once touched) — use the reset control for that. |
| ShowReset | bool | True | — | Shows the reset (×) control that clears the selection. This is daisy's only CSS-only way back to "nothing selected", so keep it unless you clear from app code. When you do ( ShowReset="false" ): after the user clicks a radio its checkedness is "dirty" per the HTML spec, so setting Value to null only removes the checked attribute and the browser keeps the radio visually checked. Put an @key on the DFilter (e.g. @key="myValue" ) so the inputs are recreated when the selection is cleared programmatically. |
| ResetLabel | string | All | — | Accessible label of the reset control (its glyph is CSS-generated ×). |
| Disabled | bool | False | — | Disables every option (and the reset). |
| ChildContent | RenderFragment | — | — | The DFilterOption entries. |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DFilterOption
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Value | string | — | — | Value reported through the parent's Value when this option is chosen. |
| Label | string | — | — | Visible label (daisy renders aria-label as the button text). |
| Disabled | bool | False | — | Disables this option only. |
| 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. |