limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/Actions

    Kbd

    Passive keycaps for a keyboard shortcut such as Ctrl+Shift+P, with an optional caption that says what the keys do: the hints in the footer of a palette or a suggestion list.

    Native componentGuide source

    Preview

    CodeSource
    fn view(palette: ComponentPalette) -> Element {
        Kbd::new("Ctrl+Shift+P", palette).render()
    }

    Kbd

    Passive keycaps for a keyboard shortcut such as Ctrl+Shift+P, with an optional caption that says what the keys do: the hints in the footer of a palette or a suggestion list.

    Import

    use limn::{Component, Kbd};

    Usage

    A Kbd needs the keys and the palette. It draws one outlined keycap for each key and takes no pointer or focus.

    fn view(palette: ComponentPalette) -> Element {
        Kbd::new("Ctrl+Shift+P", palette).render()
    }

    Notation

    Kbd::new("Ctrl+K Ctrl+C", palette).render()
    Kbd::new("Ctrl++", palette).render()
    Kbd::new("↑↓", palette).render()

    A plus joins the keys of one combination and a space separates the chords of a sequence. A literal plus is written Ctrl++. The arrows ↑, ↓, ← and → are drawn as icons, so they do not depend on the font. Empty keys draw nothing.

    Caption

    Kbd::new("Esc", palette).caption("Close").render()

    caption says what the keys do, in small muted text after them.

    Alternative

    Kbd::new("Enter", palette).alternative("Tab").caption("Accept").render()

    alternative adds another key that does the same, after a slash: Enter / Tab. It can be called more than once.

    Kbd::new("Ctrl+K Ctrl+C", palette).menu().render()

    menu draws the combination as plain muted text with no keycaps, the way a menu row shows its accelerator.

    Width budget

    Kbd::new("Ctrl+Shift+M", palette).max_width(80.0).render()

    With max_width, a hint whose measured width does not fit is left out whole. It is never cut, because a truncated combination would read as another shortcut.

    The budget covers the complete hint: all alternatives, slash separators, gaps and the caption. They disappear together, without leaving a caption or slash on its own. A narrow parent row also omits the complete hint. menu applies to every alternative.

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