Vue
NPM Package: @kksh/vue
Original Shadcn Vue: https://www.shadcn-vue.com/
Normally, Shadcn components are imported from local @/components/ui
directory.
Now you can import the components from @kksh/vue
package.
Most of Shadcn components are exported from @kksh/vue
package.
For now, @kksh/vue
has some treeshaking issues, importing from @kksh/vue
may potentially add all components to your bundle.
I didn’t figure out how to fix it yet. If you are an expert in building Vue library, please help me. The source code is at https://github.com/kunkunsh/kunkun-components/tree/main/packages/vue.
The best way to import components from this library is to import from the subpackages, like @kksh/vue/button
or @kksh/vue/command
.
import { Button } from "@/components/ui/button"import { Button } from "@kksh/vue/button"// Orimport { Button } from "@kksh/vue" // no treeshaking
Component Examples
Button Example
<script setup> import { Button } from "@kksh/vue/button"</script>
<template> <Button client:only="react">Hello Kunkun!</Button></template>
Command Palette Example
<script setup lang="ts">import { CalendarIcon, EnvelopeClosedIcon, FaceIcon, GearIcon, PersonIcon, RocketIcon,} from "@radix-icons/vue";import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "@kksh/vue/command";</script>
<template> <Command class="rounded-lg border shadow-md max-w-[450px]"> <CommandInput placeholder="Type a command or search..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup heading="Suggestions"> <CommandItem value="Calendar"> <CalendarIcon class="mr-2 h-4 w-4" /> <span>Calendar</span> </CommandItem> <CommandItem value="Search Emoji"> <FaceIcon class="mr-2 h-4 w-4" /> <span>Search Emoji</span> </CommandItem> <CommandItem value="Launch"> <RocketIcon class="mr-2 h-4 w-4" /> <span>Launch</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem value="Profile"> <PersonIcon class="mr-2 h-4 w-4" /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem value="Mail"> <EnvelopeClosedIcon class="mr-2 h-4 w-4" /> <span>Mail</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem value="Settings"> <GearIcon class="mr-2 h-4 w-4" /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command></template>
Theme
You can get KK’s color theme and set your extension theme to match KK’s theme.
@kksh/vue
’s updateTheme()
function set the theme globally, there is no need for a ThemeProvider
.
import { ui } from "@kksh/api/ui/custom"import { updateTheme } from "@kksh/vue"
ui.getTheme().then((theme) => { updateTheme(theme)})
For color theme to take effect, you need to import the theme styles from @kksh/vue/themes
.
@import url("@kksh/vue/css");@import url("@kksh/vue/themes");