# Blazor Floating Action Button (FAB)

URL: https://flexcoreui.com/demo/fab  
Section: Components  
Controls: FabMenuControl, FabMenuItem  
Keywords: floating action button, FAB, speed dial, FAB menu

A Blazor floating action button, or speed dial: a round button fixed to the bottom-right corner that fans out a screen's main actions.

## Documentation

### Parameters

| Name | Type | Default | Description |
|---|---|---|---|
| Items | IList<FabMenuItem>? | null | The actions shown when the fan opens, the first nearest the trigger. |
| IconCss | string? | null | Trigger icon. Default is a plus that rotates into a cross while open; a custom icon rotates too. |
| ChildContent | RenderFragment? | null | Your own markup in the fan after the items, such as a note or a toggle; clicks inside it keep the fan open. |
| Disabled | bool | false | Disables the trigger, so the menu cannot open, and closes a menu that is open. The trigger looks the same; only the hover effect stops. |
| Title (base) | string? | null | Tooltip and accessible name of the trigger. |
| CssClass / Style (base) | string? | null | On the host element. |
| Visible / Enabled (base) | bool | true | Accepted but have no effect. Use Disabled to disable the trigger. |
| Id / Tag / Data / Parent (base) |  | null | Accepted but not rendered. A written id binds to Id, so it does not reach the host. |
| (unmatched attributes) | Dictionary<string,object> |  | Forwarded to the host <div>. |

### Item

| Name | Type | Default | Description |
|---|---|---|---|
| Title | string | "" | The label chip beside the action and its tooltip. Left empty, there is no chip and the button has no accessible name. |
| IconCss | string? | null | Classes for the icon in the round button; a dot (•) when empty. |
| Color | BadgeVariant | Primary | Fill: Primary, Secondary, Success, Danger, Warning, Info or Dark. Light has no rule in the stylesheet: the button keeps the browser's default gray and the white icon barely shows. |
| OnClick | EventCallback | none | Runs after the menu closes. |
| ctor |  |  | new(title, iconCss, color); set OnClick in an initializer. |

### Css

| Name | Description |
|---|---|
| fx-fab-host · .fx-fab-open | Fixed 2rem from the bottom-right, z-index 1050. fx-fab-open while the menu is showing. |
| fx-fab-trigger · .disabled | 56px blue circle with a shadow; grows 5% on hover unless disabled. disabled is added while Disabled is true and has no rule in the stylesheet. |
| fx-fab-trigger-icon | Wraps the trigger icon; rotates 45° over 0.2s while the menu is open. |
| fx-fab-backdrop | Full-screen 25% black layer; click closes the menu. |
| fx-fab-actions | Column of actions above the trigger; slides in over 0.2s. |
| fx-fab-action-row · fx-fab-action-label · fx-fab-action-btn | One action: white label chip plus a 42px circle that grows 10% on hover. |
| fx-fab-color-primary … fx-fab-color-dark | Seven fills, one per BadgeVariant except Light. |

## Examples

### Menu

```razor
@using Fx.ControlKit

<ToggleButtonControl @bind-Selected="_disabled">Disabled</ToggleButtonControl>

<div class="fab-stage">
    <div class="board-head"><span class="bi bi-list-task" aria-hidden="true"></span>Today's board</div>
    <ul class="board">
        @foreach (var row in _board)
        {
            <li><span class="bi @(row.Kind == "Callback" ? "bi-telephone" : "bi-ticket-perforated")" aria-hidden="true"></span><span class="subject">@row.Subject</span><BadgeControl Text="@row.Kind" Variant="@(row.Kind == "Callback" ? BadgeVariant.Success : BadgeVariant.Info)" /></li>
        }
    </ul>
    <FabMenuControl Items="Actions" Disabled="@_disabled" Title="Add to the board" />
</div>
<span class="result" role="status">@_board.Count on today's board, @_agents agents on shift. Last action: @_last</span>
```

```csharp
// Action menu
private bool _disabled;
private int _agents = 3;
private string _last = "none yet";
private sealed record Row(string Subject, string Kind);
private readonly List<Row> _board = new() { new("Router keeps restarting", "Callback"), new("Charged twice in October", "Ticket") };
private static readonly string[] Subjects = { "Router light is red", "Invoice not received", "Cannot reset password", "No signal since noon" };
private List<FabMenuItem>? _actions;
private List<FabMenuItem> Actions => _actions ??= new()
{
    Action("New ticket", "bi bi-ticket-perforated", BadgeVariant.Primary, _ => Add("Ticket")),
    Action("New callback", "bi bi-telephone", BadgeVariant.Success, _ => Add("Callback")),
    Action("Add agent", "bi bi-person-plus", BadgeVariant.Info, t => { _agents++; _last = t; }),
    Action("Clear added", "bi bi-trash", BadgeVariant.Danger, t => { _board.RemoveRange(0, _board.Count - 2); _agents = 3; _last = t; }),
};
private void Add(string kind)
{
    if (_board.Count >= 6) { _last = "none, the board is full"; return; }
    _board.Insert(0, new(Subjects[_board.Count % Subjects.Length], kind));
    _last = $"New {kind.ToLowerInvariant()}";
}

// FabMenuItem(title, iconCss, color); OnClick is a settable EventCallback.
private FabMenuItem Action(string title, string icon, BadgeVariant color, Action<string> pick) =>
    new(title, icon, color) { OnClick = EventCallback.Factory.Create(this, () => pick(title)) };
```

### Custom

```razor
@using Fx.ControlKit

<div class="fab-stage short">
    <div class="board-head"><span class="bi bi-inbox" aria-hidden="true"></span>Your open tickets</div>
    <ul class="board">
        <li><span class="bi bi-ticket-perforated" aria-hidden="true"></span><span class="subject">Router keeps restarting</span><span class="ref">TKT-1042</span></li>
        <li><span class="bi bi-ticket-perforated" aria-hidden="true"></span><span class="subject">Wi-Fi does not reach the garage</span><span class="ref">TKT-1038</span></li>
        <li><span class="bi bi-ticket-perforated" aria-hidden="true"></span><span class="subject">Change the name on the account</span><span class="ref">TKT-1031</span></li>
    </ul>
    <FabMenuControl IconCss="bi bi-headset" Items="Help" Title="Help desk">
        <div class="fab-note">
            <span class="dot"></span> 3 agents online
            <ToggleButtonControl @bind-Selected="_urgent" CssClass="btn-sm">Urgent</ToggleButtonControl>
        </div>
    </FabMenuControl>
</div>
<span class="result" role="status">@_contact</span>
```

```csharp
// Trigger icon and extra content
private bool _urgent;
private string _contact = "No request yet";
private List<FabMenuItem>? _help;
private List<FabMenuItem> Help => _help ??= new()
{
    Action("Chat with an agent", "bi bi-chat-text", BadgeVariant.Primary, Ask),
    Action("Call me back", "bi bi-telephone", BadgeVariant.Success, Ask),
    Action("Send an email", "bi bi-envelope", BadgeVariant.Secondary, Ask),
};
private void Ask(string what) => _contact = _urgent ? $"{what}: marked urgent" : what;

// FabMenuItem(title, iconCss, color); OnClick is a settable EventCallback.
private FabMenuItem Action(string title, string icon, BadgeVariant color, Action<string> pick) =>
    new(title, icon, color) { OnClick = EventCallback.Factory.Create(this, () => pick(title)) };
```

