Widgets

HotkeyFooter

Display keyboard shortcuts at the bottom of the screen.

Overview

The HotkeyFooter widget displays available keyboard shortcuts and commands at the bottom of the screen, making it easy for users to discover functionality.

Basic Usage

use ratkit::widgets::hotkey_footer::{HotkeyFooter, Hotkey};
use ratatui::Frame;

fn render_footer(frame: &mut Frame) {
    let footer = HotkeyFooter::new(vec![
        Hotkey::new("q", "Quit"),
        Hotkey::new("s", "Save"),
        Hotkey::new("n", "New File"),
        Hotkey::new("?", "Help"),
    ]);
    
    frame.render_widget(footer, bottom_area);
}

Features

  • Grouped shortcuts - Organize by category
  • Dynamic updates - Change based on context
  • Custom styling - Match your application theme
  • Overflow handling - Gracefully handle many shortcuts

Contextual Shortcuts

Update shortcuts based on application state:

let footer = if editing {
    HotkeyFooter::new(vec![
        Hotkey::new("esc", "Cancel"),
        Hotkey::new("ctrl+s", "Save"),
    ])
} else {
    HotkeyFooter::new(vec![
        Hotkey::new("e", "Edit"),
        Hotkey::new("d", "Delete"),
    ])
};