Currently there are lots of CSS frameworks such as Bootstrap, Bulma, Semantic UI etc. which can speed up building a display (user interface). one of the CSS tools that is currently trending is Shadcn/ui, what is it before?
On the official website Shadcn/ui states
“a collection of reusable components that we can copy and paste into our apps.”
So shadcn/ui is a collection of reusable components in views, built using TailwindCSS and RadixUI. Currently it supports several frameworks such as Next.js, Laravel and so on. can be seen on the official website Shadcn/ui.
Of the many frameworks that are supported. Our main goal is how to install Shadcn/ui on Laravel React, using Laravel Breeze.
First step: install the laravel project.
laravel new laravel-shadcn
Here we use the Laravel installer (global). In the next stage we will be asked to choose an option as in the image below
Fill in according to your project needs. If so, wait until the installation is complete. Installation speed depends on your internet connection.
The Laravel project installation is complete. OK Continue!.
Second step: Installing Shadcn/ui on the laravel project
Still in the same terminal. First type the command below:
cd laravel-shadcn npx shadcn-ui@latest init
If so, a request will appear and fill it in according to your needs. as the following example.
Would you like to use TypeScript (recommended)? no Which style would you like to use? › Default Which color would you like to use as base color? › Slate Where is your global CSS file? › resources/css/app.css Do you want to use CSS variables for colors? › yes Where is your tailwind.config.js located? › tailwind.config.js Configure the import alias for components: › @/Components Configure the import alias for utils: › @/lib/utils Are you using React Server Components? › no
If you are a typescript user then you can choose yes, OK, Next. Go to vscode or according to your favorite code editor. here I use vscode then just use the following command
cd laravel-shadcn code .
Automatically opens vscode and opens your laravel project. If so, the next step is to open the app.css file in the resource/css/app.css folder to ensure that shadcnui has been successfully installed in our Laravel project.
In the picture above shadcn has been successfully installed on our Laravel project.
Explanation :
Step three: Make sure Shadcn is installed
To ensure that ShadcnUI has been installed we can give a command in the terminal. namely, for example, we will install the button component, the command is: npx shadcn-ui@latest add button can be seen in the image below
Then open the Welcome.jsx file and follow as in the image below.
If it is already. open two Terminals with the same directory namely laravel-shadcn
Terminal 1
npm run dev
Terminal 2
php artisan serve
Then open it in the browser and the button component will appear which default is colored Dark.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3