Skip to main content

Styling Variants

Understanding inline styles vs Tailwind CSS variants and when to use each.

Comparison


Inline Styles

Pros:
  • No additional dependencies
  • Works everywhere (web and React Native)
  • Explicit, self-contained styling
  • Direct control over every value
Cons:
  • More verbose code
  • Manual dark mode logic in every component
  • Repeated color values across files
Best for:
  • Projects without Tailwind
  • React Native / Expo apps
  • Developers who prefer explicit styles

Tailwind CSS

Pros:
  • Concise, readable code
  • On React, automatic dark mode with the dark: prefix
  • Integrates with design systems
  • Smaller bundle with purging
Cons:
  • Requires Tailwind CSS 3.3 or later (4 included) on React, and NativeWind 4 (with Tailwind CSS 3) on React Native and Expo
  • Learning curve if unfamiliar
  • Less explicit (need to know what classes do)
Best for:
  • Projects already using Tailwind
  • Web-only React apps
  • Developers who prefer utility-first CSS

Choosing a Variant

Choose during npx @sublay/cli init:
If you’re unsure: choose Inline Styles. It works everywhere with no setup.

Switching Variants

To switch after installation, delete the component and reinstall with the new style:
This replaces your component files. Back up any customizations before switching.

React Native Styling

For React Native and Expo:
  • Inline Styles → Standard React Native StyleSheet / style prop approach
  • Tailwind → Uses NativeWind (className prop)

Tailwind on React Native and Expo

The Tailwind variant styles everything with className, which works only once NativeWind is set up in your app. Without it the components render unstyled, with no error. NativeWind’s installation guide is the reference; for these components the setup is:
1

Install NativeWind and Tailwind CSS 3

NativeWind 4 works with Tailwind CSS 3, not 4.
2

tailwind.config.js

3

global.css, imported once

Import it in your app’s entry file: import "./global.css";
4

babel.config.js

5

metro.config.js

6

TypeScript only: nativewind-env.d.ts

Dark mode needs no Tailwind setup on React Native and Expo: pass the component’s theme prop ("light" or "dark"), and each class is chosen from it in code.
NativeWind counts 1rem as 14 pixels on phones (Tailwind on the web counts 16). The inline styles variant uses the same 14-based sizes, so the two variants look the same.

Next Steps

Colors & Theming

Customize colors

Layout & Structure

Modify layout

Adding Features

Add custom functionality

Advanced

Advanced techniques