Vite
Add PanelUI web components to a Vite and React app.
For a single-page React app built with Vite.
A new project
Create the project
The shadcn CLI creates the app, sets up Tailwind CSS and writes the theme tokens in one go:
npx shadcn@latest init -t vitepnpm dlx shadcn@latest init -t viteyarn dlx shadcn@latest init -t vitebunx shadcn@latest init -t viteAdd a component
npx shadcn@latest add https://panelui.dev/r/web/rolling-number.jsonpnpm dlx shadcn@latest add https://panelui.dev/r/web/rolling-number.jsonyarn dlx shadcn@latest add https://panelui.dev/r/web/rolling-number.jsonbunx shadcn@latest add https://panelui.dev/r/web/rolling-number.jsonThe source is written to components/panelui/rolling-number.tsx, and the packages it uses are
installed for you.
Use it
import { RollingNumber } from "@/components/panelui/rolling-number"
export default function App() {
return (
<main className="flex min-h-svh items-center justify-center">
<RollingNumber value={121} className="text-6xl font-semibold" />
</main>
)
}An existing project
A Vite project needs Tailwind CSS and the @ import alias before the CLI can run. If yours has neither, start from the template above, or set them up as the Tailwind and Vite documentation describe. Then:
npx shadcn@latest initpnpm dlx shadcn@latest inityarn dlx shadcn@latest initbunx shadcn@latest initThen add a component as in the steps above.
From npm
To install the package instead of copying source, follow From npm once the project has its shadcn theme.