ns-code-built-view-styling

Installation
SKILL.md

Styling views built in code

Views constructed imperatively (new StackLayout(), new Label(), …) and opened via getRootLayout().open(...) or attached manually sit outside your templates, and two things that "just work" in templates silently don't:

1. Tailwind utility classes may not exist

@nativescript/tailwind generates CSS only for class names that appear in scanned template/source content. A utility used only from code-built views (view.className = 'rounded-t-3xl bg-slate-800') may be purged from the emitted CSS — the view renders unstyled, and only in builds where no template happens to use the same class. That coupling is invisible.

Fix: style code-built views with inline properties, taking hex values from your palette (tailwind.config.js):

import { Color, StackLayout } from '@nativescript/core';

const card = new StackLayout();
// inline because these views are built outside any template and utility classes may be purged
card.backgroundColor = new Color('#161C26');
card.borderTopLeftRadius = 28;
card.borderTopRightRadius = 28;
Installs
19
GitHub Stars
1
First Seen
Aug 28, 2026
ns-code-built-view-styling — nativescript/skills