# Blazor Badge, Alert, Timeline and Progress Bar

URL: https://flexcoreui.com/demo/new-components  
Section: Components  
Controls: BadgeControl, AlertControl, SkeletonControl, TimelineControl, BreadCrumbControl, ProgressBarControl, ChunkProgressBarControl  
Keywords: badge, alert, skeleton loader, timeline, breadcrumb, progress bar

Small Blazor controls for status and progress: badge, alert, skeleton placeholder, timeline, breadcrumb and two kinds of progress bar.

## Documentation

### Badge

| Name | Type | Default | Description |
|---|---|---|---|
| Text | string? | null | Content of the span when not empty; ChildContent is then ignored. |
| ChildContent | RenderFragment? | null | Rendered only when Text is null or empty. |
| Variant | BadgeVariant | BadgeVariant.Primary | Picks the color class, fx-badge-primary to fx-badge-dark; see the values below. An unknown value falls back to fx-badge-primary. |
| Size | BadgeSize | BadgeSize.Medium | Picks fx-badge-sm, fx-badge-md or fx-badge-lg: font size and padding. |
| IsPill | bool | true | Adds fx-badge-pill: fully rounded ends and wider side padding. False keeps the 4px corners of fx-badge. The pill's 0.65em side padding applies at every BadgeSize. |
| IsDot | bool | false | Adds fx-badge-dot: an 8px circle with no padding. Text and ChildContent are still rendered inside it, so give a dot neither. |
| Title | string? | null | Inherited from FlexControlBase. Declared, but BadgeControl never reads it, and because it binds to a parameter it is not passed through as a title attribute either: a Title on a dot badge renders nothing, so put its meaning in nearby text. |

### Badge variants

| Name | Description |
|---|---|
| Primary | Blue, white text (fx-badge-primary); the default. |
| Secondary | Slate gray, white text. |
| Success | Green, white text. |
| Danger | Red, white text. |
| Warning | Amber, white text. |
| Info | Sky blue, white text. |
| Light | Light gray, dark text, 1px border. |
| Dark | Dark slate, white text. |

### Badge sizes

| Name | Description |
|---|---|
| Small | fx-badge-sm: 0.65rem text, 0.2em 0.4em padding. |
| Medium | fx-badge-md: 0.75rem text, 0.25em 0.55em padding; the default. |
| Large | fx-badge-lg: 0.85rem text, 0.35em 0.7em padding. |

### Alert

| Name | Type | Default | Description |
|---|---|---|---|
| Title | string? | null | Inherited from FlexControlBase; rendered as an h6.fx-alert-title when not empty. |
| Text | string? | null | Rendered in div.fx-alert-text under the title when not empty. |
| ChildContent | RenderFragment? | null | Rendered after Title and Text inside the content column; all three can be present. |
| Severity | AlertSeverity | AlertSeverity.Info | Picks the color class (fx-alert-info, -success, -warning, -error) and which of the four inline SVG icons is drawn. |
| ShowIcon | bool | true | Renders the fx-alert-icon column with the severity's icon. |
| AllowClose | bool | false | Renders the close button (fx-alert-close, aria-label Close). Clicking it sets a private flag that removes the whole alert from the render tree, then raises OnClose. No parameter shows it again; a new component instance does. |

### Alert events

| Name | Type | Description |
|---|---|---|
| OnClose | EventCallback | After the close button has hidden the alert. No argument; invoked only when a delegate is set. Nothing else hides the alert, so nothing else raises it. |

### Alert severities

