Shadcn/UI Create React App Starter Project + Step By Step How To
The Shadcn UI Create React App Example is a project created by Ahmad Sandid that utilizes the Shadcn UI components and the Create-React-App framework. It provides a guide on how to install and run the project, as well as steps to create it from scratch. The project aims to showcase the capabilities and functionality of the Shadcn UI components.
To install and run the Shadcn UI Create React App Example, follow these steps:
npx create-react-app shadcn-ui-cra-example --template typescript
npm install shadcn-ui tailwindcss autoprefixer postcss-cli
module.exports = {
purge: [
'./src/**/*.html',
'./src/**/*.js',
'./src/**/*.jsx',
'./src/**/*.ts',
'./src/**/*.tsx',
],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
@import '../../node_modules/tailwindcss/base.css';
@import '../../node_modules/tailwindcss/components.css';
@import '../../node_modules/tailwindcss/utilities.css';
body {
@apply bg-gray-100 text-gray-800 font-sans antialiased;
}
{
"compilerOptions": {
"sourceMap": true,
"noImplicitAny": true,
"removeComments": true,
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "react-jsx",
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
}
}
export const capitalize = (str: string): string => {
return str.charAt(0).toUpperCase() + str.slice(1);
};
npx shadcn-ui add button
Edit the path command to be “./src/components/ui”.
import React from 'react';
import { Button } from '@/components/ui';
function App() {
return (
<div className="flex justify-center items-center h-screen">
<Button>Hello Shadcn UI</Button>
</div>
);
}
export default App;
npm start
The Shadcn UI Create React App Example is a demonstration of how to use Shadcn UI components in a Create-React-App project. It provides the necessary installation instructions and code snippets to get started with the project. The integration of Shadcn UI components, Create-React-App framework, and Tailwind CSS allows for easy and efficient development of user interfaces.