Skip to content

Commit 4bb6d9a

Browse files
authored
Merge pull request #316 from webreinvent/feature/video-and-css-optimization
Feature -> Develop | video and css optimization
2 parents ce1adb4 + 7437188 commit 4bb6d9a

File tree

6 files changed

+608
-20
lines changed

6 files changed

+608
-20
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
toc: true
3+
title: Theming Guide
4+
---
5+
## Theming in Nuxt
6+
7+
This document explains how to set up and manage **theming in Nuxt 3**, including:
8+
9+
- Defining **brand colors** and **semantic colors** (primary, secondary, etc.)
10+
- Structuring **theme tokens** for consistency
11+
- Theming with **Tailwind CSS** and **PrimeVue**
12+
- (Optional) Supporting light/dark mode and multiple themes
13+
14+
---
15+
16+
## 1. What is Theming?
17+
18+
**Theming** is the process of defining a consistent visual identity for your application.
19+
20+
It usually includes:
21+
22+
- 🟡 Defining **brand colors** (e.g., your company's primary palette)
23+
- 🟢 Defining **semantic colors** (e.g., success, warning, error)
24+
- 🔵 Applying these colors globally in UI components
25+
- ⚫ Optionally enabling **light/dark** or multiple theme variants
26+
27+
---
28+
29+
## 2. Options for Theming in Nuxt
30+
31+
You can manage themes in Nuxt using:
32+
33+
1. **Tailwind CSS** – Define colors in `tailwind.config.js` and use utility classes
34+
2. **PrimeVue** – Use built-in themes or create custom theme overrides
35+
3. **CSS variables** – For flexible, runtime theme switching
36+
37+
---
38+
39+
## 3. Defining Brand & Semantic Colors (Base Layer)
40+
41+
Even before Tailwind or PrimeVue, define your **color tokens** clearly.
42+
43+
### Example color tokens:
44+
45+
Brand colors:
46+
47+
- `Primary`: #1D4ED8
48+
49+
- `Secondary`: #9333EA
50+
51+
- `Accent`: #F59E0B
52+
53+
Semantic colors:
54+
55+
- `Success`: #10B981
56+
57+
- `Warning`: #F59E0B
58+
59+
- `Error`: #EF4444
60+
61+
- `Info`: #3B82F6
62+
63+
64+
These tokens can be used across Tailwind and PrimeVue themes to keep the system **consistent**.
65+
66+
---
67+
68+
## Final Notes
69+
70+
* Use variables for colors, backgrounds, gradients, and even shadows.
71+
* Combine Tailwind's arbitrary values with semantic CSS variables.
72+
* Maintain consistent naming across light/dark modes.
73+
* Document each variable clearly to help future developers.
74+
75+
A scalable theming approach will improve maintainability, accessibility, and performance across your Vue or Nuxt projects.
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
toc: true
3+
title: Nuxt with Tailwind
4+
---
5+
6+
## Tailwind Installation
7+
8+
Using Tailwind CSS in your Nuxt project is only one command away.
9+
10+
#### 1. Install `@nuxtjs/tailwindcss` dependency to your project:
11+
12+
```
13+
npx nuxi@latest module add tailwindcss
14+
```
15+
#### 2. If not already done, add it to your modules section in your nuxt.config:
16+
17+
```
18+
export default defineNuxtConfig({
19+
modules: ['@nuxtjs/tailwindcss']
20+
})
21+
```
22+
23+
### Tailwind Files
24+
25+
When running your Nuxt project, this module will look for these files:
26+
27+
- `./assets/css/tailwind.css`
28+
- `./tailwind.config.{js,cjs,mjs,ts}`
29+
30+
If these files don't exist, the module will automatically generate a basic configuration for them, so you don't have to create these files manually.
31+
32+
You can create the `tailwind.config.js` file by running the following command, as noted by the Tailwind CSS installation guide:
33+
34+
```
35+
npx tailwindcss init
36+
```
37+
38+
If the above fails, you can try `npx tailwindcss-cli init`.
39+
40+
If you're going to create your own CSS file for Tailwind CSS, make sure to add the @tailwind directives:
41+
42+
```css
43+
@tailwind base;
44+
@tailwind components;
45+
@tailwind utilities;
46+
```
47+
48+
### Module Configuration
49+
50+
You can customize the module's behavior by using the tailwindcss property in nuxt.config:
51+
52+
```js
53+
export default defineNuxtConfig({
54+
modules: ['@nuxtjs/tailwindcss'],
55+
tailwindcss: {
56+
// Options
57+
}
58+
})
59+
```
60+
61+
62+
## Theming with Tailwind CSS
63+
64+
### Step 1: Define Colors in Tailwind
65+
66+
Edit `tailwind.config.js`:
67+
68+
```js
69+
export default {
70+
darkMode: 'class',
71+
theme: {
72+
extend: {
73+
colors: {
74+
// Brand colors
75+
brand: {
76+
primary: '#1D4ED8',
77+
secondary: '#9333EA',
78+
accent: '#F59E0B'
79+
},
80+
81+
// Semantic colors
82+
semantic: {
83+
success: '#10B981',
84+
warning: '#F59E0B',
85+
error: '#EF4444',
86+
info: '#3B82F6'
87+
}
88+
}
89+
}
90+
}
91+
}
92+
```
93+
94+
✅ Now you can use these colors anywhere:
95+
96+
```html
97+
<button class="bg-brand-primary text-white">Primary</button>
98+
<div class="text-semantic-success">Success message</div>
99+
```
100+
101+
### Step 2: (Optional) Use CSS Variables for Multiple Themes
102+
103+
If you want multiple themes (e.g., light, dark, blue), define variables in a global CSS file.
104+
105+
`assets/css/theme.css:`
106+
107+
```css
108+
:root {
109+
--color-primary: #1D4ED8;
110+
--color-secondary: #9333EA;
111+
--color-bg: #ffffff;
112+
--color-text: #000000;
113+
}
114+
115+
[data-theme="dark"] {
116+
--color-primary: #60A5FA;
117+
--color-secondary: #C084FC;
118+
--color-bg: #0F172A;
119+
--color-text: #ffffff;
120+
}
121+
```
122+
123+
Use in components:
124+
125+
```html
126+
<button class="px-4 py-2" style="background: var(--color-primary); color: var(--color-text);">
127+
Themed Button
128+
</button>
129+
```
130+
131+
Or register these CSS variables as Tailwind colors if you prefer utility classes.

content/4.guide/9.primevue-theming-guide.md renamed to content/4.guide/6.theming-guide/3.nuxt-with-primevue.md

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
toc: true
3-
title: PrimeVue Theming Guide
3+
title: Nuxt with Primevue
44
---
55

6-
## Introduction
6+
## Theming with PrimeVue
77

88
This guide outlines a structured approach to applying theming in Vue and Nuxt apps using **CSS custom properties** alongside **Tailwind CSS** and **PrimeVue**. It helps ensure your application is both performant and maintainable with scalable light and dark modes.
99

@@ -13,7 +13,7 @@ This guide outlines a structured approach to applying theming in Vue and Nuxt ap
1313

1414
- **[Install Tailwind CSS](https://tailwindcss.nuxtjs.org/getting-started/installation){:target="_blank"}**
1515

16-
## 1. Tailwind Setup
16+
### 1. Tailwind Setup
1717

1818
Ensure your project includes Tailwind’s base setup:
1919

@@ -23,7 +23,7 @@ Ensure your project includes Tailwind’s base setup:
2323
@tailwind utilities;
2424
```
2525

26-
## 2. Adding Dark Mode Support
26+
### 2. Adding Dark Mode Support
2727

2828
PrimeVue uses the `system` as the default `darkModeSelector` in theme configuration. If you have a dark mode switch in your application, set the `darkModeSelector` to the selector you utilize such as `.my-app-dark` in your nuxt config so that PrimeVue can fit in seamlessly with your color scheme.
2929

@@ -62,12 +62,12 @@ theme: {
6262
}
6363
```
6464

65-
## 3. Defining Light and Dark Themes
65+
### 3. Defining Light and Dark Themes
6666

6767
Use CSS custom properties (`--var-name`) inside `:root` for light theme and a custom class (e.g., `.my-app-dark`) for dark theme overrides. Add the theming vairables in your css file where tailwind is already setup.
6868

6969

70-
### Light Theme
70+
#### Light Theme
7171

7272
```css
7373
:root {
@@ -101,7 +101,7 @@ Use CSS custom properties (`--var-name`) inside `:root` for light theme and a cu
101101
}
102102
```
103103

104-
### Dark Theme
104+
#### Dark Theme
105105

106106
```css
107107
:root.my-app-dark {
@@ -133,11 +133,11 @@ Use CSS custom properties (`--var-name`) inside `:root` for light theme and a cu
133133

134134
---
135135

136-
## 3. Using CSS Variables with Tailwind CSS
136+
### 3. Using CSS Variables with Tailwind CSS
137137

138138
While Tailwind doesn’t directly support variables in all utilities, **arbitrary values** allow us to use CSS variables in most cases:
139139

140-
### Practical Examples
140+
#### Practical Examples
141141

142142
```html
143143
<!-- Background from CSS variable -->
@@ -158,7 +158,7 @@ While Tailwind doesn’t directly support variables in all utilities, **arbitrar
158158

159159
> ⚠️ Gradients and background images must be applied using `bg-[image:var(--bg-circle-subtle)]` to render properly.
160160
161-
## 4. Switching Between Light and Dark Themes
161+
### 4. Switching Between Light and Dark Themes
162162

163163
Following is a very basic example implementation of a dark mode switch, you may extend it further by involving `prefers-color-scheme` to retrieve it from the system initially and use `localStorage` to make it stateful. See this [article](https://dev.to/abbeyperini/dark-mode-toggle-and-prefers-color-scheme-4f3m){:target="_blank"} for more information.
164164

@@ -174,7 +174,7 @@ function toggleDarkMode() {
174174
<Button label="Toggle Dark Mode" @click="toggleDarkMode()" />
175175
```
176176

177-
## 5. Naming Best Practices
177+
### 5. Naming Best Practices
178178

179179
To keep your styles scalable:
180180

@@ -195,12 +195,3 @@ To keep your styles scalable:
195195
| `--gradient-5` | `--bg-circle-spotlight` |
196196

197197
---
198-
199-
## Final Notes
200-
201-
* Use variables for colors, backgrounds, gradients, and even shadows.
202-
* Combine Tailwind's arbitrary values with semantic CSS variables.
203-
* Maintain consistent naming across light/dark modes.
204-
* Document each variable clearly to help future developers.
205-
206-
A scalable theming approach will improve maintainability, accessibility, and performance across your Vue or Nuxt projects.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
toc: true
3+
title: Primevue Optimizations
4+
---
5+
6+
## Optimization
7+
8+
Reduce bundle size through the following optimizations:
9+
10+
#### 1. Turn off primevue's `autoImport` option
11+
12+
```js
13+
primevue: {
14+
autoImport: false,
15+
}
16+
```
17+
18+
#### 2. components
19+
20+
When `autoImport` is disabled, use the `include` and `exclude` for manual registration.
21+
22+
The components to import and register are defined with the `include` option using a string array. When the value is ignored or set using the `*` alias, all of the components are registered.
23+
24+
```js
25+
primevue: {
26+
components: {
27+
include: ['Button', 'DataTable']
28+
}
29+
}
30+
```
31+
32+
In case all components are imported, particular components can still be excluded with the exclude option.
33+
34+
```js
35+
primevue: {
36+
components: {
37+
include: '*',
38+
exclude: ['Galleria', 'Carousel']
39+
}
40+
}
41+
```
42+
43+
By default, for compatibility reasons, Chart and Editor components are excluded. To include them simply set the `exclude` option to an empty list.
44+
45+
```js
46+
primevue: {
47+
components: {
48+
exclude: []
49+
}
50+
}
51+
```

0 commit comments

Comments
 (0)