Swap & Fab
DSwap cross-fades (rotates, flips) two states on a checkbox — CSS-only, with
optional Blazor binding. DFab is a floating action button that reveals its
detail rows while focused.
Swap
<DSwap @bind-Checked="_wifi" On="@OnIcon" Off="@OffIcon" Class="text-primary" />
<DSwap Rotate="true" On="@OnText" Off="@OffText" />
<DSwap Flip="true" On="@OnText" Off="@OffText" />
<DSwap Active="true" On="@OnText" Off="@OffText" />
@code {
private bool _wifi = true;
private RenderFragment OnIcon =>@<text><span class="text-3xl">📶</span></text>;
private RenderFragment OffIcon =>@<text><span class="text-3xl opacity-30">📴</span></text>;
private RenderFragment OnText =>@<text><span class="badge badge-success badge-lg">ON</span></text>;
private RenderFragment OffText =>@<text><span class="badge badge-ghost badge-lg">OFF</span></text>;
}Fab— Bottom-right of the viewport — click it, then tab through the actions
<DFab TriggerClass="btn btn-circle btn-lg btn-primary shadow-lg">
<Trigger>
<DIcon Icon="@DaisyIcons.Plus" Class="h-6 w-6" />
</Trigger>
<Details>
<a class="btn btn-circle btn-sm btn-ghost bg-base-200" href="/components/cards" aria-label="Cards">
<DIcon Icon="@DaisyIcons.Search" Class="h-4 w-4" />
</a>
<span class="badge badge-neutral">Search</span>
<a class="btn btn-circle btn-sm btn-ghost bg-base-200" href="/components/table" aria-label="Table">
<DIcon Icon="@DaisyIcons.Trash" Class="h-4 w-4" />
</a>
<span class="badge badge-neutral">Trash</span>
</Details>
</DFab>API
DSwap
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Checked | bool | False | @bind-Checked | Whether the swap is in its "on" state. |
| On | RenderFragment | — | — | Content shown in the "on" state. |
| Off | RenderFragment | — | — | Content shown in the "off" state. |
| Indeterminate | RenderFragment | — | — | Optional content shown while the underlying checkbox is indeterminate. |
| Active | bool | False | — | Adds swap-active , forcing the "on" state (for buttons without a form control). |
| Rotate | bool | False | — | Rotate animation ( swap-rotate ). |
| Flip | bool | False | — | Flip animation ( swap-flip ). |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DFab
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Trigger | RenderFragment | — | — | The always-visible button (wrapped in a tabindex="0" element; daisy reveals the detail rows while the FAB has focus). |
| TriggerClass | string | — | — | Classes for the trigger wrapper (e.g. btn btn-circle btn-lg ). |
| Details | RenderFragment | — | — | Detail rows, revealed on focus/hover. Each direct child element of this fragment is one row (typically a button plus an optional label). |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |
DIcon
Parameters
| Name | Type | Default | Binding | Description |
|---|---|---|---|---|
| Icon | DaisyIcon | — | — | The icon to render (built-in from DaisyIcons or String) ). |
| Size | DaisySize | Medium | — | Rendered size (xs=12px, sm=14px, md=16px, lg=20px) via inline width/height. ExtraSmallSmallMediumLargeExtraLarge |
| StrokeWidth | double | 1.5 | — | Stroke width for built-in glyphs (heroicons geometry is designed for 1.5). |
| Label | string | — | — | Accessible label. When set the icon gets role="img" + aria-label ; otherwise it is hidden from assistive tech (decorative). |
| Class | string | — | — | Additional CSS classes appended to the component's computed daisyUI classes. |
| Style | string | — | — | Inline styles applied to the root element. |