Skip to content

Commit 9dfb084

Browse files
committed
docs(cli): cleanup and explain the create command better
1 parent 8430ecf commit 9dfb084

File tree

3 files changed

+78
-23
lines changed

3 files changed

+78
-23
lines changed

apps/web/content/docs/customize/config.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Example config for manual mode:
143143
The CLI uses the configuration file to determine how to create new components:
144144

145145
```bash
146-
npx flowbite-react create MyComponent
146+
npx flowbite-react@latest create my-component
147147
```
148148

149149
The component creation process is affected by these configuration options:

apps/web/content/docs/customize/custom-components.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ The Flowbite React theming system can be used to create your own themeable compo
1010
The easiest way to create a new custom component is to use the Flowbite React CLI:
1111

1212
```bash
13-
npx flowbite-react create MyComponent
13+
npx flowbite-react@latest create my-component
1414
```
1515

1616
This will generate a new component with the proper structure and theming setup. The CLI uses the configuration from `.flowbite-react/config.json` to determine:
1717

1818
1. Where to create the component (`path`)
19-
2. Whether to include the "use client" directive (`rsc`)
19+
2. Whether to include the `"use client"` directive (`rsc`)
2020
3. Whether to use TypeScript or JavaScript (`tsx`)
2121

2222
You can customize these options in your config file `.flowbite-react/config.json`:

apps/web/content/docs/getting-started/cli.mdx

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,64 @@ This command performs several automated setup steps:
4949

5050
## CLI Commands
5151

52-
### `flowbite-react init`
53-
54-
Initializes Flowbite React in your project. This command:
55-
56-
- Ensures Tailwind CSS is installed
57-
- Creates the `.flowbite-react` config directory
58-
- Creates `config.json` and `.gitignore` files in the config directory
59-
- Creates `.vscode/settings.json` and `.vscode/extensions.json` files
60-
- Detects and configures your bundler with the appropriate plugin
61-
- Adds postinstall script to `package.json` (if no bundler detected)
62-
6352
### `flowbite-react build`
6453

6554
Generates the class list for your components. This:
6655

6756
- Creates the output directory if needed
6857
- Generates a comprehensive list of Tailwind classes used in your components
6958

59+
```bash
60+
npx flowbite-react@latest build
61+
```
62+
63+
### `flowbite-react create <component-name>`
64+
65+
Creates a new component with the proper structure and theming setup:
66+
67+
```bash
68+
npx flowbite-react@latest create button
69+
```
70+
71+
The `create` command uses the configuration options from `.flowbite-react/config.json` to determine:
72+
73+
1. **Where to create the component** (`path`):
74+
75+
- Determines the directory where the component will be created
76+
- Default: `"src/components"`
77+
- Example: With `"path": "src/ui/elements"`, the component will be created at `src/ui/elements/button.tsx`
78+
79+
2. **Language format** (`tsx`):
80+
81+
- When `true`: Creates a TypeScript component (`.tsx`) with full type definitions
82+
- When `false`: Creates a JavaScript component (`.jsx`) without TypeScript syntax
83+
- Default: `true`
84+
- Example: With `"tsx": false`, the component will be created as `button.jsx` with JavaScript syntax
85+
86+
3. **React Server Components support** (`rsc`):
87+
- When `true`: Adds the `"use client";` directive at the top of the component file
88+
- When `false`: Omits the directive for client-only components
89+
- Default: `true`
90+
- Example: With `"rsc": false`, the component won't include the `"use client";` directive
91+
92+
The generated component includes:
93+
94+
- Proper theme structure with base styles
95+
- Theme resolution with the Flowbite React theming system
96+
- Component props with proper typing (in TypeScript mode)
97+
- Forward ref implementation for DOM access
98+
- Display name for better debugging
99+
100+
Example usage after creation:
101+
102+
```jsx
103+
import { Button } from "./src/components/button";
104+
105+
function App() {
106+
return <Button>Click me</Button>;
107+
}
108+
```
109+
70110
### `flowbite-react dev`
71111

72112
Starts the development mode which:
@@ -76,6 +116,21 @@ Starts the development mode which:
76116
- Provides real-time class generation
77117
- Monitors imported components
78118

119+
```bash
120+
npx flowbite-react@latest dev
121+
```
122+
123+
### `flowbite-react init`
124+
125+
Initializes Flowbite React in your project. This command:
126+
127+
- Ensures Tailwind CSS is installed
128+
- Creates the `.flowbite-react` config directory
129+
- Creates `config.json` and `.gitignore` files in the config directory
130+
- Creates `.vscode/settings.json` and `.vscode/extensions.json` files
131+
- Detects and configures your bundler with the appropriate plugin
132+
- Adds postinstall script to `package.json` (if no bundler detected)
133+
79134
### `flowbite-react install`
80135

81136
Installs Flowbite React in your project:
@@ -84,6 +139,15 @@ Installs Flowbite React in your project:
84139
- Installs the latest version of flowbite-react
85140
- Skips installation if already installed
86141

142+
### `flowbite-react register`
143+
144+
Registers the Flowbite React process for development:
145+
146+
- Runs the dev process in the background
147+
- Manages process lifecycle
148+
- Handles automatic class generation
149+
- Creates and maintains process ID file
150+
87151
### `flowbite-react setup plugin`
88152

89153
Sets up the appropriate bundler plugin for your project:
@@ -111,15 +175,6 @@ Sets up VSCode for optimal development:
111175
- Adds recommended extensions
112176
- Configures class attribute settings
113177

114-
### `flowbite-react register`
115-
116-
Registers the Flowbite React process for development:
117-
118-
- Runs the dev process in the background
119-
- Manages process lifecycle
120-
- Handles automatic class generation
121-
- Creates and maintains process ID file
122-
123178
## Project Templates
124179

125180
The CLI supports various framework templates. Each template comes with a complete guide and example implementation:

0 commit comments

Comments
 (0)