React
NPM Package: @kksh/react
Original Shadcn: https://ui.shadcn.com/
Normally, Shadcn components are imported from local @/components/ui
directory.
Now you can import the components from @kksh/react
package.
Most of Shadcn components are exported from @kksh/react
package.
import { Button } from "@/components/ui/button"import { Button } from "@kksh/react"
Component Examples
Button Example
import { Button } from "@kksh/react"
export function ButtonDemo() { return <Button>Hello Kunkun!</Button>}
Command Palette Example
import { CalendarIcon, EnvelopeClosedIcon, FaceIcon, GearIcon, PersonIcon, RocketIcon,} from "@radix-ui/react-icons";
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut,} from "@kksh/react";
export default function CommandDemo() { return ( <Command className="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> <CalendarIcon className="mr-2 h-4 w-4" /> <span>Calendar</span> </CommandItem> <CommandItem> <FaceIcon className="mr-2 h-4 w-4" /> <span>Search Emoji</span> </CommandItem> <CommandItem disabled> <RocketIcon className="mr-2 h-4 w-4" /> <span>Launch</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem> <PersonIcon className="mr-2 h-4 w-4" /> <span>Profile</span> <CommandShortcut>⌘P</CommandShortcut> </CommandItem> <CommandItem> <EnvelopeClosedIcon className="mr-2 h-4 w-4" /> <span>Mail</span> <CommandShortcut>⌘B</CommandShortcut> </CommandItem> <CommandItem> <GearIcon className="mr-2 h-4 w-4" /> <span>Settings</span> <CommandShortcut>⌘S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </Command> );}
Theme
You can get KK’s color theme and set your extension theme to match KK’s theme.
@kksh/react
requires <ThemeProvider />
and <ThemeWrapper />
components to be wrapped around the root component.
<ThemeProvider />
is responsible for dark/light mode switching<ThemeWrapper />
is responsible for setting the color theme
import { ui } from "@kksh/api/ui/custom"import { updateTheme } from "@kksh/react"
useEffect(() => { ui.getTheme().then((theme) => { updateTheme(theme) })}, [])return ( <ThemeProvider defaultTheme="dark" storageKey="kk-ui-theme"> <ThemeWrapper> <main> ... </main> </ThemeWrapper> </ThemeProvider>)
For color theme to take effect, you need to import the theme styles from @kksh/vue/themes
.
@import url("@kksh/react/css");@import url("@kksh/react/themes");