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
Copy file name to clipboardExpand all lines: README.md
+62-12Lines changed: 62 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# @nativescript/tailwind
2
2
3
-
> **Warning**: :warning:`@nativescript/[email protected]` 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.
3
+
> **Warning**: :warning:For **Tailwind CSS v3**, `@nativescript/[email protected]` 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.
4
4
5
5
Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot easier!
6
6
@@ -15,21 +15,55 @@ Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot
15
15
16
16
## Usage
17
17
18
-
> **Note:** This guide assumes you are using `@nativescript/[email protected]`as some configuration is done automatically. If you have not upgraded yet, please read the docs below for usage with older `@nativescript/webpack` versions.
18
+
> **Note:** This guide assumes you are using `@nativescript/[email protected]`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).
19
19
20
-
Install `@nativescript/tailwind` and `tailwindcss`
20
+
### Tailwind CSS v4
21
+
22
+
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.
66
+
**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.**
33
67
34
68
```js
35
69
// tailwind.config.js
@@ -66,7 +100,7 @@ module.exports = {
66
100
}
67
101
```
68
102
69
-
Change your `app.css` or `app.scss` to include the tailwind utilities
103
+
**Include Tailwind directives:**Change your `app.css` or `app.scss` to include the tailwind directives:
70
104
71
105
```css
72
106
@tailwind base;
@@ -78,30 +112,46 @@ Start using tailwind in your app.
78
112
79
113
### Using a custom PostCSS config
80
114
81
-
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:
115
+
Manual PostCSS configuration is typically **not required** for **Tailwind CSS v4**. `@nativescript/tailwind` handles the necessary setup automatically.
116
+
117
+
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`:
118
+
119
+
```js
120
+
// 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.
82
132
83
133
```js
84
-
// postcss.config.js
134
+
// postcss.config.js (Example for v3 customization)
> **Note:**if you want to apply customizations to `tailwindcss` or `@nativescript/tailwind`, you will need to disable autoloading:
146
+
> **Note (Tailwind CSS v3):**If you want to apply customizations to `tailwindcss` or `@nativescript/tailwind` in v3 using a custom PostCSS config, you will need to disable autoloading:
96
147
>
97
148
> ```cli
98
149
> ns config set tailwind.autoload false
99
150
> ```
100
-
> 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.
101
151
102
152
## Usage with older @nativescript/webpack versions
103
153
104
-
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`.
154
+
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