Editor Setup - Flowbite React
Learn how to configure Visual Studio Code with Tailwind CSS support, code formatting, and linting for Flowbite React development.
This comprehensive guide will help you set up your development environment with proper intellisense, formatting, and linting support for Flowbite React's custom theme prop and Tailwind CSS integration.
VS Code Setup#
Visual Studio Code is our recommended editor for Flowbite React development. Follow these sections to configure your environment properly.
Tailwind Intellisense#
Follow these steps to enable intelligent Tailwind CSS suggestions and autocompletion:
- Install the official Tailwind CSS IntelliSense extension from the VS Code marketplace.
- Create a
.vscodedirectory in your project root:
mkdir .vscode
- Create a VS Code settings file:
touch .vscode/settings.json
- Configure VS Code settings for Tailwind CSS support:
{
"files.associations": {
"*.css": "tailwindcss"
},
"tailwindCSS.classAttributes": ["class", "className", "theme"],
"tailwindCSS.experimental.classRegex": [
["twMerge\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["createTheme(?:<\\w+>)?\\s*\\(([^)]*)\\)", "{?\\s?[\\w].*:\\s*?[\"'`]([^\"'`]*).*?,?\\s?}?"]
]
}
Prettier Setup#
Ensure consistent code formatting with Prettier:
- Install the required packages:
npm i -D prettier prettier-plugin-tailwindcss
- Create a Prettier configuration file:
touch prettier.config.js
- Configure Prettier with Tailwind CSS support:
/** @type {import('prettier').Config} */
module.exports = {
plugins: ["prettier-plugin-tailwindcss"],
// tailwindcss
tailwindAttributes: ["theme"],
tailwindFunctions: ["twMerge", "createTheme"],
};
ESLint Setup#
Set up ESLint to ensure code quality and catch potential issues:
Legacy Configuration#
- Install the Tailwind CSS ESLint plugin:
npm i -D eslint-plugin-tailwindcss
- Configure ESLint with Tailwind CSS support:
/** @type {import("eslint").Linter.Config} */
module.exports = {
// ...
extends: [
// ...
"plugin:tailwindcss/recommended",
],
settings: {
// ...
tailwindcss: {
callees: ["twMerge", "createTheme"],
classRegex: "^(class(Name)|theme)?$",
},
},
};
Flat Configuration#
Starting with ESLint v9, the flat config format is the default configuration method. Here's how to set up ESLint with Tailwind CSS support using the new flat config format:
- Install ESLint Tailwind CSS plugin:
npm i -D eslint-plugin-tailwindcss
- Configure ESLint with Tailwind CSS support using the flat config format:
import tailwindcss from "eslint-plugin-tailwindcss";
export default [
...tailwindcss.configs["flat/recommended"],
{
settings: {
tailwindcss: {
callees: ["twMerge", "createTheme"],
classRegex: "^(class(Name)|theme)?$",
},
},
},
];
Automated Setup#
For existing projects, you can quickly configure your editor using our CLI tool:
npx flowbite-react@latest setup vscode
This command will:
- Create the necessary
.vscodedirectory - Configure VS Code settings for Tailwind CSS
- Set up recommended extensions
- Configure Prettier and ESLint integrations
Note: If you're starting a new project, you don't need to run this command separately. The
npx flowbite-react@latest initcommand automatically includes all editor setup as part of its initialization process. Only usesetup vscodewhen configuring an editor for an existing project.
Next Steps#
After completing this setup, your Visual Studio Code environment will be fully configured for Flowbite React development with:
- Intelligent Tailwind CSS suggestions
- Automatic code formatting
- Code quality checking
- Full support for the custom
themeprop
For additional configuration options or troubleshooting, refer to our GitHub repository or join our community on Discord.