| Name | Description |
|---|---|
| Info | Light blue, i-in-circle icon; the default and the fallback for any other value. |
| Success | Light green, check-in-circle icon. |
| Warning | Light amber, filled triangle icon. |
| Error | Light red, outlined triangle icon with an exclamation mark (the library's warning SvgIconControl). |

### Skeleton

| Name | Type | Default | Description |
|---|---|---|---|
| Variant | SkeletonVariant | SkeletonVariant.Text | The control is a single empty div; this picks its shape class, fx-skeleton-text, fx-skeleton-circular or fx-skeleton-rectangular. See the values below. |
| Animation | SkeletonAnimation | SkeletonAnimation.Pulse | Picks fx-skeleton-pulse, fx-skeleton-wave or fx-skeleton-none. |
| Width | string? | null | Any CSS length. Appended to the style attribute after Style as width, so it overrides the variant's width. |
| Height | string? | null | Any CSS length. Appended after Width as height, overriding the variant's height. |

### Skeleton variants

| Name | Description |
|---|---|
| Text | A 1.2em-tall bar, full width, 4px corners, 0.5em bottom margin; the default. |
| Circular | A 40px circle. |
| Rectangular | Full width, 120px tall, 4px corners. |

### Skeleton animations

| Name | Description |
|---|---|
| Pulse | Opacity fades to 0.4 and back every 1.5s; the default. |
| Wave | A translucent highlight sweeps left to right every 1.6s (an ::after gradient). |
| None | Adds fx-skeleton-none, which has no stylesheet rule: the block is static. |

### Timeline

| Name | Type | Default | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | The items, rendered inside div.fx-timeline. The control cascades itself to them (IsFixed), but TimelineItemControl keeps that value in a private cascading parameter it never reads. |
| Orientation | TimelineOrientation | TimelineOrientation.Vertical | Adds fx-timeline-vertical or fx-timeline-horizontal to the root. Neither class has a rule in TimelineControl.razor.css, so the layout is the vertical flex column either way. |
| Position | TimelinePosition | TimelinePosition.Left | Adds fx-timeline-pos-left, -right or -alternate. No stylesheet rule reads them: content always sits to the right of the axis. |

### Timeline orientations

| Name | Description |
|---|---|
| Vertical | fx-timeline-vertical; the default. |
| Horizontal | fx-timeline-horizontal. Class name only: no rule styles it, so items still stack vertically. |

### Timeline positions

| Name | Description |
|---|---|
| Left | fx-timeline-pos-left; the default. |
| Right | fx-timeline-pos-right. Class name only; no rule styles it. |
| Alternate | fx-timeline-pos-alternate. Class name only; no rule styles it. |

### Timeline item

| Name | Type | Default | Description |
|---|---|---|---|
| Title | string? | null | div.fx-timeline-title (bold) under the time, when not empty. |
| Time | string? | null | div.fx-timeline-time, the small gray line at the top of the item, when not empty. Plain text; nothing parses or formats it. |
| IconCss | string? | null | Classes of a span rendered inside the 14px point when PointContent is null and this is not empty. |
| PointColor | BadgeVariant | BadgeVariant.Primary | Adds fx-timeline-item-point- plus the lower-cased value to the item. The stylesheet colors the point for Success, Danger, Warning, Info, Secondary and Dark; Primary and Light have no rule and keep the point's default blue. |
| PointContent | RenderFragment? | null | Replaces the point's content; wins over IconCss. |
| ChildContent | RenderFragment? | null | Body text in div.fx-timeline-body under the title; the div is rendered even when empty. |

### Bread crumb

| Name | Type | Default | Description |
|---|---|---|---|
| Items | IList<BreadCrumbItem>? | null | Rendered in order as li.fx-breadcrumb-item; the separator between items is CSS. An item renders as a link (a.fx-breadcrumb-link) only when it is not the last, has a non-empty Href and is not Disabled; otherwise as span.fx-breadcrumb-text. The last item also gets the class active, which no stylesheet rule uses. Null renders an empty list. |
| ChildContent | RenderFragment? | null | Rendered inside the ol after the generated items. |

### Crumb item

| Name | Type | Default | Description |
|---|---|---|---|
| Text | string | "" | The crumb's visible text, inside the link or the span. |
| Href | string? | null | Link target. Null or empty renders the crumb as text; the last crumb is text whatever its Href. |
| IconCss | string? | null | Classes of a span.fx-breadcrumb-icon placed before the text, in both the link and the text form. |
| Disabled | bool | false | Adds the class disabled to the item (gray, pointer-events: none) and renders it as text even when it has an Href. |

### Flex base

| Name | Type | Default | Description |
|---|---|---|---|
| CssClass | string? | null | Appended after the generated classes on the root element of the five inheriting controls. |
| Style | string? | null | The root element's style attribute, as given; SkeletonControl appends its Width and Height to it. None of the five uses the base's ResolvedStyle. |
| AdditionalAttributes | Dictionary<string, object>? | null | Attributes that match no parameter, splatted onto the same root element. A Title attribute is not among them: it binds to the Title parameter. |
| Title | string? | null | Read by AlertControl only, as its heading. The other four never read it. |
| Visible | bool | true | Declared, but none of the five reads it or uses ResolvedStyle, so false does not hide them. |
| Enabled | bool | true | Declared, but none of the five reads it. |
| Id | string? | null | Declared, but none of the five reads it, so it never reaches the element. |
| Tag / Data | string? | null | Declared, but none of the five reads them. |
| Parent | FlexControlBase? | null | Declared, but none of the five reads it. |

### Progress

| Name | Type | Default | Description |
|---|---|---|---|
| Value | double | 0 | Percent complete, 0 to 100, not a fraction: 0.5 is half a percent. Clamped to that range for the fill width, which eases over 0.25 s when it changes, and for the percentage in the detail line, shown with at most one decimal (0.#). Ignored while Indeterminate is true. |
| Title | string? | null | Bold lead-in at the start of the header, when not blank. A non-null Title, even an empty one, also puts a middle dot before Status. |
| Status | string? | null | Gray text after the title (span.fx-progress-status), when not blank. |
| Detail | string? | null | Text of the monospace line under the bar (p.fx-progress-detail), after the percentage and a middle dot when the percentage is shown. |
| Indeterminate | bool | false | Adds fx-progress-indeterminate to the fill: a block 30% wide sweeps left to right every 1.4 s in place of the fill width, and the percentage is not shown. |
| IsError | bool | false | Adds fx-progress-error to the root: pink background, red border and a solid red fill, and an indeterminate sweep stops. It shows no text by itself; pair it with ErrorMessage. |
| ErrorMessage | string? | null | A dark red line between the header and the bar (p.fx-progress-error-text), prefixed with ✗. Rendered only when IsError is true and the message is not blank. |
| CancelDisabled | bool | false | Disables the Cancel button and changes its label to "cancelling…", ignoring CancelText. No effect without an OnCancel delegate. |
| CancelText | string? | null | Label of the Cancel button; null shows "Cancel". The button's title attribute stays "Cancel" whatever the label. |
| ShowPercent | bool | true | Shows the clamped Value with a % sign at the start of the detail line, except while Indeterminate is true. |
| CssClass | string? | null | Appended to the root's classes after fx-progress and, when IsError is true, fx-progress-error. |
| Style | string? | null | The root's style attribute, as given. |

### Progress events

| Name | Type | Description |
|---|---|---|
| OnCancel | EventCallback | Raised when the Cancel button is clicked; no argument. The header shows the button, a bare ButtonControl with class fx-progress-cancel and no fx-button styling, only while this has a delegate. The control stops nothing itself: the example's handler sets the flag bound to CancelDisabled, and the page passes no delegate once the import has stopped, which removes the button. |

### Chunk

| Name | Type | Default | Description |
|---|---|---|---|
| Value | double | 0 | Clamped to Min–Max. The clamped value itself is aria-valuenow; the percentage, 100 × (Value − Min) / (Max − Min), fills the segments and is aria-valuetext. The example passes a line count with Max 5,000. |
| Min | double | 0 | Start of the range; aria-valuemin. |
| Max | double | 100 | End of the range; aria-valuemax. Must be greater than Min. |
| ChunkCount | int | 10 | Number of segments: spans that share the bar's length, 3px apart. The first floor(ChunkCount × percentage / 100) get the class complete and turn blue, so a segment fills only when its whole share is reached. 1 to 1000. |
| Indeterminate | bool | false | Adds the class indeterminate to every segment: each fades to blue and back, one second each way, or is solid blue under prefers-reduced-motion: reduce. aria-valuenow is left out, aria-valuetext becomes "In progress" and the shown value "…". Segments already complete keep complete. |
| ShowValue | bool | true | Renders an output after the segments with the percentage as a whole number, or "…" while Indeterminate is true. |
| Orientation | FlexOrientation | FlexOrientation.Horizontal | Adds the lower-cased value, horizontal or vertical, to the root's classes; see the values below. |
| AriaLabel | string | "Progress" | The root's aria-label. The default names nothing in particular; the example gives each bar its own. |
| CssClass | string? | null | Inherited from FlexControlBase. Placed after fx-chunk-progress and before the orientation class. |
| Style | string? | null | Inherited. Reaches the root through the base's ResolvedStyle and wins over the stylesheet, as the vertical bar's height: 120px shows. |
| Visible | bool | true | Inherited. False adds display:none through ResolvedStyle: unlike the five controls in the last table, this one is hidden by it. |
| AdditionalAttributes | Dictionary<string, object>? | null | Inherited. Captures attributes that match no parameter but never renders them, so data-* and aria-* attributes are dropped; id and title bind to the unread Id and Title parameters. |
| Title / Id / Tag / Data | string? | null | Inherited; declared, but the control never reads them. |
| Enabled | bool | true | Inherited; declared, but the control never reads it. |
| Parent | FlexControlBase? | null | Inherited; declared, but the control never reads it. |

### Orientations

| Name | Description |
|---|---|
| Horizontal | Class horizontal, which has no rule: the segments run left to right in the base row layout, at least 180px wide; the default. |
| Vertical | Class vertical: a column 20px wide and 200px tall, filled from the bottom (column-reverse); the shown value sits at the top. |

## Examples

### Status

```razor
@using Fx.ControlKit

<div class="ui">
    <div class="demo-row">
        <ButtonControl CssClass="btn-sm" IconCss="bi bi-arrow-clockwise" Disabled="_loading" OnClick="RefreshAsync">Refresh board</ButtonControl>
        <ButtonControl CssClass="btn-sm" Disabled="@(_open.Count == Issues.Length)" OnClick="() => _open = Issues.ToList()">Show alerts again</ButtonControl>
        <span class="label">Open alerts</span>
        <BadgeControl Text="@_open.Count.ToString()" Variant="@(_open.Count > 0 ? BadgeVariant.Danger : BadgeVariant.Success)" Size="BadgeSize.Small" />
    </div>
    <div class="stack mt">
        @foreach (var issue in _open)
        {
            <AlertControl @key="issue.Title" Severity="issue.Severity" Title="@issue.Title" Text="@issue.Text" AllowClose="true" OnClose="() => _open.Remove(issue)" />
        }
    </div>
    <div class="board mt" aria-busy="@(_loading ? "true" : "false")">
        <div class="board-head"><span class="bi bi-kanban" aria-hidden="true"></span>Sprint 8 tasks</div>
        @foreach (var t in SprintTasks)
        {
            <div class="board-row">
                @if (_loading)
                {
                    <SkeletonControl Variant="SkeletonVariant.Circular" Width="12px" Height="12px" />
                    <SkeletonControl Variant="SkeletonVariant.Text" Animation="SkeletonAnimation.Wave" Width="60%" />
                    <SkeletonControl Variant="SkeletonVariant.Rectangular" Width="84px" Height="20px" />
                }
                else
                {
                    <BadgeControl IsDot="true" Variant="@t.Variant" />
                    <BadgeControl Text="@t.Code" IsPill="false" Variant="BadgeVariant.Light" />
                    <span class="board-task">@t.Title</span>
                    <BadgeControl Text="@t.Status" Variant="@t.Variant" />
                }
            </div>
        }
    </div>
</div>
```

```csharp
// Sprint 8 tasks
private sealed record SprintTask(string Code, string Title, string Status, BadgeVariant Variant);
private static readonly SprintTask[] SprintTasks =
{
    new("WEB-113", "Site footer", "Done", BadgeVariant.Success),
    new("WEB-117", "Order form", "In review", BadgeVariant.Warning),
    new("WEB-118", "Order emails", "In progress", BadgeVariant.Primary),
    new("WEB-120", "Payment setup", "To do", BadgeVariant.Secondary),
};
private sealed record Issue(AlertSeverity Severity, string Title, string Text);
private static readonly Issue[] Issues =
{
    new(AlertSeverity.Error, "Preview build failed", "WEB-117: the order form did not deploy to the preview site."),
    new(AlertSeverity.Warning, "Waiting on the client", "WEB-120 cannot start until Green Fork Cafe picks a payment provider."),
    new(AlertSeverity.Info, "Client demo moved", "The Sprint 8 demo for Green Fork Cafe is now Thursday at 11:00."),
    new(AlertSeverity.Success, "Design approved", "Green Fork Cafe signed off on the order email templates for WEB-118."),
};
private List<Issue> _open = Issues.ToList();
private bool _loading;
private async Task RefreshAsync()
{
    _loading = true;
    await Task.Delay(1500);   // stands in for the call that loads the board
    _loading = false;
}
```

### Content

```razor
@using Fx.ControlKit

<div class="ui">
    <BreadCrumbControl Items="_crumbs" />
    <div class="demo-row mt">
        <ButtonControl CssClass="btn-primary btn-sm" Disabled="@(_done == Steps.Length)" OnClick="() => _done++">Complete next step</ButtonControl>
        <ButtonControl CssClass="btn-sm" Disabled="@(_done == 0)" OnClick="() => _done = 0">Start over</ButtonControl>
        <span class="label" role="status">@_done of @Steps.Length steps done</span>
    </div>
    <div class="two mt">
        <TimelineControl>
            @foreach (var (step, i) in Steps.Select((step, i) => (step, i)))
            {
                <TimelineItemControl @key="step.Title" Title="@($"{step.Title}: {StateOf(i)}")" Time="@(i < _done ? step.Time : null)" PointColor="@PointFor(i)"
                                     IconCss="@(i < _done ? "bi bi-check-lg" : null)">@step.Note</TimelineItemControl>
            }
        </TimelineControl>
    </div>
</div>
```

```csharp
// Follow a task
private readonly List<BreadCrumbItem> _crumbs = new() { new("Home", "/", "bi bi-house"), new("Website relaunch", "demo/new-components#status"), new("WEB-118 Order emails") };
private sealed record Step(string Title, string Time, string Note);
private static readonly Step[] Steps =
{
    new("Brief", "Mon 9:00 AM", "Order confirmation and pickup reminder emails."),
    new("Design", "Tue 2:10 PM", "Sign-off on both templates from Green Fork Cafe."),
    new("Build", "Wed 1:30 PM", "Test sends of both emails from the preview site."),
    new("Review", "Thu 4:45 PM", "Code review by Hermione Ranger."),
    new("Release", "Fri 10:40 AM", "Part of the Sprint 8 release."),
};
private int _done = 2;
private string StateOf(int i) => i < _done ? "done" : i == _done ? "next" : "to do";   // the state in words, not only in color
private BadgeVariant PointFor(int i) => i < _done ? BadgeVariant.Success : i == _done ? BadgeVariant.Warning : BadgeVariant.Secondary;
```

### Progress

```razor
@using Fx.ControlKit

<div class="ui">
    <div class="demo-row">
        <ButtonControl CssClass="btn-primary" OnClick="StartImport" Disabled="Running">Start import</ButtonControl>
        <ButtonControl OnClick="FailImport" Disabled="@(_phase != ImportPhase.Importing)">Simulate a failure</ButtonControl>
    </div>
    <div class="progress-demo mt">
        <ProgressBarControl Value="Percent" Title="Importing contact lists" Status="@ImportStatus" Detail="@ImportDetail"
                            Indeterminate="Connecting" IsError="@(_phase == ImportPhase.Failed)" ErrorMessage="@_error"
                            OnCancel="CancelCallback" CancelText="Stop import" CancelDisabled="_canceling" />
        <div class="chunk-col">
            <ChunkProgressBarControl Value="_linesDone" Max="TotalLines" ChunkCount="10" Indeterminate="Connecting"
                                     AriaLabel="Contact list lines imported" />
        </div>
        <ChunkProgressBarControl Value="_linesDone" Max="TotalLines" ChunkCount="5" Indeterminate="Connecting" ShowValue="false"
                                 Orientation="FlexOrientation.Vertical" Style="height: 120px" AriaLabel="Contact list lines imported, vertical" />
    </div>
</div>
```

```csharp
// Progress (2026-10-25): the import is simulated; a PeriodicTimer on this page advances it and the controls only display it.
private enum ImportPhase { Idle, Connecting, Importing, Canceled, Failed, Done }
private static readonly (string Name, int Lines)[] ContactFiles = { ("Newsletter", 2000), ("Loyalty club", 1800), ("Catering", 1200) };
private static readonly int TotalLines = ContactFiles.Sum(f => f.Lines);
private ImportPhase _phase;
private int _linesDone, _connectTicks;
private bool _canceling;
private string? _error;
private PeriodicTimer? _timer;

private bool Running => _phase is ImportPhase.Connecting or ImportPhase.Importing;
private bool Connecting => _phase == ImportPhase.Connecting;
private double Percent => 100.0 * _linesDone / TotalLines;
// The control shows its Cancel button whenever OnCancel has a delegate, so pass one only while the import runs.
private EventCallback CancelCallback => Running ? EventCallback.Factory.Create(this, CancelImport) : default;

private (int Index, int Done) CurrentFile()
{
    int i = 0, left = _linesDone;
    while (i < ContactFiles.Length - 1 && left >= ContactFiles[i].Lines) left -= ContactFiles[i++].Lines;
    return (i, left);
}

private string FileStatus() { var (i, done) = CurrentFile(); return $"{ContactFiles[i].Name}: {done:N0} of {ContactFiles[i].Lines:N0} lines"; }

private string ImportStatus => _phase switch
{
    ImportPhase.Idle => "not started",
    ImportPhase.Connecting => "connecting",
    ImportPhase.Canceled => $"stopped at {_linesDone:N0} lines",
    ImportPhase.Done => $"{TotalLines:N0} lines read",
    _ => FileStatus(),
};

private string ImportDetail => $"file {CurrentFile().Index + 1} of {ContactFiles.Length} · {_linesDone:N0} of {TotalLines:N0} lines in all";

private void StartImport()
{
    StopTimer();
    (_phase, _linesDone, _connectTicks, _canceling, _error) = (ImportPhase.Connecting, 0, 0, false, null);
    _timer = new PeriodicTimer(TimeSpan.FromMilliseconds(250));
    _ = RunImportAsync(_timer);
}

private async Task RunImportAsync(PeriodicTimer timer)
{
    // StopTimer and Dispose end this loop: a disposed PeriodicTimer's WaitForNextTickAsync returns false.
    while (await timer.WaitForNextTickAsync())
        await InvokeAsync(() => { Tick(); StateHasChanged(); });
}

private void Tick()
{
    if (!Running) return;
    if (_canceling) { _phase = ImportPhase.Canceled; StopTimer(); }
    else if (Connecting) { if (++_connectTicks == 6) _phase = ImportPhase.Importing; }
    else
    {
        _linesDone = Math.Min(TotalLines, _linesDone + Random.Shared.Next(80, 170));
        if (_linesDone == TotalLines) { _phase = ImportPhase.Done; StopTimer(); }
    }
}

// Bound to CancelDisabled: the button reads "cancelling…" until the next tick stops the loop.
private void CancelImport() => _canceling = true;

private void FailImport()
{
    var (i, done) = CurrentFile();
    _error = $"{ContactFiles[i].Name}, line {done + 1:N0}: the email column is empty.";
    _phase = ImportPhase.Failed;
    StopTimer();
}

private void StopTimer() { _timer?.Dispose(); _timer = null; }

// The page declares @implements IDisposable, so the timer stops when the page goes away.
public void Dispose() => StopTimer();
```

