Skip to main content

kbd

Function kbd 

Source
pub fn kbd<S>() -> El<S>
Expand description

A <kbd> that shows a key or a shortcut the visitor presses.

A screen reader reads its text as it stands, so write the key’s name in words where a symbol would be read as something else, such as “Ctrl” rather than “^”. For a shortcut, place one kbd per key side by side.

use hypersig::Signals;
use hypersig::html::p;
use hypersig_ui::kbd;
use serde::{Deserialize, Serialize};

#[derive(Signals, Serialize, Deserialize)]
struct Help {
    open: bool,
}

let hint = p::<Help>().text("Press ").child(kbd().text("Esc")).text(" to close.");
assert!(hint.render().contains("<kbd"));