limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/States

    Empty

    The state of a page, pane or result list with nothing in it: an icon, what is missing, why, and the next step. It is centered and has no frame of its own, so it sits on whatever surface it is given.

    Native componentGuide source

    Preview

    CodeSource
    fn view(palette: ComponentPalette) -> Element {
        Empty::new("No projects", "Create a project or import an existing one.", palette)
            .icon(Icon::Folder)
            .action("new-project", "Create project", ButtonVariant::Default)
            .render()
    }
    
    fn update(state: &mut State, action: &UiAction) {
        if let UiAction::Clicked { id } = action {
            if id == "new-project" {
                state.create_project();
            }
        }
    }

    Examples

    Each one is the library drawing it. Press, type and hover.

    Two actions
    CodeSource
    Empty::new("No projects", "Create a project or import an existing one.", cx.palette)
        .icon(Icon::Folder)
        .action("empty-new", "Create project", ButtonVariant::Default)
        .action("empty-import", "Import", ButtonVariant::Outline)
        .width(width)
        .render()
    Compact
    CodeSource
    Empty::new("No results", "Try another term.", cx.palette)
        .icon(Icon::Search)
        .compact()
        .width(width.min(360.0))
        .render()
    Framed
    CodeSource
    Empty::new("No plugins yet", "Choose a plugin folder to install.", cx.palette)
        .icon(Icon::Puzzle)
        .compact()
        .framed()
        .width(width)
        .render()
    Title only
    CodeSource
    Empty::new("Nothing here", "", cx.palette).width(width.min(360.0)).render()

    Empty

    The state of a page, pane or result list with nothing in it: an icon, what is missing, why, and the next step. It is centered and has no frame of its own, so it sits on whatever surface it is given.

    Import

    use limn::{ButtonVariant, Component, Empty, Icon};

    Usage

    An empty state needs a title, a description and the palette. An action is a button that reports UiAction::Clicked with its ID.

    fn view(palette: ComponentPalette) -> Element {
        Empty::new("No projects", "Create a project or import an existing one.", palette)
            .icon(Icon::Folder)
            .action("new-project", "Create project", ButtonVariant::Default)
            .render()
    }
    
    fn update(state: &mut State, action: &UiAction) {
        if let UiAction::Clicked { id } = action {
            if id == "new-project" {
                state.create_project();
            }
        }
    }

    An empty description is left out, so Empty::new("Nothing here", "", palette) is a title alone.

    Actions in a row

    Empty::new("No projects", "Create a project or import an existing one.", palette)
        .action("new-project", "Create project", ButtonVariant::Default)
        .action("import", "Import", ButtonVariant::Outline)
        .render()

    Each action adds a small Button to a centered row, in the order given. action_element adds a control of your own after them, for an action that is more than a button.

    Compact

    Empty::new("No results", "Try another term.", palette)
        .icon(Icon::Search)
        .compact()
        .render()

    compact is for a narrow pane or a filtered list: a smaller icon and type, less padding, and a minimum height of 168 px in place of 208.

    Framed

    Empty::new("No plugins yet", "Choose a plugin folder to install it.", palette)
        .compact()
        .framed()
        .render()

    framed sets it in a card of its own: the palette’s surface, a hairline border and the card radius. Use it on a page of cards, where an empty group should still read as one.

    Size

    width fixes the width; without it the state takes the width it is given. height sets a minimum height, never below the 208 or 168 px of its density. The description wraps, and wrapped copy or actions make the state taller. Its 440 px copy limit also constrains measurement: wrapped lines keep the normal gap before the actions, even in a wide pane.

    Actions

    ActionWhen
    UiAction::Clicked { id }One of its action buttons is activated, with the ID given to that action.

    Accessibility

    With an id the title is a heading the platform knows by that ID, described by the reason under it. The actions are buttons named by their labels. Without an id only the actions are known.

    Empty::new("No results", "Try another search.", palette)
        .id("no-results")
        .render()

    API reference

    The guide covers composition, options and actions. Generate the complete Rust type and builder reference from the checkout:

    cargo doc -p limn --open

    Component API overview · State and actions

    The example is drawn by crates/limn-gallery/src/pages/empty.rs.