Skip to content

Commit e089099

Browse files
committed
feat: add shadcn UI docs
1 parent 670d62d commit e089099

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.vitepress/config/sidebar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ const sidebar = [
136136
// collapsed: true,
137137
items: [
138138
{ text: 'Introduction', link: '/docs/frontend/' },
139-
{ text: 'Bare UI', link: '/docs/frontend/bareui' },
140139
{ text: 'Leaf Blade', link: '/docs/frontend/blade' },
141-
{ text: 'Other Engines', link: '/docs/frontend/third-party' },
140+
{ text: 'Inertia JS', link: '/docs/frontend/inertia' },
142141
{ text: 'Vite JS', link: '/docs/frontend/vite' },
143142
{ text: 'Tailwind CSS', link: '/docs/frontend/tailwind' },
144-
{ text: 'Inertia JS', link: '/docs/frontend/inertia' },
143+
{ text: 'Bare UI', link: '/docs/frontend/bareui' },
144+
{ text: 'Other Engines', link: '/docs/frontend/third-party' },
145145
// { text: 'Leaf UI', link: '/docs/frontend/leaf-ui' },
146146
// {
147147
// text: 'Leaf Zero',

src/docs/frontend/inertia.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,36 @@ php leaf g:template home --type=vue # Vue
141141
php leaf g:template home --type=svelte # Svelte
142142
```
143143

144+
## Using Shadcn
145+
146+
If you are pairing React with your Leaf app, you can use [shadcn/ui](https://ui.shadcn.com/) to build your UI. We don't ship with the necessary files to use shadcn/ui, but you can easily set it up by running the following command:
147+
148+
```bash:no-line-numbers
149+
php leaf scaffold:shadcn
150+
```
151+
152+
From there, you can install any shadcn/ui component you want, and it will automatically be configured to work with your Leaf app.
153+
154+
```bash:no-line-numbers
155+
pnpm dlx shadcn@latest add switch
156+
```
157+
158+
The final step is to use the component you just installed:
159+
160+
```jsx{6}
161+
import { Switch } from "@/components/ui/switch"
162+
163+
const MyPage = () => {
164+
return (
165+
<div>
166+
<Switch />
167+
</div>
168+
)
169+
}
170+
171+
export default MyPage
172+
```
173+
144174
## Form validation with inertia
145175

146176
Leaf has already configured inertia for the vast majority of use-cases, which also includes form validation. This is an example form for updating a user's name. The first part is creating the form, which inertia has a beautiful helper for:

0 commit comments

Comments
 (0)