@adamosuiteservices/ui 2.11.14 → 2.11.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/colors.css +1 -1
- package/dist/styles.css +1 -1
- package/dist/themes.css +1 -1
- package/docs/AI-GUIDE.md +321 -321
- package/docs/components/layout/sidebar.md +399 -399
- package/docs/components/layout/toaster.md +436 -436
- package/docs/components/ui/accordion-rounded.md +584 -584
- package/docs/components/ui/accordion.md +269 -269
- package/docs/components/ui/button-group.md +984 -984
- package/docs/components/ui/button.md +1137 -1137
- package/docs/components/ui/calendar.md +1159 -1159
- package/docs/components/ui/card.md +1455 -1455
- package/docs/components/ui/checkbox.md +292 -292
- package/docs/components/ui/collapsible.md +323 -323
- package/docs/components/ui/command.md +454 -454
- package/docs/components/ui/context-menu.md +540 -540
- package/docs/components/ui/dialog.md +628 -628
- package/docs/components/ui/dropdown-menu.md +709 -709
- package/docs/components/ui/field.md +706 -706
- package/docs/components/ui/hover-card.md +446 -446
- package/docs/components/ui/input.md +362 -362
- package/docs/components/ui/kbd.md +434 -434
- package/docs/components/ui/label.md +359 -359
- package/docs/components/ui/pagination.md +650 -650
- package/docs/components/ui/popover.md +536 -536
- package/docs/components/ui/progress.md +182 -182
- package/docs/components/ui/radio-group.md +311 -311
- package/docs/components/ui/select.md +352 -352
- package/docs/components/ui/separator.md +214 -214
- package/docs/components/ui/sheet.md +142 -142
- package/docs/components/ui/skeleton.md +140 -140
- package/docs/components/ui/slider.md +341 -341
- package/docs/components/ui/spinner.md +170 -170
- package/docs/components/ui/switch.md +408 -408
- package/docs/components/ui/tabs-underline.md +106 -106
- package/docs/components/ui/tabs.md +122 -122
- package/docs/components/ui/textarea.md +243 -243
- package/docs/components/ui/toggle.md +237 -237
- package/docs/components/ui/tooltip.md +317 -317
- package/docs/components/ui/typography.md +280 -280
- package/package.json +1 -1
|
@@ -1,434 +1,434 @@
|
|
|
1
|
-
# Kbd
|
|
2
|
-
|
|
3
|
-
Representa teclas del teclado con estilo visual. Ideal para documentación, tooltips, atajos de teclado y ayuda contextual.
|
|
4
|
-
|
|
5
|
-
## Descripción
|
|
6
|
-
|
|
7
|
-
El componente `Kbd` representa teclas del teclado con estilo visual.
|
|
8
|
-
|
|
9
|
-
## Importación
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { Kbd, KbdGroup } from "@adamosuiteservices/ui/kbd";
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Anatomía
|
|
16
|
-
|
|
17
|
-
```tsx
|
|
18
|
-
<p>
|
|
19
|
-
Press <Kbd>Ctrl</Kbd> + <Kbd>C</Kbd> to copy
|
|
20
|
-
</p>
|
|
21
|
-
|
|
22
|
-
<KbdGroup>
|
|
23
|
-
<Kbd>⌘</Kbd>
|
|
24
|
-
<Kbd>K</Kbd>
|
|
25
|
-
</KbdGroup>
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
**Componentes**: 2 (Kbd, KbdGroup)
|
|
29
|
-
|
|
30
|
-
## Props
|
|
31
|
-
|
|
32
|
-
### Kbd
|
|
33
|
-
|
|
34
|
-
| Prop | Tipo | Descripción |
|
|
35
|
-
| ----------- | -------- | ---------------------------------- |
|
|
36
|
-
| `className` | `string` | Clases CSS adicionales |
|
|
37
|
-
| ...props | - | Todas las props nativas de `<kbd>` |
|
|
38
|
-
|
|
39
|
-
### KbdGroup
|
|
40
|
-
|
|
41
|
-
| Prop | Tipo | Descripción |
|
|
42
|
-
| ----------- | -------- | ---------------------------------- |
|
|
43
|
-
| `className` | `string` | Clases CSS adicionales |
|
|
44
|
-
| ...props | - | Todas las props nativas de `<div>` |
|
|
45
|
-
|
|
46
|
-
## Patrones de Uso
|
|
47
|
-
|
|
48
|
-
### Básico
|
|
49
|
-
|
|
50
|
-
```tsx
|
|
51
|
-
<div className="flex items-center gap-4">
|
|
52
|
-
<Kbd>Ctrl</Kbd>
|
|
53
|
-
<Kbd>⌘</Kbd>
|
|
54
|
-
<Kbd>⇧</Kbd>
|
|
55
|
-
<Kbd>⌥</Kbd>
|
|
56
|
-
<Kbd>⌃</Kbd>
|
|
57
|
-
</div>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Con Modificadores
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
<KbdGroup>
|
|
64
|
-
<Kbd>Ctrl</Kbd>
|
|
65
|
-
<span>+</span>
|
|
66
|
-
<Kbd>B</Kbd>
|
|
67
|
-
</KbdGroup>
|
|
68
|
-
|
|
69
|
-
<KbdGroup>
|
|
70
|
-
<Kbd>Ctrl</Kbd>
|
|
71
|
-
<span>+</span>
|
|
72
|
-
<Kbd>Shift</Kbd>
|
|
73
|
-
<span>+</span>
|
|
74
|
-
<Kbd>P</Kbd>
|
|
75
|
-
</KbdGroup>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Inline con Texto
|
|
79
|
-
|
|
80
|
-
```tsx
|
|
81
|
-
<p className="text-sm text-muted-foreground">
|
|
82
|
-
Use{" "}
|
|
83
|
-
<KbdGroup>
|
|
84
|
-
<Kbd>Ctrl</Kbd>
|
|
85
|
-
<Kbd>K</Kbd>
|
|
86
|
-
</KbdGroup>{" "}
|
|
87
|
-
to open the command palette
|
|
88
|
-
</p>
|
|
89
|
-
|
|
90
|
-
<p className="text-sm">
|
|
91
|
-
Press{" "}
|
|
92
|
-
<KbdGroup>
|
|
93
|
-
<Kbd>⌘</Kbd>
|
|
94
|
-
<Kbd>K</Kbd>
|
|
95
|
-
</KbdGroup>{" "}
|
|
96
|
-
to search
|
|
97
|
-
</p>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### En Botones
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
import { Button } from "@adamosuiteservices/ui/button";
|
|
104
|
-
|
|
105
|
-
<Button variant="outline" size="sm" className="pr-2">
|
|
106
|
-
Accept <Kbd>⏎</Kbd>
|
|
107
|
-
</Button>
|
|
108
|
-
|
|
109
|
-
<Button variant="outline" size="sm" className="pr-2">
|
|
110
|
-
Cancel <Kbd>Esc</Kbd>
|
|
111
|
-
</Button>
|
|
112
|
-
|
|
113
|
-
<Button variant="outline" size="sm" className="pr-2">
|
|
114
|
-
Save <Kbd>⌘</Kbd><Kbd>S</Kbd>
|
|
115
|
-
</Button>
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### En Tooltips
|
|
119
|
-
|
|
120
|
-
```tsx
|
|
121
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "@adamosuiteservices/ui/tooltip";
|
|
122
|
-
import { Button } from "@adamosuiteservices/ui/button";
|
|
123
|
-
|
|
124
|
-
<Tooltip>
|
|
125
|
-
<TooltipTrigger asChild>
|
|
126
|
-
<Button size="sm" variant="outline">
|
|
127
|
-
Save
|
|
128
|
-
</Button>
|
|
129
|
-
</TooltipTrigger>
|
|
130
|
-
<TooltipContent>
|
|
131
|
-
<div className="flex items-center gap-2">
|
|
132
|
-
Save Changes <Kbd>S</Kbd>
|
|
133
|
-
</div>
|
|
134
|
-
</TooltipContent>
|
|
135
|
-
</Tooltip>
|
|
136
|
-
|
|
137
|
-
<Tooltip>
|
|
138
|
-
<TooltipTrigger asChild>
|
|
139
|
-
<Button size="sm" variant="outline">
|
|
140
|
-
Copy
|
|
141
|
-
</Button>
|
|
142
|
-
</TooltipTrigger>
|
|
143
|
-
<TooltipContent>
|
|
144
|
-
<div className="flex items-center gap-2">
|
|
145
|
-
Copy Selection{" "}
|
|
146
|
-
<KbdGroup>
|
|
147
|
-
<Kbd>⌘</Kbd>
|
|
148
|
-
<Kbd>C</Kbd>
|
|
149
|
-
</KbdGroup>
|
|
150
|
-
</div>
|
|
151
|
-
</TooltipContent>
|
|
152
|
-
</Tooltip>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### En Input Group
|
|
156
|
-
|
|
157
|
-
```tsx
|
|
158
|
-
import { InputGroup, InputGroupInput, InputGroupAddon } from "@adamosuiteservices/ui/input-group";
|
|
159
|
-
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
160
|
-
|
|
161
|
-
<InputGroup>
|
|
162
|
-
<InputGroupInput placeholder="Search..." />
|
|
163
|
-
<InputGroupAddon>
|
|
164
|
-
<Icon symbol="search" className="text-lg" />
|
|
165
|
-
</InputGroupAddon>
|
|
166
|
-
<InputGroupAddon align="inline-end">
|
|
167
|
-
<Kbd>⌘</Kbd>
|
|
168
|
-
<Kbd>K</Kbd>
|
|
169
|
-
</InputGroupAddon>
|
|
170
|
-
</InputGroup>
|
|
171
|
-
|
|
172
|
-
<InputGroup>
|
|
173
|
-
<InputGroupInput placeholder="Quick actions..." />
|
|
174
|
-
<InputGroupAddon align="inline-end">
|
|
175
|
-
<KbdGroup>
|
|
176
|
-
<Kbd>Ctrl</Kbd>
|
|
177
|
-
<Kbd>Space</Kbd>
|
|
178
|
-
</KbdGroup>
|
|
179
|
-
</InputGroupAddon>
|
|
180
|
-
</InputGroup>
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
### Teclas de Navegación
|
|
184
|
-
|
|
185
|
-
```tsx
|
|
186
|
-
<div className="flex flex-col gap-2">
|
|
187
|
-
<h4 className="text-sm font-medium">Arrow Keys</h4>
|
|
188
|
-
<div className="flex gap-2">
|
|
189
|
-
<Kbd>↑</Kbd>
|
|
190
|
-
<Kbd>↓</Kbd>
|
|
191
|
-
<Kbd>←</Kbd>
|
|
192
|
-
<Kbd>→</Kbd>
|
|
193
|
-
</div>
|
|
194
|
-
</div>
|
|
195
|
-
|
|
196
|
-
<div className="flex flex-col gap-2">
|
|
197
|
-
<h4 className="text-sm font-medium">Special Keys</h4>
|
|
198
|
-
<div className="flex gap-2">
|
|
199
|
-
<Kbd>Tab</Kbd>
|
|
200
|
-
<Kbd>Space</Kbd>
|
|
201
|
-
<Kbd>Enter</Kbd>
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
<div className="flex flex-col gap-2">
|
|
206
|
-
<h4 className="text-sm font-medium">Function Keys</h4>
|
|
207
|
-
<div className="flex gap-2">
|
|
208
|
-
<Kbd>F1</Kbd>
|
|
209
|
-
<Kbd>F2</Kbd>
|
|
210
|
-
<Kbd>F12</Kbd>
|
|
211
|
-
</div>
|
|
212
|
-
</div>
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Atajos Complejos con Descripciones
|
|
216
|
-
|
|
217
|
-
```tsx
|
|
218
|
-
<div className="flex flex-col gap-4">
|
|
219
|
-
<div className="flex flex-col gap-2">
|
|
220
|
-
<h4 className="text-sm font-medium">Editor Shortcuts</h4>
|
|
221
|
-
<div className="flex flex-col gap-2 text-sm">
|
|
222
|
-
<div className="flex items-center justify-between">
|
|
223
|
-
<span>Duplicate line</span>
|
|
224
|
-
<KbdGroup>
|
|
225
|
-
<Kbd>Shift</Kbd>
|
|
226
|
-
<Kbd>Alt</Kbd>
|
|
227
|
-
<Kbd>↓</Kbd>
|
|
228
|
-
</KbdGroup>
|
|
229
|
-
</div>
|
|
230
|
-
<div className="flex items-center justify-between">
|
|
231
|
-
<span>Multi-cursor</span>
|
|
232
|
-
<KbdGroup>
|
|
233
|
-
<Kbd>Ctrl</Kbd>
|
|
234
|
-
<Kbd>Alt</Kbd>
|
|
235
|
-
<Kbd>↓</Kbd>
|
|
236
|
-
</KbdGroup>
|
|
237
|
-
</div>
|
|
238
|
-
<div className="flex items-center justify-between">
|
|
239
|
-
<span>Go to definition</span>
|
|
240
|
-
<KbdGroup>
|
|
241
|
-
<Kbd>F12</Kbd>
|
|
242
|
-
</KbdGroup>
|
|
243
|
-
</div>
|
|
244
|
-
</div>
|
|
245
|
-
</div>
|
|
246
|
-
|
|
247
|
-
<div className="flex flex-col gap-2">
|
|
248
|
-
<h4 className="text-sm font-medium">Browser Shortcuts</h4>
|
|
249
|
-
<div className="flex flex-col gap-2 text-sm">
|
|
250
|
-
<div className="flex items-center justify-between">
|
|
251
|
-
<span>New tab</span>
|
|
252
|
-
<KbdGroup>
|
|
253
|
-
<Kbd>Ctrl</Kbd>
|
|
254
|
-
<Kbd>T</Kbd>
|
|
255
|
-
</KbdGroup>
|
|
256
|
-
</div>
|
|
257
|
-
<div className="flex items-center justify-between">
|
|
258
|
-
<span>Hard refresh</span>
|
|
259
|
-
<KbdGroup>
|
|
260
|
-
<Kbd>Ctrl</Kbd>
|
|
261
|
-
<Kbd>Shift</Kbd>
|
|
262
|
-
<Kbd>R</Kbd>
|
|
263
|
-
</KbdGroup>
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
</div>
|
|
267
|
-
</div>
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
### Con Iconos
|
|
271
|
-
|
|
272
|
-
```tsx
|
|
273
|
-
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
274
|
-
|
|
275
|
-
<div className="flex items-center gap-4">
|
|
276
|
-
<Kbd><Icon symbol="save" className="text-sm" /></Kbd>
|
|
277
|
-
<Kbd><Icon symbol="content_copy" className="text-sm" /></Kbd>
|
|
278
|
-
<Kbd><Icon symbol="settings" className="text-sm" /></Kbd>
|
|
279
|
-
</div>
|
|
280
|
-
|
|
281
|
-
<div className="flex items-center gap-2">
|
|
282
|
-
<span className="text-sm">Quick actions:</span>
|
|
283
|
-
<KbdGroup>
|
|
284
|
-
<Kbd><Icon symbol="save" className="text-sm" /></Kbd>
|
|
285
|
-
<Kbd>S</Kbd>
|
|
286
|
-
</KbdGroup>
|
|
287
|
-
<KbdGroup>
|
|
288
|
-
<Kbd><Icon symbol="content_copy" className="text-sm" /></Kbd>
|
|
289
|
-
<Kbd>C</Kbd>
|
|
290
|
-
</KbdGroup>
|
|
291
|
-
</div>
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### En Contexto (Cards)
|
|
295
|
-
|
|
296
|
-
```tsx
|
|
297
|
-
<div className="rounded-lg border p-4">
|
|
298
|
-
<h3 className="text-lg font-semibold mb-2">Command Palette</h3>
|
|
299
|
-
<p className="text-sm text-muted-foreground mb-4">
|
|
300
|
-
Quickly access commands and navigate your workspace.
|
|
301
|
-
</p>
|
|
302
|
-
<div className="flex items-center gap-2 text-sm">
|
|
303
|
-
<span>Open with</span>
|
|
304
|
-
<KbdGroup>
|
|
305
|
-
<Kbd>⌘</Kbd>
|
|
306
|
-
<Kbd>K</Kbd>
|
|
307
|
-
</KbdGroup>
|
|
308
|
-
<span>or</span>
|
|
309
|
-
<KbdGroup>
|
|
310
|
-
<Kbd>Ctrl</Kbd>
|
|
311
|
-
<Kbd>Shift</Kbd>
|
|
312
|
-
<Kbd>P</Kbd>
|
|
313
|
-
</KbdGroup>
|
|
314
|
-
</div>
|
|
315
|
-
</div>
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
## Casos de Uso Comunes
|
|
319
|
-
|
|
320
|
-
**Documentation**: Documentar atajos de teclado en docs
|
|
321
|
-
**Tooltips**: Mostrar shortcuts en tooltips de botones
|
|
322
|
-
**Help sections**: Secciones de ayuda con atajos
|
|
323
|
-
**Command palettes**: Mostrar shortcuts junto a comandos
|
|
324
|
-
**Onboarding**: Tutoriales con atajos de teclado
|
|
325
|
-
**Input hints**: Hints en inputs (ej: "Press ⌘K to search")
|
|
326
|
-
|
|
327
|
-
## Estilos Base
|
|
328
|
-
|
|
329
|
-
### Estilos Kbd
|
|
330
|
-
|
|
331
|
-
- **Background**: `bg-muted`
|
|
332
|
-
- **Color**: `text-muted-foreground`
|
|
333
|
-
- **Height**: `h-5` (~20px)
|
|
334
|
-
- **Min Width**: `min-w-5` (square mínimo)
|
|
335
|
-
- **Padding**: `px-1`
|
|
336
|
-
- **Font**: `font-sans text-xs font-medium`
|
|
337
|
-
- **Border**: `rounded-sm`
|
|
338
|
-
- **Select**: `select-none`, `pointer-events-none`
|
|
339
|
-
- **SVG**: Auto-sized to `size-3` si no tiene clase
|
|
340
|
-
|
|
341
|
-
### Estilos KbdGroup
|
|
342
|
-
|
|
343
|
-
- **Display**: `inline-flex`
|
|
344
|
-
- **Align**: `items-center`
|
|
345
|
-
- **Gap**: `gap-1`
|
|
346
|
-
|
|
347
|
-
### Tooltip Context
|
|
348
|
-
|
|
349
|
-
Cuando está dentro de Tooltip:
|
|
350
|
-
|
|
351
|
-
- **Background**: `bg-background/20`
|
|
352
|
-
- **Color**: `text-background`
|
|
353
|
-
- **Dark mode**: `dark:bg-background/10`
|
|
354
|
-
|
|
355
|
-
## Símbolos Comunes
|
|
356
|
-
|
|
357
|
-
### Modificadores Mac
|
|
358
|
-
|
|
359
|
-
- `⌘` - Command
|
|
360
|
-
- `⇧` - Shift
|
|
361
|
-
- `⌥` - Option/Alt
|
|
362
|
-
- `⌃` - Control
|
|
363
|
-
- `⏎` - Return
|
|
364
|
-
- `⌫` - Delete
|
|
365
|
-
|
|
366
|
-
### Flechas
|
|
367
|
-
|
|
368
|
-
- `↑` - Up
|
|
369
|
-
- `↓` - Down
|
|
370
|
-
- `←` - Left
|
|
371
|
-
- `→` - Right
|
|
372
|
-
|
|
373
|
-
### Otros
|
|
374
|
-
|
|
375
|
-
- `⎵` - Space
|
|
376
|
-
- `⇥` - Tab
|
|
377
|
-
- `⎋` - Escape
|
|
378
|
-
|
|
379
|
-
## Accesibilidad
|
|
380
|
-
|
|
381
|
-
- ✅ **Semantic HTML**: Usa `<kbd>` nativo (semántico)
|
|
382
|
-
- ✅ **Non-interactive**: `pointer-events-none` por defecto
|
|
383
|
-
- ✅ **Screen readers**: Texto es leído normalmente
|
|
384
|
-
- ✅ **No focus**: No recibe focus (solo visual)
|
|
385
|
-
- ⚠️ **Context**: Siempre acompaña con texto descriptivo
|
|
386
|
-
|
|
387
|
-
## Notas de Implementación
|
|
388
|
-
|
|
389
|
-
- **HTML nativo**: Basado en `<kbd>` elemento nativo
|
|
390
|
-
- **KbdGroup**: Es un `<kbd>` contenedor, no `<div>` (semántico)
|
|
391
|
-
- **Auto-sizing**: SVGs se redimensionan automáticamente a `size-3`
|
|
392
|
-
- **Tooltip-aware**: Estilos especiales cuando está dentro de Tooltip
|
|
393
|
-
- **Non-interactive**: No recibe eventos de pointer por defecto
|
|
394
|
-
- **Select-none**: No se puede seleccionar texto
|
|
395
|
-
- **Monospace**: Usa `font-sans` no monospace
|
|
396
|
-
- **Min square**: `min-w-5` asegura que single chars sean cuadrados
|
|
397
|
-
|
|
398
|
-
## KbdGroup vs Multiple Kbd
|
|
399
|
-
|
|
400
|
-
```tsx
|
|
401
|
-
{
|
|
402
|
-
/* Con KbdGroup - semanticamente agrupados */
|
|
403
|
-
}
|
|
404
|
-
<KbdGroup>
|
|
405
|
-
<Kbd>Ctrl</Kbd>
|
|
406
|
-
<Kbd>K</Kbd>
|
|
407
|
-
</KbdGroup>;
|
|
408
|
-
|
|
409
|
-
{
|
|
410
|
-
/* Sin KbdGroup - separados */
|
|
411
|
-
}
|
|
412
|
-
<span>
|
|
413
|
-
<Kbd>Ctrl</Kbd> + <Kbd>K</Kbd>
|
|
414
|
-
</span>;
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
**Usa KbdGroup cuando**: Las teclas se presionan simultáneamente (shortcut)
|
|
418
|
-
**No uses KbdGroup cuando**: Las teclas son alternativas o secuenciales
|
|
419
|
-
|
|
420
|
-
## Troubleshooting
|
|
421
|
-
|
|
422
|
-
**Kbd no se ve**: Verifica que tenga contenido (texto o icono)
|
|
423
|
-
**Tamaño inconsistente**: Usa `min-w-5` para asegurar cuadrado en single chars
|
|
424
|
-
**Icono muy grande**: Los SVGs se redimensionan automáticamente a `size-3`
|
|
425
|
-
**No se ve en Tooltip**: Los estilos de Tooltip aplican automáticamente
|
|
426
|
-
**Spacing inconsistente**: KbdGroup tiene `gap-1`, ajusta con className si necesario
|
|
427
|
-
**Seleccionable**: Verifica que tenga `select-none` aplicado
|
|
428
|
-
**Background no se ve**: Verifica tema y color `bg-muted`
|
|
429
|
-
**Muy alto**: Altura fija `h-5`, no cambies sin ajustar padding
|
|
430
|
-
|
|
431
|
-
## Referencias
|
|
432
|
-
|
|
433
|
-
- **MDN Kbd**: <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd>
|
|
434
|
-
- **Unicode Symbols**: <https://www.unicode.org/charts/>
|
|
1
|
+
# Kbd
|
|
2
|
+
|
|
3
|
+
Representa teclas del teclado con estilo visual. Ideal para documentación, tooltips, atajos de teclado y ayuda contextual.
|
|
4
|
+
|
|
5
|
+
## Descripción
|
|
6
|
+
|
|
7
|
+
El componente `Kbd` representa teclas del teclado con estilo visual.
|
|
8
|
+
|
|
9
|
+
## Importación
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { Kbd, KbdGroup } from "@adamosuiteservices/ui/kbd";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Anatomía
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<p>
|
|
19
|
+
Press <Kbd>Ctrl</Kbd> + <Kbd>C</Kbd> to copy
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<KbdGroup>
|
|
23
|
+
<Kbd>⌘</Kbd>
|
|
24
|
+
<Kbd>K</Kbd>
|
|
25
|
+
</KbdGroup>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Componentes**: 2 (Kbd, KbdGroup)
|
|
29
|
+
|
|
30
|
+
## Props
|
|
31
|
+
|
|
32
|
+
### Kbd
|
|
33
|
+
|
|
34
|
+
| Prop | Tipo | Descripción |
|
|
35
|
+
| ----------- | -------- | ---------------------------------- |
|
|
36
|
+
| `className` | `string` | Clases CSS adicionales |
|
|
37
|
+
| ...props | - | Todas las props nativas de `<kbd>` |
|
|
38
|
+
|
|
39
|
+
### KbdGroup
|
|
40
|
+
|
|
41
|
+
| Prop | Tipo | Descripción |
|
|
42
|
+
| ----------- | -------- | ---------------------------------- |
|
|
43
|
+
| `className` | `string` | Clases CSS adicionales |
|
|
44
|
+
| ...props | - | Todas las props nativas de `<div>` |
|
|
45
|
+
|
|
46
|
+
## Patrones de Uso
|
|
47
|
+
|
|
48
|
+
### Básico
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<div className="flex items-center gap-4">
|
|
52
|
+
<Kbd>Ctrl</Kbd>
|
|
53
|
+
<Kbd>⌘</Kbd>
|
|
54
|
+
<Kbd>⇧</Kbd>
|
|
55
|
+
<Kbd>⌥</Kbd>
|
|
56
|
+
<Kbd>⌃</Kbd>
|
|
57
|
+
</div>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Con Modificadores
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
<KbdGroup>
|
|
64
|
+
<Kbd>Ctrl</Kbd>
|
|
65
|
+
<span>+</span>
|
|
66
|
+
<Kbd>B</Kbd>
|
|
67
|
+
</KbdGroup>
|
|
68
|
+
|
|
69
|
+
<KbdGroup>
|
|
70
|
+
<Kbd>Ctrl</Kbd>
|
|
71
|
+
<span>+</span>
|
|
72
|
+
<Kbd>Shift</Kbd>
|
|
73
|
+
<span>+</span>
|
|
74
|
+
<Kbd>P</Kbd>
|
|
75
|
+
</KbdGroup>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Inline con Texto
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<p className="text-sm text-muted-foreground">
|
|
82
|
+
Use{" "}
|
|
83
|
+
<KbdGroup>
|
|
84
|
+
<Kbd>Ctrl</Kbd>
|
|
85
|
+
<Kbd>K</Kbd>
|
|
86
|
+
</KbdGroup>{" "}
|
|
87
|
+
to open the command palette
|
|
88
|
+
</p>
|
|
89
|
+
|
|
90
|
+
<p className="text-sm">
|
|
91
|
+
Press{" "}
|
|
92
|
+
<KbdGroup>
|
|
93
|
+
<Kbd>⌘</Kbd>
|
|
94
|
+
<Kbd>K</Kbd>
|
|
95
|
+
</KbdGroup>{" "}
|
|
96
|
+
to search
|
|
97
|
+
</p>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### En Botones
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { Button } from "@adamosuiteservices/ui/button";
|
|
104
|
+
|
|
105
|
+
<Button variant="outline" size="sm" className="pr-2">
|
|
106
|
+
Accept <Kbd>⏎</Kbd>
|
|
107
|
+
</Button>
|
|
108
|
+
|
|
109
|
+
<Button variant="outline" size="sm" className="pr-2">
|
|
110
|
+
Cancel <Kbd>Esc</Kbd>
|
|
111
|
+
</Button>
|
|
112
|
+
|
|
113
|
+
<Button variant="outline" size="sm" className="pr-2">
|
|
114
|
+
Save <Kbd>⌘</Kbd><Kbd>S</Kbd>
|
|
115
|
+
</Button>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### En Tooltips
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "@adamosuiteservices/ui/tooltip";
|
|
122
|
+
import { Button } from "@adamosuiteservices/ui/button";
|
|
123
|
+
|
|
124
|
+
<Tooltip>
|
|
125
|
+
<TooltipTrigger asChild>
|
|
126
|
+
<Button size="sm" variant="outline">
|
|
127
|
+
Save
|
|
128
|
+
</Button>
|
|
129
|
+
</TooltipTrigger>
|
|
130
|
+
<TooltipContent>
|
|
131
|
+
<div className="flex items-center gap-2">
|
|
132
|
+
Save Changes <Kbd>S</Kbd>
|
|
133
|
+
</div>
|
|
134
|
+
</TooltipContent>
|
|
135
|
+
</Tooltip>
|
|
136
|
+
|
|
137
|
+
<Tooltip>
|
|
138
|
+
<TooltipTrigger asChild>
|
|
139
|
+
<Button size="sm" variant="outline">
|
|
140
|
+
Copy
|
|
141
|
+
</Button>
|
|
142
|
+
</TooltipTrigger>
|
|
143
|
+
<TooltipContent>
|
|
144
|
+
<div className="flex items-center gap-2">
|
|
145
|
+
Copy Selection{" "}
|
|
146
|
+
<KbdGroup>
|
|
147
|
+
<Kbd>⌘</Kbd>
|
|
148
|
+
<Kbd>C</Kbd>
|
|
149
|
+
</KbdGroup>
|
|
150
|
+
</div>
|
|
151
|
+
</TooltipContent>
|
|
152
|
+
</Tooltip>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### En Input Group
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { InputGroup, InputGroupInput, InputGroupAddon } from "@adamosuiteservices/ui/input-group";
|
|
159
|
+
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
160
|
+
|
|
161
|
+
<InputGroup>
|
|
162
|
+
<InputGroupInput placeholder="Search..." />
|
|
163
|
+
<InputGroupAddon>
|
|
164
|
+
<Icon symbol="search" className="text-lg" />
|
|
165
|
+
</InputGroupAddon>
|
|
166
|
+
<InputGroupAddon align="inline-end">
|
|
167
|
+
<Kbd>⌘</Kbd>
|
|
168
|
+
<Kbd>K</Kbd>
|
|
169
|
+
</InputGroupAddon>
|
|
170
|
+
</InputGroup>
|
|
171
|
+
|
|
172
|
+
<InputGroup>
|
|
173
|
+
<InputGroupInput placeholder="Quick actions..." />
|
|
174
|
+
<InputGroupAddon align="inline-end">
|
|
175
|
+
<KbdGroup>
|
|
176
|
+
<Kbd>Ctrl</Kbd>
|
|
177
|
+
<Kbd>Space</Kbd>
|
|
178
|
+
</KbdGroup>
|
|
179
|
+
</InputGroupAddon>
|
|
180
|
+
</InputGroup>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Teclas de Navegación
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
<div className="flex flex-col gap-2">
|
|
187
|
+
<h4 className="text-sm font-medium">Arrow Keys</h4>
|
|
188
|
+
<div className="flex gap-2">
|
|
189
|
+
<Kbd>↑</Kbd>
|
|
190
|
+
<Kbd>↓</Kbd>
|
|
191
|
+
<Kbd>←</Kbd>
|
|
192
|
+
<Kbd>→</Kbd>
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div className="flex flex-col gap-2">
|
|
197
|
+
<h4 className="text-sm font-medium">Special Keys</h4>
|
|
198
|
+
<div className="flex gap-2">
|
|
199
|
+
<Kbd>Tab</Kbd>
|
|
200
|
+
<Kbd>Space</Kbd>
|
|
201
|
+
<Kbd>Enter</Kbd>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
|
|
205
|
+
<div className="flex flex-col gap-2">
|
|
206
|
+
<h4 className="text-sm font-medium">Function Keys</h4>
|
|
207
|
+
<div className="flex gap-2">
|
|
208
|
+
<Kbd>F1</Kbd>
|
|
209
|
+
<Kbd>F2</Kbd>
|
|
210
|
+
<Kbd>F12</Kbd>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Atajos Complejos con Descripciones
|
|
216
|
+
|
|
217
|
+
```tsx
|
|
218
|
+
<div className="flex flex-col gap-4">
|
|
219
|
+
<div className="flex flex-col gap-2">
|
|
220
|
+
<h4 className="text-sm font-medium">Editor Shortcuts</h4>
|
|
221
|
+
<div className="flex flex-col gap-2 text-sm">
|
|
222
|
+
<div className="flex items-center justify-between">
|
|
223
|
+
<span>Duplicate line</span>
|
|
224
|
+
<KbdGroup>
|
|
225
|
+
<Kbd>Shift</Kbd>
|
|
226
|
+
<Kbd>Alt</Kbd>
|
|
227
|
+
<Kbd>↓</Kbd>
|
|
228
|
+
</KbdGroup>
|
|
229
|
+
</div>
|
|
230
|
+
<div className="flex items-center justify-between">
|
|
231
|
+
<span>Multi-cursor</span>
|
|
232
|
+
<KbdGroup>
|
|
233
|
+
<Kbd>Ctrl</Kbd>
|
|
234
|
+
<Kbd>Alt</Kbd>
|
|
235
|
+
<Kbd>↓</Kbd>
|
|
236
|
+
</KbdGroup>
|
|
237
|
+
</div>
|
|
238
|
+
<div className="flex items-center justify-between">
|
|
239
|
+
<span>Go to definition</span>
|
|
240
|
+
<KbdGroup>
|
|
241
|
+
<Kbd>F12</Kbd>
|
|
242
|
+
</KbdGroup>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
|
|
247
|
+
<div className="flex flex-col gap-2">
|
|
248
|
+
<h4 className="text-sm font-medium">Browser Shortcuts</h4>
|
|
249
|
+
<div className="flex flex-col gap-2 text-sm">
|
|
250
|
+
<div className="flex items-center justify-between">
|
|
251
|
+
<span>New tab</span>
|
|
252
|
+
<KbdGroup>
|
|
253
|
+
<Kbd>Ctrl</Kbd>
|
|
254
|
+
<Kbd>T</Kbd>
|
|
255
|
+
</KbdGroup>
|
|
256
|
+
</div>
|
|
257
|
+
<div className="flex items-center justify-between">
|
|
258
|
+
<span>Hard refresh</span>
|
|
259
|
+
<KbdGroup>
|
|
260
|
+
<Kbd>Ctrl</Kbd>
|
|
261
|
+
<Kbd>Shift</Kbd>
|
|
262
|
+
<Kbd>R</Kbd>
|
|
263
|
+
</KbdGroup>
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
</div>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Con Iconos
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import { Icon } from "@adamosuiteservices/ui/icon";
|
|
274
|
+
|
|
275
|
+
<div className="flex items-center gap-4">
|
|
276
|
+
<Kbd><Icon symbol="save" className="text-sm" /></Kbd>
|
|
277
|
+
<Kbd><Icon symbol="content_copy" className="text-sm" /></Kbd>
|
|
278
|
+
<Kbd><Icon symbol="settings" className="text-sm" /></Kbd>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div className="flex items-center gap-2">
|
|
282
|
+
<span className="text-sm">Quick actions:</span>
|
|
283
|
+
<KbdGroup>
|
|
284
|
+
<Kbd><Icon symbol="save" className="text-sm" /></Kbd>
|
|
285
|
+
<Kbd>S</Kbd>
|
|
286
|
+
</KbdGroup>
|
|
287
|
+
<KbdGroup>
|
|
288
|
+
<Kbd><Icon symbol="content_copy" className="text-sm" /></Kbd>
|
|
289
|
+
<Kbd>C</Kbd>
|
|
290
|
+
</KbdGroup>
|
|
291
|
+
</div>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### En Contexto (Cards)
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
<div className="rounded-lg border p-4">
|
|
298
|
+
<h3 className="text-lg font-semibold mb-2">Command Palette</h3>
|
|
299
|
+
<p className="text-sm text-muted-foreground mb-4">
|
|
300
|
+
Quickly access commands and navigate your workspace.
|
|
301
|
+
</p>
|
|
302
|
+
<div className="flex items-center gap-2 text-sm">
|
|
303
|
+
<span>Open with</span>
|
|
304
|
+
<KbdGroup>
|
|
305
|
+
<Kbd>⌘</Kbd>
|
|
306
|
+
<Kbd>K</Kbd>
|
|
307
|
+
</KbdGroup>
|
|
308
|
+
<span>or</span>
|
|
309
|
+
<KbdGroup>
|
|
310
|
+
<Kbd>Ctrl</Kbd>
|
|
311
|
+
<Kbd>Shift</Kbd>
|
|
312
|
+
<Kbd>P</Kbd>
|
|
313
|
+
</KbdGroup>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Casos de Uso Comunes
|
|
319
|
+
|
|
320
|
+
**Documentation**: Documentar atajos de teclado en docs
|
|
321
|
+
**Tooltips**: Mostrar shortcuts en tooltips de botones
|
|
322
|
+
**Help sections**: Secciones de ayuda con atajos
|
|
323
|
+
**Command palettes**: Mostrar shortcuts junto a comandos
|
|
324
|
+
**Onboarding**: Tutoriales con atajos de teclado
|
|
325
|
+
**Input hints**: Hints en inputs (ej: "Press ⌘K to search")
|
|
326
|
+
|
|
327
|
+
## Estilos Base
|
|
328
|
+
|
|
329
|
+
### Estilos Kbd
|
|
330
|
+
|
|
331
|
+
- **Background**: `bg-muted`
|
|
332
|
+
- **Color**: `text-muted-foreground`
|
|
333
|
+
- **Height**: `h-5` (~20px)
|
|
334
|
+
- **Min Width**: `min-w-5` (square mínimo)
|
|
335
|
+
- **Padding**: `px-1`
|
|
336
|
+
- **Font**: `font-sans text-xs font-medium`
|
|
337
|
+
- **Border**: `rounded-sm`
|
|
338
|
+
- **Select**: `select-none`, `pointer-events-none`
|
|
339
|
+
- **SVG**: Auto-sized to `size-3` si no tiene clase
|
|
340
|
+
|
|
341
|
+
### Estilos KbdGroup
|
|
342
|
+
|
|
343
|
+
- **Display**: `inline-flex`
|
|
344
|
+
- **Align**: `items-center`
|
|
345
|
+
- **Gap**: `gap-1`
|
|
346
|
+
|
|
347
|
+
### Tooltip Context
|
|
348
|
+
|
|
349
|
+
Cuando está dentro de Tooltip:
|
|
350
|
+
|
|
351
|
+
- **Background**: `bg-background/20`
|
|
352
|
+
- **Color**: `text-background`
|
|
353
|
+
- **Dark mode**: `dark:bg-background/10`
|
|
354
|
+
|
|
355
|
+
## Símbolos Comunes
|
|
356
|
+
|
|
357
|
+
### Modificadores Mac
|
|
358
|
+
|
|
359
|
+
- `⌘` - Command
|
|
360
|
+
- `⇧` - Shift
|
|
361
|
+
- `⌥` - Option/Alt
|
|
362
|
+
- `⌃` - Control
|
|
363
|
+
- `⏎` - Return
|
|
364
|
+
- `⌫` - Delete
|
|
365
|
+
|
|
366
|
+
### Flechas
|
|
367
|
+
|
|
368
|
+
- `↑` - Up
|
|
369
|
+
- `↓` - Down
|
|
370
|
+
- `←` - Left
|
|
371
|
+
- `→` - Right
|
|
372
|
+
|
|
373
|
+
### Otros
|
|
374
|
+
|
|
375
|
+
- `⎵` - Space
|
|
376
|
+
- `⇥` - Tab
|
|
377
|
+
- `⎋` - Escape
|
|
378
|
+
|
|
379
|
+
## Accesibilidad
|
|
380
|
+
|
|
381
|
+
- ✅ **Semantic HTML**: Usa `<kbd>` nativo (semántico)
|
|
382
|
+
- ✅ **Non-interactive**: `pointer-events-none` por defecto
|
|
383
|
+
- ✅ **Screen readers**: Texto es leído normalmente
|
|
384
|
+
- ✅ **No focus**: No recibe focus (solo visual)
|
|
385
|
+
- ⚠️ **Context**: Siempre acompaña con texto descriptivo
|
|
386
|
+
|
|
387
|
+
## Notas de Implementación
|
|
388
|
+
|
|
389
|
+
- **HTML nativo**: Basado en `<kbd>` elemento nativo
|
|
390
|
+
- **KbdGroup**: Es un `<kbd>` contenedor, no `<div>` (semántico)
|
|
391
|
+
- **Auto-sizing**: SVGs se redimensionan automáticamente a `size-3`
|
|
392
|
+
- **Tooltip-aware**: Estilos especiales cuando está dentro de Tooltip
|
|
393
|
+
- **Non-interactive**: No recibe eventos de pointer por defecto
|
|
394
|
+
- **Select-none**: No se puede seleccionar texto
|
|
395
|
+
- **Monospace**: Usa `font-sans` no monospace
|
|
396
|
+
- **Min square**: `min-w-5` asegura que single chars sean cuadrados
|
|
397
|
+
|
|
398
|
+
## KbdGroup vs Multiple Kbd
|
|
399
|
+
|
|
400
|
+
```tsx
|
|
401
|
+
{
|
|
402
|
+
/* Con KbdGroup - semanticamente agrupados */
|
|
403
|
+
}
|
|
404
|
+
<KbdGroup>
|
|
405
|
+
<Kbd>Ctrl</Kbd>
|
|
406
|
+
<Kbd>K</Kbd>
|
|
407
|
+
</KbdGroup>;
|
|
408
|
+
|
|
409
|
+
{
|
|
410
|
+
/* Sin KbdGroup - separados */
|
|
411
|
+
}
|
|
412
|
+
<span>
|
|
413
|
+
<Kbd>Ctrl</Kbd> + <Kbd>K</Kbd>
|
|
414
|
+
</span>;
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**Usa KbdGroup cuando**: Las teclas se presionan simultáneamente (shortcut)
|
|
418
|
+
**No uses KbdGroup cuando**: Las teclas son alternativas o secuenciales
|
|
419
|
+
|
|
420
|
+
## Troubleshooting
|
|
421
|
+
|
|
422
|
+
**Kbd no se ve**: Verifica que tenga contenido (texto o icono)
|
|
423
|
+
**Tamaño inconsistente**: Usa `min-w-5` para asegurar cuadrado en single chars
|
|
424
|
+
**Icono muy grande**: Los SVGs se redimensionan automáticamente a `size-3`
|
|
425
|
+
**No se ve en Tooltip**: Los estilos de Tooltip aplican automáticamente
|
|
426
|
+
**Spacing inconsistente**: KbdGroup tiene `gap-1`, ajusta con className si necesario
|
|
427
|
+
**Seleccionable**: Verifica que tenga `select-none` aplicado
|
|
428
|
+
**Background no se ve**: Verifica tema y color `bg-muted`
|
|
429
|
+
**Muy alto**: Altura fija `h-5`, no cambies sin ajustar padding
|
|
430
|
+
|
|
431
|
+
## Referencias
|
|
432
|
+
|
|
433
|
+
- **MDN Kbd**: <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/kbd>
|
|
434
|
+
- **Unicode Symbols**: <https://www.unicode.org/charts/>
|