You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:warning:`@nativescript/core@8.2.0` is required for colors to work properly You may see wrong colors on older core versions, because Tailwind CSS v3 uses the RGB/A color notation, which has been implemented for 8.2.0 and prior versions don't support it.
16
+
:warning:For **Tailwind CSS v3**, `@nativescript/core@8.2.0` is required for colors to work properly. You may see wrong colors on older core versions, because Tailwind CSS v3 uses the RGB/A color notation, which has been implemented for 8.2.0. **Tailwind CSS v4** uses Lightning CSS which handles this automatically.
17
17
18
18
:::
19
19
@@ -32,23 +32,57 @@ Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot
32
32
33
33
:::tip Note
34
34
35
-
This guide assumes you are using `@nativescript/webpack@5.x`as some configuration is done automatically. If you have not upgraded yet, please read the docs below for usage with older `@nativescript/webpack` versions.
35
+
This guide assumes you are using `@nativescript/webpack@5.x`or higher. If you have not upgraded yet, please read the docs below for usage with older `@nativescript/webpack` versions (applicable to Tailwind CSS v3).
36
36
37
37
:::
38
38
39
-
Install `@nativescript/tailwind` and `tailwindcss`
39
+
### Tailwind CSS v4
40
+
41
+
If you need to use Tailwind CSS v4, follow these steps. Tailwind CSS v4 [support](https://github.com/NativeScript/tailwind/pull/194) simplifies the setup significantly over v3.
When the [NativeScript CLI](https://github.com/NativeScript/nativescript-cli) creates a new project, it may put code into a `src` folder instead of the `app` referenced below. Adjust `content`, `darkMode`, `corePlugins` plus any other settings you need. Here are the values we recommend. If you're struggling to get Tailwind working for the first time, check the `content` setting.
85
+
**Configure `tailwind.config.js`:**When the [NativeScript CLI](https://github.com/NativeScript/nativescript-cli) creates a new project, it may put code into a `src` folder instead of the `app` referenced below. Adjust `content`, `darkMode`, `corePlugins` plus any other settings you need. Here are the values we recommend. **If you're struggling to get Tailwind working for the first time, check the `content` setting.**
52
86
53
87
```js
54
88
// tailwind.config.js
@@ -83,7 +117,7 @@ module.exports = {
83
117
}
84
118
```
85
119
86
-
Change your `app.css` or `app.scss` to include the tailwind utilities
120
+
**Include Tailwind directives:**Change your `app.css` or `app.scss` to include the tailwind directives:
87
121
88
122
```css
89
123
@tailwind base;
@@ -95,35 +129,50 @@ Start using tailwind in your app.
95
129
96
130
### Using a custom PostCSS config
97
131
98
-
In case you need to customize the postcss configuration, you can create a `postcss.config.js` (other formats are supported, see https://github.com/webpack-contrib/postcss-loader#config-files) file and add any customizations, for example:
132
+
Manual PostCSS configuration is typically **not required** for **Tailwind CSS v4**. `@nativescript/tailwind` handles the necessary setup automatically.
133
+
134
+
However, if you need to add _other_ PostCSS plugins alongside Tailwind v4, create a `postcss.config.js` (or other supported formats, see https://github.com/webpack-contrib/postcss-loader#config-files) and include `@nativescript/tailwind`:
135
+
136
+
```js
137
+
// postcss.config.js (Example for v4 with other plugins)
For **Tailwind CSS v3**, if you need to customize the postcss configuration (e.g., use a custom `tailwind.config.custom.js`), you can create a `postcss.config.js` file.
99
149
100
150
```js
101
-
// postcss.config.js
151
+
// postcss.config.js (Example for v3 customization)
if you want to apply customizations to `tailwindcss` or `@nativescript/tailwind`, you will need to disable autoloading:
165
+
If you want to apply customizations to `tailwindcss` or `@nativescript/tailwind` in v3 using a custom PostCSS config, you will need to disable autoloading:
115
166
116
167
```cli
117
168
ns config set tailwind.autoload false
118
169
```
119
170
120
-
This is required only if you make changes to either of the 2 plugins - because by default `postcss-loader` processes the config file first, and then the `postcssOptions` passed to it. With autoloading enabled, any customizations will be overwritten due to the loading order. Setting `tailwind.autoload` to `false` just disables the internal loading of these plugins, and requires you to manually add them to your postcss config in the above order.
121
-
122
171
:::
123
172
124
173
## Usage with older @nativescript/webpack versions
125
174
126
-
This usage is considered legacy and will not be supported - however we are documenting it here in case your project is still using older `@nativescript/webpack`.
175
+
This usage is considered legacy and will not be supported - however we are documenting it here in case your project is still using older `@nativescript/webpack`.**This applies to Tailwind CSS v3 setups.**
0 commit comments