diff --git a/docs/content/2.components/kbd.md b/docs/content/2.components/kbd.md new file mode 100644 index 0000000..d9df1fc --- /dev/null +++ b/docs/content/2.components/kbd.md @@ -0,0 +1,50 @@ +--- +description: Display a keyboard keys such as shortcuts or hotkeys +since: 1.3.3 +--- + +## Usage + +Use the default slot to display the keyboard key. + +::ComponentPreview +K +:: + +The `label` prop also can be used to do so. + +::ComponentPreview +--- +props: + label: K +--- +:: + +### Sizes + +The `size` prop changes the size of the `kbd`. + +::ComponentPreview +--- +props: + size: sm +--- +K +:: + +### Shadow + +Add a shadow to the `kbd`. + +::ComponentPreview +--- +props: + shadow: true +--- +K +:: + +## Config + +::ComponentDefaults +:: diff --git a/src/runtime/components/elements/Kbd.vue b/src/runtime/components/elements/Kbd.vue new file mode 100644 index 0000000..389d21d --- /dev/null +++ b/src/runtime/components/elements/Kbd.vue @@ -0,0 +1,63 @@ + + + diff --git a/src/runtime/types/index.ts b/src/runtime/types/index.ts index 9f28fbc..5353ccb 100644 --- a/src/runtime/types/index.ts +++ b/src/runtime/types/index.ts @@ -1,5 +1,6 @@ export * from './button' export * from './message' export * from './input' +export * from './kbd' export * from './utils' diff --git a/src/runtime/types/kbd.d.ts b/src/runtime/types/kbd.d.ts new file mode 100644 index 0000000..5bab662 --- /dev/null +++ b/src/runtime/types/kbd.d.ts @@ -0,0 +1,7 @@ +import type { AppConfig } from 'nuxt/schema' +import type { kbd } from '../ui.config' +import type { ExtractDeepKey } from './utils' + +export type KbdSize = + | keyof typeof kbd.size + | ExtractDeepKey diff --git a/src/runtime/ui.config/elements/kbd.ts b/src/runtime/ui.config/elements/kbd.ts new file mode 100644 index 0000000..89243a4 --- /dev/null +++ b/src/runtime/ui.config/elements/kbd.ts @@ -0,0 +1,17 @@ +export default { + base: 'inline-flex justify-center items-center text-gray-900 dark:text-gray-100 leading-none', + rounded: 'rounded', + font: 'font-medium', + background: 'bg-gray-100 dark:bg-gray-800', + ring: 'ring-1 ring-inset ring-gray-300 dark:ring-gray-700', + padding: 'px-1', + shadow: 'shadow-sm', + size: { + xs: 'h-4 min-w-4 text-[10px]', + sm: 'h-5 min-w-5 text-[11px]', + md: 'h-6 min-w-6 text-xs', + }, + default: { + size: 'sm', + }, +} diff --git a/src/runtime/ui.config/index.ts b/src/runtime/ui.config/index.ts index 12f22a7..17cbfe3 100644 --- a/src/runtime/ui.config/index.ts +++ b/src/runtime/ui.config/index.ts @@ -3,6 +3,7 @@ export { default as standard } from './standard' // elements export { default as button } from './elements/button' +export { default as kbd } from './elements/kbd' // forms export { default as input } from './forms/input'