chore(Kbd): usage with value prop

This commit is contained in:
Benjamin Canac
2023-05-14 17:06:08 +02:00
parent 8caa78819a
commit ae02f23a8c
3 changed files with 28 additions and 3 deletions

View File

@@ -5,6 +5,6 @@ const { metaSymbol } = useShortcuts()
<template> <template>
<div class="flex items-center gap-0.5"> <div class="flex items-center gap-0.5">
<UKbd>{{ metaSymbol }}</UKbd> <UKbd>{{ metaSymbol }}</UKbd>
<UKbd>U</UKbd> <UKbd>K</UKbd>
</div> </div>
</template> </template>

View File

@@ -7,6 +7,27 @@ navigation:
## Usage ## Usage
Use the default slot to set the text of the Kbd.
::component-card
---
code: K
---
K
::
You can also use the `value` prop:
::component-card
---
props:
value: K
---
::
As explained in the [Shortcuts](/getting-started/shortcuts) page, you can use the `metaSymbol` property of the `useShortcuts` composable to display the meta key according to the user's OS.
::component-example ::component-example
#default #default
:kbd-example :kbd-example
@@ -20,7 +41,7 @@ const { metaSymbol } = useShortcuts()
<template> <template>
<div class="flex items-center gap-0.5"> <div class="flex items-center gap-0.5">
<UKbd>{{ metaSymbol }}</UKbd> <UKbd>{{ metaSymbol }}</UKbd>
<UKbd>U</UKbd> <UKbd>K</UKbd>
</div> </div>
</template> </template>
``` ```

View File

@@ -1,6 +1,6 @@
<template> <template>
<kbd :class="[ui.base, ui.size[size], ui.padding, ui.rounded, ui.font, ui.background, ui.ring]"> <kbd :class="[ui.base, ui.size[size], ui.padding, ui.rounded, ui.font, ui.background, ui.ring]">
<slot /> <slot>{{ value }}</slot>
</kbd> </kbd>
</template> </template>
@@ -17,6 +17,10 @@ import appConfig from '#build/app.config'
export default defineComponent({ export default defineComponent({
props: { props: {
value: {
type: String,
default: null
},
size: { size: {
type: String, type: String,
default: () => appConfig.ui.kbd.default.size, default: () => appConfig.ui.kbd.default.size,