Use with Vite - Flowbite React
Learn how to install Flowbite React for your Vite project and start developing modern web applications with interactive components
#
Using the CLIRun the following command to scaffold a new Flowbite React
project using Vite
:
# npm
npm create flowbite-react@latest -- --template vite
# yarn
yarn create flowbite-react --template vite
# pnpm
pnpm create flowbite-react@latest --template vite
# bun
bun create flowbite-react@latest --template vite
Manual Installation
#
Create projectRun the following command to create a new Vite project using React and Typescript:
npm create vite@latest -- --template react-ts
#
Setup Tailwind CSS- Install
tailwindcss
and its peer dependencies:
npm i -D tailwindcss postcss autoprefixer
- Generate
tailwind.config.js
andpostcss.config.js
files:
npx tailwindcss init -p
- Add the paths to all of your template files in your
tailwind.config.js
file:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
- Add the
@tailwind
directives for each of Tailwind's layers to your./src/index.css
file:
@tailwind base;
@tailwind components;
@tailwind utilities;
#
Install Flowbite React- Run the following command to install
flowbite-react
:
npm i flowbite-react
- Add the Flowbite React
content
path andplugin
totailwind.config.js
:
const flowbite = require("flowbite-react/tailwind");
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
// ...
flowbite.content(),
],
plugins: [
// ...
flowbite.plugin(),
],
};
#
Try it outNow that you have successfully installed Flowbite React you can start using the components from the library.
import { Button } from "flowbite-react";
export default function App() {
return <Button>Click me</Button>;
}