|
| 1 | +<script setup> |
| 2 | +import { FwbAlert } from '../../src/index' |
| 3 | +</script> |
| 4 | + |
1 | 5 | # Flowbite Vue - Quickstart |
2 | 6 |
|
3 | 7 | Get started with Flowbite by including it into your project using NPM |
4 | 8 |
|
5 | 9 | Flowbite is a library of components built on top of the utility-classes from Tailwind CSS and it also includes a JavaScript file that makes interactive elements works, such as modals, dropdowns, and more. Learn how to get started by following this quickstart guide. |
6 | 10 |
|
7 | | -## Require via NPM |
| 11 | +<br> |
8 | 12 |
|
9 | | -Make sure that you have [Node.js](https://nodejs.org/en/) and [Tailwind CSS](https://tailwindcss.com/) installed. |
| 13 | +::: info |
| 14 | +Make sure that you have [Node.js](https://nodejs.org/en/) installed. Flowbite Vue requires version 18 or newer. |
| 15 | +```bash |
| 16 | +node -v |
| 17 | +``` |
| 18 | +::: |
| 19 | + |
| 20 | +### Install and configure TailwindCSS |
10 | 21 |
|
11 | | -1. Install `flowbite` and `flowbite-vue` as a dependency using NPM by running the following command: |
| 22 | +1. Install [Tailwind CSS](https://tailwindcss.com/docs/installation/using-vite) as part of `devDependencies`: |
12 | 23 |
|
13 | 24 | ```bash |
14 | | -npm i flowbite flowbite-vue |
| 25 | +npm install -D tailwindcss @tailwindcss/vite |
15 | 26 | ``` |
16 | 27 |
|
17 | | -2. Require Flowbite as a plugin inside the tailwind.config.js and add flowbite-vue dist folder to tailwind content: |
| 28 | +2. Configure the Vite plugin: |
| 29 | +::: code-group |
18 | 30 |
|
19 | | -```javascript |
20 | | -module.exports = { |
21 | | - content: [ |
22 | | - 'node_modules/flowbite-vue/**/*.{js,jsx,ts,tsx,vue}', |
23 | | - 'node_modules/flowbite/**/*.{js,jsx,ts,tsx}' |
24 | | - ], |
| 31 | +```js{3,8} [vite.config.js] |
| 32 | +import { defineConfig } from 'vite' |
| 33 | +import vue from '@vitejs/plugin-vue' |
| 34 | +import tailwindcss from '@tailwindcss/vite' |
| 35 | +
|
| 36 | +export default defineConfig({ |
25 | 37 | plugins: [ |
26 | | - require('flowbite/plugin') |
| 38 | + vue(), |
| 39 | + tailwindcss(), |
27 | 40 | ], |
28 | | - theme: {} |
| 41 | +}) |
| 42 | +``` |
| 43 | +::: |
| 44 | + |
| 45 | +3. Import Tailwind CSS |
| 46 | +::: code-group |
| 47 | +```css [src/style.css] |
| 48 | +@import "tailwindcss"; |
| 49 | +``` |
| 50 | +::: |
| 51 | + |
| 52 | +::: info |
| 53 | +Remember to `@reference` your main style in `<style>` blocks if you want to use directives from Tailwind CSS. |
| 54 | +::: |
| 55 | + |
| 56 | +```vue{2} |
| 57 | +<style scoped> |
| 58 | +@reference "./style.css"; |
| 59 | +
|
| 60 | +.custom-class { |
| 61 | + @apply border rounded p-3; |
29 | 62 | } |
| 63 | +</style> |
30 | 64 | ``` |
31 | 65 |
|
32 | | -3. Import Flowbite Vue styles: |
33 | | -```javascript |
34 | | -//in your `main.js` file |
35 | | -import '../node_modules/flowbite-vue/dist/index.css' |
| 66 | +### Install and configure Flowbite Vue |
| 67 | +1. Install **Flowbite** and **Flowbite Vue** as part of `dependencies`: |
| 68 | + |
| 69 | +```bash |
| 70 | +npm i flowbite flowbite-vue |
36 | 71 | ``` |
| 72 | + |
| 73 | +2. Update `style.css` file |
| 74 | + |
37 | 75 | ```css |
38 | | -/* or in your `app.css` file */ |
39 | | -@import '/node_modules/flowbite-vue/dist/index.css'; |
| 76 | +/* import Flowbite Vue styles */ |
| 77 | +@import "flowbite-vue/index.css"; |
| 78 | + |
| 79 | +/* import Flowbite plugin */ |
| 80 | +@plugin "flowbite/plugin"; |
| 81 | + |
| 82 | +/* add Flowbite Vue directory using @source directive */ |
| 83 | +@source "../node_modules/flowbite-vue"; |
40 | 84 | ``` |
41 | 85 |
|
42 | | -4. Now you can use `flowbite-vue` anywhere in your project and build awesome interfaces: |
| 86 | +4. Now you can use **Flowbite Vue** anywhere in your project and build awesome interfaces: |
| 87 | + |
| 88 | +<div class="vp-raw"> |
| 89 | + <fwb-alert type="success"> |
| 90 | + Success! You can now use Flowbite Vue in your Vue application 🎉 |
| 91 | + </fwb-alert> |
| 92 | +</div> |
| 93 | + |
43 | 94 | ```vue |
44 | 95 | <template> |
45 | | - <fwb-dropdown text="Click me" placement="top"> |
46 | | - <fwb-list-group> |
47 | | - <fwb-list-group-item>Item #1</fwb-list-group-item> |
48 | | - <fwb-list-group-item>Item #2</fwb-list-group-item> |
49 | | - <fwb-list-group-item>Item #3</fwb-list-group-item> |
50 | | - </fwb-list-group> |
51 | | - </fwb-dropdown> |
| 96 | + <fwb-alert type="success"> |
| 97 | + Success! You can now use Flowbite Vue in your Vue application 🎉 |
| 98 | + </fwb-alert> |
52 | 99 | </template> |
53 | 100 |
|
54 | 101 | <script setup> |
55 | | -import { FwbDropdown, FwbListGroup, FwbListGroupItem } from 'flowbite-vue' |
| 102 | +import { FwbAlert } from 'flowbite-vue' |
56 | 103 | </script> |
57 | 104 | ``` |
58 | | - |
59 | | -> Make sure you have tailwind css imported. https://tailwindcss.com/docs/guides/vite |
60 | | -
|
61 | | -``` |
62 | | -@tailwind base; |
63 | | -@tailwind components; |
64 | | -@tailwind utilities; |
65 | | -``` |
|
0 commit comments