Rask
Rask
v0.23.1-alpha.0.738

Components

Empty state

What a list says when it has nothing to show: one sentence, centred, with room above and below, said to a screen reader as it changes. Flux UI has no empty state of its own; this is the one its account overview demo draws when a search matches nothing, measured from it.

In a table

Search for what no supplier is called. The table keeps its headings and its one row says so, its cell across both columns: Ui.TableCell.ColSpan(2)[Ui.Empty[…]]. A table drawn from a query does this itself: Ui.Table.Of(suppliers).Empty("No suppliers yet.", "No supplier matches.").

EmptyExample.cs
namespace Rask.Site.Features.UiDocs.Examples;

// Search for what no supplier is called: the table's one row says so, across both columns, as Flux's demo draws it.
public sealed partial class EmptyExample : Component
{
    private static readonly (string Name, string City)[] Suppliers = [("Aminoff Freight", "Oslo"), ("Bothman & Sons", "Leeds"), ("Geidt Logistics", "Porto")];

    private string _search = "";

    protected override Component? Render()
    {
        var found = Suppliers.Where(s => s.Name.Contains(_search.Trim(), StringComparison.OrdinalIgnoreCase)).ToList();
        IEnumerable<Component> rows = found.Count == 0
            ? [Ui.TableRow.Key("none")[Ui.TableCell.ColSpan(2)[Ui.Empty["No supplier matches “" + _search.Trim() + "”."]]]]
            : found.Select(s => Ui.TableRow.Key(s.Name)[Ui.TableCell.Variant(Ui.TableCellVariant.Strong)[s.Name], Ui.TableCell[s.City]]);

        return Div.Class("grid gap-4")[
            Ui.Input.Value(_search).Placeholder("Search suppliers").Icon(Ui.IconName.MagnifyingGlass).Clearable().Class("max-w-xs")
                .OnInput(text => { _search = text; }).OnChange(text => { _search = text; }),
            Ui.Table.Id("ue-suppliers").ContainerClass("min-w-0")[
                Ui.TableColumns[Ui.TableColumn["Supplier"], Ui.TableColumn["City"]],
                Ui.TableRows[rows]
            ]
        ];
    }
}
Live result
Supplier
City
Aminoff FreightOslo
Bothman & SonsLeeds
Geidt LogisticsPorto

In place of a list

A list with nothing in it yet says so where its table would be. Ui.Empty has no ink of its own — in a cell it reads in the cell's — so out of one the page gives it: the cell's 14px muted ink here.

EmptyListExample.cs
namespace Rask.Site.Features.UiDocs.Examples;

// A list with nothing in it yet says so in place of its table. Out of a cell the page gives the ink: here the cell's.
public sealed partial class EmptyListExample : Component
{
    private bool _archived;

    protected override Component? Render() =>
        Div.Class("grid gap-4")[
            Div[Ui.Button.Key("archive").Sm.OnClick(() => { _archived = !_archived; })[_archived ? "Bring them back" : "Archive every driver"]],
            _archived
                ? Ui.Empty.Id("ue-drivers-empty").Class("text-sm text-zinc-500 dark:text-zinc-300")["No drivers yet."]
                : Ui.Table.Id("ue-drivers").ContainerClass("min-w-0")[
                    Ui.TableColumns[Ui.TableColumn["Driver"], Ui.TableColumn["Chip"]],
                    Ui.TableRows[
                        Ui.TableRow.Key("lindsey")[Ui.TableCell.Variant(Ui.TableCellVariant.Strong)["Lindsey Aminoff"], Ui.TableCell["C-0142"]],
                        Ui.TableRow.Key("jaxson")[Ui.TableCell.Variant(Ui.TableCellVariant.Strong)["Jaxson Geidt"], Ui.TableCell["C-0177"]]
                    ]
                ]
        ];
}
Live result
Driver
Chip
Lindsey AminoffC-0142
Jaxson GeidtC-0177

Reference

Ui.Empty

not in Flux UI

What a list says when it has nothing to show: a centred status line with 24px above and below, as Flux's demo draws it; in a cell, the cell's ink and size. Its children are the sentence.

No steps of its own: what goes inside it is its content.

It is one HTML element, so Id, Class, Style, Data, Aria and the events are its steps too.

Confirm