From 023211c9dacdc0753343bda1ca45f8b7f2b6dc30 Mon Sep 17 00:00:00 2001 From: Steve McNiven-Scott Date: Fri, 18 Apr 2025 09:20:02 -0400 Subject: [PATCH 1/3] Update readme with tailwind 4 --- README.md | 162 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index ae33f4c..2f2f31d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # @nativescript/tailwind -> **Warning**: :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. +> **Warning**: :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. Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot easier! @@ -15,93 +15,143 @@ Makes using [Tailwind CSS](https://tailwindcss.com/) in NativeScript a whole lot ## Usage -> **Note:** 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. +> **Note:** 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). -Install `@nativescript/tailwind` and `tailwindcss` +### Tailwind CSS v4 -```cli -npm install --save @nativescript/tailwind tailwindcss -``` +Tailwind CSS v4 [support](https://github.com/NativeScript/tailwind/pull/194) simplifies the setup significantly over v3. -Generate a `tailwind.config.js` with +**Install dependencies:** -```cli -npx tailwindcss init -``` + ```cli + npm install --save @nativescript/tailwind tailwindcss + ``` -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. +**Import Tailwind:** Add the following to your `app.css` or `app.scss`: -```js -// tailwind.config.js -const plugin = require('tailwindcss/plugin'); + ```css + @import 'tailwindcss'; + ``` -/** @type {import('tailwindcss').Config} */ -module.exports = { - // check this setting first for initial setup issues - content: [ - './app/**/*.{css,xml,html,vue,svelte,ts,tsx}' - ], - // use the .ns-dark class to control dark mode (applied by NativeScript) - since 'media' (default) is not supported. - darkMode: ['class', '.ns-dark'], - theme: { - extend: {}, - }, - plugins: [ - /** - * A simple inline plugin that adds the ios: and android: variants - * - * Example usage: - * - *