Use with Farm - Flowbite React
Learn how to install Flowbite React with Farm
This guide provides three ways to integrate Flowbite React with Farm:
- Quick Start: Create a new project with everything pre-configured
- Add to Existing Project: Add Flowbite React to an existing Farm project
- Manual Setup: Set up everything from scratch manually
Quick Start (Recommended)
Quick Start#
The fastest way to get started is using our project creation CLI, which sets up a new Farm project with Flowbite React, Tailwind CSS, and all necessary configurations:
npx create-flowbite-react@latest -t farm
This will:
- Create a new Farm project
- Install and configure Tailwind CSS
- Set up Flowbite React with all required dependencies
- Configure dark mode support
- Set up example components
Add to Existing Project
Add to Existing Project#
If you already have a Farm project and want to add Flowbite React, you can use our initialization CLI:
npx flowbite-react@latest init
This will automatically:
- Install Flowbite React and its dependencies
- Configure Tailwind CSS to include Flowbite React plugin
- Set up necessary configurations
Manual Setup
Manual Setup#
If you prefer to set everything up manually or need more control over the configuration, follow these steps:
1. Create Project#
Create a new Farm project:
npx create-farm@latest farm-project
cd farm-project
When prompted:
- Select "React"
Install PostCSS:
npm install @farmfe/js-plugin-postcss postcss
Add @farmfe/js-plugin-postcss to your farm.config.ts file:
import { defineConfig } from "@farmfe/core";
import farmPluginPostcss from "@farmfe/js-plugin-postcss";
export default defineConfig({
plugins: ["@farmfe/plugin-react", farmPluginPostcss()],
});
2. Configure Tailwind CSS#
Install Tailwind CSS and its dependencies:
npm install -D tailwindcss @tailwindcss/postcss
Create a postcss.config.mjs file:
touch postcss.config.mjs
Add @tailwindcss/postcss to your postcss.config.mjs file:
/** @type {import('postcss-load-config').Config} */
export default {
plugins: {
"@tailwindcss/postcss": {},
},
};
Update the css file src/index.css to include Tailwind CSS:
@import "tailwindcss";
3. Install Flowbite React#
Install Flowbite React:
npx flowbite-react@latest init
This will:
- Install Flowbite React and its dependencies
- Configure Tailwind CSS to include Flowbite React plugin
- Configure Vite to include Flowbite React plugin
Try it out#
Now that you have successfully installed Flowbite React you can start using the components from the library:
// src/main.tsx
import { Button } from "flowbite-react";
export function Main() {
return (
<>
<Button>Click me</Button>
</>
);
}