You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
5 months ago | |
|---|---|---|
| .. | ||
| README.md | 5 months ago | |
| index.ts | 5 months ago | |
| kbd.css | 5 months ago | |
| kbd.svelte | 5 months ago | |
| types.ts | 5 months ago | |
README.md
Eidos Kbd
Keyboard shortcut typography primitive. Renders <kbd> with a small
chrome (border + background + inner padding) so the key looks like a
physical cap. Inline within prose — for shortcut hints, key sequences.
Superficie
<p>Press <Kbd>Ctrl</Kbd> + <Kbd>K</Kbd> to open search.</p>
<p>Hit <Kbd variant="outline" size="sm">Esc</Kbd> to dismiss.</p>
<p>Type <Kbd variant="ghost">tab</Kbd> to switch focus.</p>
Baseline
Origen: air/components/typography/kbd (rama morfo-runtime).
Adaptaciones para eidos:
- Default size aligned with foundation: air defaulted
size=2(small). Eidos reads--font-size-xsdirectly so the default pulls from the foundation contract instead of a numeric paso. - Variants added:
surface(default, filled with neutral element bg + border),outline(transparent + border),ghost(no chrome). Air had only one treatment. - Lower border emphasis preserved:
surfacekeeps theborder-bottom-width: 2px+ inset shadow trick to read like a physical cap;outlineandghostdrop it for cleaner inline flow. - Tokens:
--air-kbd-*→ consume the foundation directly (--style-code-*,--color-neutral-*,--font-size-{key}).
Comparativa
| Capacidad | UIX Kbd | Radix Themes Kbd | Chakra Kbd | Mantine Kbd | shadcn/ui Kbd |
|---|---|---|---|---|---|
| Visual key-cap chrome | Sí | Sí | Sí | Sí | Sí |
| Variants | surface / outline / ghost | size only | colorScheme | none | none |
| Size override | Sí | Sí | Sí | Sí | inherits font-size |
| Mono family | Sí (--style-code-font-family) |
Sí | Sí | Sí | Sí |
Inline semantics (<kbd>) |
Sí | Sí | Sí | Sí | Sí |
as polymorphism |
Sí | Sí | Sí | Sí | No |
Decisiones
- Default
surfacevariant: the chrome is the entire point of the primitive — bare mono text would just be<Code>. - Mono family from
--style-code-font-family: same source as Code / CodeBlock. Keeps the typography contract single-rooted. min-inline-size: 1.5em: ensures single-char keys ("K", "1") read as square caps and don't collapse to text width.- No platform key mapping: air did not ship
<Kbd cmd>to swapCtrl→⌘on macOS. Defer until a clear use case emerges; the consumer can branch onnavigator.platformtoday.
Eventos Sema
Kbd declara 0 eventos. Visual-only — el shortcut event lives on the consumer (a Toolbar button, a global key handler), no en el primitive de label.
Gaps
| Gap | Disposición | Detalle |
|---|---|---|
Platform-aware key swap (Ctrl ↔ ⌘) |
diferir | El consumer branches en navigator.platform. Si el patrón se repite, añadir un helper kbdForPlatform() o un wrapper docs-level. |
Sequence helper (<Kbd sequence={['Ctrl','K']} />) |
diferir | Composable inline — <Kbd>Ctrl</Kbd> + <Kbd>K</Kbd> cubre el caso sin contratar más superficie. |
| Sound on key press demo (educational) | descartar | El primitive es label, no input. Sound on press pertenece a una demo o componente Sound separado. |
Referencias
- Radix Themes Kbd: https://www.radix-ui.com/themes/docs/components/kbd
- Chakra UI Kbd: https://chakra-ui.com/docs/components/kbd
- Mantine Kbd: https://mantine.dev/core/kbd/
- MDN
<kbd>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd
Passive justification
Visual-only (scope: ['eidos']). Una sola part Provider, marker
[data-kbd]. Sin estados, sin keyboard, sin ARIA propia. La recipe
consume --style-code-* + --color-neutral-* del foundation + el
override --_kbd-font-size inline.