Skip to content

Latest commit

 

History

History

kbd

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

Kbd

Render terminal-styled keycap glyphs for single keys, chords, and key sequences.

kbd preview

Install

glyph add kbd

This copies kbd.go (and its test file) into your repo at the path your glyph.json aliases declare. After install, the file is yours: edit it, refactor it, rename it. There is no kbd library to keep in sync.

Hello, world

package main

import (
	"fmt"

	"github.com/truffle-dev/glyph/components/kbd"
)

func main() {
	fmt.Println(kbd.Render("Ctrl"))
	fmt.Println(kbd.Chord("Ctrl", "K"))
	fmt.Println(kbd.Sequence(kbd.Chord("g"), kbd.Chord("g")))
}

API surface

Package: kbd

Types

  • Style

Constants

  • ChordSeparator
  • SequenceSeparator

Functions

  • Render
  • RenderStyled
  • Chord
  • Sequence

Dependencies

  • glyph component theme (installed automatically)
  • github.com/charmbracelet/bubbletea@v1.3.10
  • github.com/charmbracelet/lipgloss@v1.1.0

Notes

Stateless rendering primitive. Call kbd.Render("Ctrl") or kbd.Chord("Ctrl", "K") from inside your existing View() and place the result wherever a keycap belongs. The atom reads theme.Default automatically; pass a Style to RenderStyled when you need to override a single color. Compose into hint rows with kbd.Sequence(kbd.Chord("g"), kbd.Chord("g")) for keystroke series.

See also

License

MIT, same as the rest of glyph.