npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nativescript/tailwind

v4.0.7

Published

TailwindCSS for NativeScript

Readme

@nativescript/tailwind

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.

Makes using Tailwind CSS in NativeScript a whole lot easier!

<label
  text="Tailwind CSS is awesome!"
  class="px-2 py-1 text-center text-blue-600 bg-blue-200 rounded-full"
/>

Tailwind CSS is awesome!

Usage

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).

Tailwind CSS v4

If you need to use Tailwind CSS v4, follow these steps. Tailwind CSS v4 support simplifies the setup significantly over v3.

Install dependencies:

npm install --save @nativescript/tailwind tailwindcss

Import Tailwind: Add the following to your app.css or app.scss:

@import 'tailwindcss';

Upgrading from Tailwind CSS 3

Update dependencies:

npm install --save tailwindcss@latest

Open your app.css or app.scss and replace any existing Tailwind imports with:

@import 'tailwindcss';

Tailwind CSS v3

If you need to use Tailwind CSS v3, follow these steps:

Install dependencies:

npm install --save @nativescript/tailwind tailwindcss

Generate tailwind.config.js:

npx tailwindcss init

Configure tailwind.config.js: When the 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.

// tailwind.config.js
const plugin = require('tailwindcss/plugin');

/** @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: 
     *
     *   <Label class="android:text-red-500 ios:text-blue-500" />
     *
     */
    plugin(function ({ addVariant }) {
      addVariant('android', '.ns-android &');
      addVariant('ios', '.ns-ios &');
    }),
  ],
  corePlugins: {
    preflight: false // disables browser-specific resets
  }
}

Include Tailwind directives: Change your app.css or app.scss to include the tailwind directives:

@tailwind base;
@tailwind components;
@tailwind utilities;

Start using tailwind in your app.

Using a custom PostCSS config

Manual PostCSS configuration is typically not required for Tailwind CSS v4. @nativescript/tailwind handles the necessary setup automatically.

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:

// postcss.config.js (Example for v4 with other plugins)

module.exports = {
  plugins: [
    "@nativescript/tailwind", // Handles Tailwind v4 setup
    // Add other PostCSS plugins here
    "@csstools/postcss-is-pseudo-class" 
  ],
};

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.

// postcss.config.js (Example for v3 customization)

module.exports = {
  plugins: [
    ["tailwindcss", { config: "./tailwind.config.custom.js" }],
    "@nativescript/tailwind",
    // Add other PostCSS plugins here
    "@csstools/postcss-is-pseudo-class" 
  ],
};

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:

ns config set tailwind.autoload false

Usage with older @nativescript/webpack versions

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.

npm install --save-dev @nativescript/tailwind tailwindcss postcss postcss-loader

Create postcss.config.js with the following:

module.exports = {
  plugins: [
      require('tailwindcss'),
      require('nativescript-tailwind')
  ]
}

Generate a tailwind.config.js with

npx tailwindcss init

Adjust content, darkMode, corePlugins plus any other settings you need, here are the values we recommend:

// tailwind.config.js

module.exports = {
  content: [
    './app/**/*.{css,xml,html,vue,svelte,ts,tsx}'
  ],
  // use .dark to toggle dark mode - since 'media' (default) does not work in NativeScript
  darkMode: 'class',
  theme: {
    extend: {},
  },
  plugins: [],
  corePlugins: {
    preflight: false // disables browser-specific resets
  }
}

Change your app.css or app.scss to include the tailwind utilities

@tailwind base;
@tailwind components;
@tailwind utilities;

Update webpack.config.js to use PostCSS

Find the section of the config that defines the rules/loaders for different file types. To quickly find this block - search for rules: [.

For every css/scss block, append the postcss-loader to the list of loaders, for example:

{
  test: /[\/|\\]app\.css$/,
  use: [
    'nativescript-dev-webpack/style-hot-loader',
    {
      loader: "nativescript-dev-webpack/css2json-loader",
      options: { useForImports: true }
    },
+   'postcss-loader',
  ],
}

Make sure you append postcss-loader to all css/scss rules in the config.