Data display
Keyboard key
A keyboard key, such as Ctrl or K, in a native <kbd>.
JxKbd
import 'package:jx_cli/ui.dart'
Available since 0.0.2
Preview
Search with CtrlK
When to use it
- Documenting shortcuts.
- A search field hint ("Ctrl K").
Minimal example
JxKbd('Esc')
Complete example
A full Jaspr component you can paste into a project.
import 'package:jaspr/dom.dart';
import 'package:jaspr/jaspr.dart';
import 'package:jx_cli/ui.dart';
class Shortcut extends StatelessComponent {
const Shortcut(this.keys, {super.key});
final List<String> keys;
@override
Component build(BuildContext context) {
return span(classes: 'inline-flex ai:center gap:1', [
for (final (i, key) in keys.indexed) ...[
if (i > 0) span(classes: 'c:gray-500', [.text('+')]),
JxKbd(key),
],
]);
}
}
Properties
| Property | Type | Default | Description |
|---|---|---|---|
keyLabel |
String |
required |
Text of the key. |
classes |
String? |
null |
Extra JX classes, appended after the component classes. |
Accessibility
-
A
<kbd>element, read as text.