limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/Layout

    PageHeader

    The heading of a page: a title, an optional description, and elements the host owns before and after them.

    Native componentGuide source

    Preview

    CodeSource
    fn view(palette: ComponentPalette) -> Element {
        PageHeader::new("Providers", palette)
            .description("Connected accounts and the models they offer.")
            .trailing(Button::new("refresh", "Refresh", palette).render())
            .render()
    }

    Examples

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

    Page header2 / 5
    CodeSource
    PageHeader::new("Providers", palette)
        .description("Connected accounts and models available to the agent.")
        .trailing(action("page-header-stacked"))
        .stacked(true)
        .render()
        .size(Some(width.min(320.0)), None)
    Page header3 / 5
    CodeSource
    PageHeader::new("Agent plugin marketplace", palette)
        .description("Skills for your agent, per user or per project")
        .leading(IconButton::new("page-header-back", Icon::ArrowLeft, palette).variant(ButtonVariant::Ghost).render())
        .trailing(action("page-header-cut"))
        .truncate(true)
        .sizing(CATALOG)
        .render()
        .size(Some(width.min(360.0)), None)
    Page header4 / 5
    CodeSource
    PageHeader::new("Automations", palette)
        .description("Scheduled tasks for this project, with a description spanning multiple lines on a narrow page.")
        .trailing(action("page-header-top"))
        .trailing_top(true)
        .render()
        .size(Some(width.min(420.0)), None)
    Page header5 / 5
    CodeSource
    PageHeader::new("Keyboard shortcuts", palette).render()

    PageHeader

    The heading of a page: a title, an optional description, and elements the host owns before and after them.

    Import

    use limn::{Component, PageHeader, PageHeaderSizing};

    Usage

    A header needs a title and the palette. It is passive: the elements the host puts in it report their own actions.

    fn view(palette: ComponentPalette) -> Element {
        PageHeader::new("Providers", palette)
            .description("Connected accounts and the models they offer.")
            .trailing(Button::new("refresh", "Refresh", palette).render())
            .render()
    }

    The title is in the palette’s text color and the description under it in the muted color. Both wrap unless truncate is set.

    Leading and trailing

    PageHeader::new("Marketplace", palette)
        .leading(IconButton::new("back", Icon::ArrowLeft, palette).render())
        .trailing(Button::new("refresh", "Refresh", palette).render())
        .render()

    leading puts an element before the copy, such as a back button, and trailing one after it at its own width. Both are centered on the header.

    trailing_top(true) keeps the trailing element on the title’s line instead of centering it, for a header whose description runs over several lines.

    Stacked

    PageHeader::new("Providers", palette)
        .trailing(Button::new("refresh", "Refresh", palette).render())
        .stacked(content_width < 300.0)
        .render()

    stacked(true) moves the trailing element under the copy, for a narrow page.

    Truncate

    truncate(true) cuts the title and the description to one line each instead of wrapping them.

    Sizing

    const CATALOG: PageHeaderSizing = PageHeaderSizing {
        title_size: 20.0,
        height: 40.0,
        ..PageHeaderSizing::DEFAULT
    };
    
    PageHeader::new("Marketplace", palette).truncate(true).sizing(CATALOG).render()

    A PageHeaderSizing holds the header’s density in logical pixels:

    FieldSetsDEFAULT
    title_sizeFont size of the title18
    description_sizeFont size of the description11
    copy_gapSpace between the title and the description4
    row_gapSpace between the leading element, the copy and the trailing element12
    stacked_gapSpace between the copy and a trailing element under it8
    heightFixed height of the header while it is a row; zero follows the copy0

    PageHeaderSizing::DEFAULT is the heading of a settings page.

    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/page.rs.