Use with Parcel - Flowbite React
Learn how to install Flowbite React for your Parcel project and start developing modern web applications with interactive components
#
Using the CLIRun the following command to scaffold a new Flowbite React
project using Parcel
:
# npm
npm create flowbite-react@latest -- --template parcel
# yarn
yarn create flowbite-react --template parcel
# pnpm
pnpm create flowbite-react@latest --template parcel
# bun
bun create flowbite-react@latest --template parcel
Manual Installation
#
Create projectFollow the steps to create a Parcel project using React and Tailwind CSS.
#
Setup Parcel- Create a directory for your project:
mkdir flowbite-react-parcel
- Initialize
package.json
file:
npm init -y
- Install
Parcel
:
npm i -D parcel
- Create
src
directory:
mkdir src
- Create
src/index.html
file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Parcel App</title>
</head>
<body></body>
</html>
- Configure
package.json
file, addsource
and updatescripts
withstart
andbuild
steps:
{
"name": "flowbite-react-parcel",
"version": "1.0.0",
"description": "",
"main": "index.js",
"source": "src/index.html",
"scripts": {
"start": "parcel",
"build": "parcel build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
#
Setup React- Install
React
:
npm i react react-dom
- Create
src/index.js
file:
import { createRoot } from "react-dom/client";
import { App } from "./app";
const container = document.getElementById("app");
const root = createRoot(container);
root.render(<App />);
- Create
src/app.js
file:
export function App() {
return <h1>Hello world!</h1>;
}
- Update
src/index.html
file:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Parcel App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="index.js"></script>
</body>
</html>
#
Setup Tailwind CSS- Install
tailwindcss
and its peer dependencies:
npm i -D tailwindcss postcss
- Generate
tailwind.config.js
file:
npx tailwindcss init
- Create
.postcssrc
file and enable the tailwindcss plugin:
{
"plugins": {
"tailwindcss": {}
}
}
- Add the paths to all of your template files in your
tailwind.config.js
file:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./src/**/*.{html,js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
- Create a
./src/index.css
file and add the@tailwind
directives for each of Tailwind's layers:
@tailwind base;
@tailwind components;
@tailwind utilities;
- Update
src/index.html
to includesrc/index.css
file in thehead
:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Parcel App</title>
<link href="./index.css" rel="stylesheet" />
</head>
<body>
<div id="app"></div>
<script type="module" src="index.js"></script>
</body>
</html>
#
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 function App() {
return <Button>Click me</Button>;
}