purgetss
π―Skillfrom maccesar/titanium-sdk-skills
Purges and generates utility-first TSS styles for Titanium mobile apps, automatically creating optimized `app.tss` based on used utility classes.
Part of
maccesar/titanium-sdk-skills(7 items)
Installation
npm install -g @maccesar/titoolscurl -fsSL https://raw.githubusercontent.com/macCesar/titools/main/install.sh | bashSkill Details
"Titanium PurgeTSS utility-first styling toolkit. Use when styling, reviewing, analyzing, or examining Titanium UI with utility classes, configuring config.cjs, creating dynamic components with $.UI.create(), building animations, using grid layouts, setting up icon fonts, or working with TSS styles. Never suggest other CSS framework classes - verify in class-index.md first."
Overview
# PurgeTSS Expert
Utility-first styling toolkit for Titanium/Alloy mobile apps.
Project Detection
:::info AUTO-DETECTS PURGETSS PROJECTS
This skill automatically detects PurgeTSS usage when invoked and provides utility-first styling guidance.
Detection occurs automatically - no manual command needed.
PurgeTSS project indicators:
purgetss/folderpurgetss/config.cjsconfiguration filepurgetss/styles/utilities.tssutility classesapp/styles/app.tss(auto-generated)
Behavior based on detection:
- PurgeTSS detected β Provides PurgeTSS-specific guidance, recommends utility classes, suggests
$.UI.create()for dynamic components - Not detected β Does NOT suggest PurgeTSS utility classes, does NOT recommend
$.UI.create(), does NOT reference PurgeTSS-specific patterns
:::
Core Workflow
- Setup:
purgetss create 'name'orpurgetss initfor existing projects - Build: Write XML with utility classes β PurgeTSS auto-generates
app.tss - Configure: Customize via
purgetss/config.cjs
Project Structure
```bash
./purgetss/
ββ fonts/ # Custom font files (.ttf, .otf)
ββ styles/
β ββ definitions.css # For VS Code IntelliSense
β ββ utilities.tss # All PurgeTSS utility classes
ββ config.cjs # Theme configuration
./app/styles/
ββ app.tss # AUTO-GENERATED - DO NOT EDIT DIRECTLY
ββ _app.tss # YOUR CUSTOM STYLES (persists across runs)
```
Understanding `app.tss` vs `_app.tss`
:::warning CRITICAL: app.tss IS AUTO-GENERATED
app.tss is ALWAYS regenerated every time the app compiles.
PurgeTSS scans ALL XMLs and Controllers for utility classes, then generates a fresh app.tss containing only the classes actually used.
NEVER edit app.tss directly - your changes WILL be overwritten on the next build.
:::
:::info THE _app.tss BACKUP FILE
On first run, PurgeTSS backs up your original app.tss to _app.tss.
_app.tss is your custom styles file - it persists across all PurgeTSS runs.
Every build, PurgeTSS:
- Scans XMLs and Controllers for used classes
- Regenerates
app.tssfrom scratch - Copies
_app.tsscontent into the generatedapp.tss
Better approach: define custom classes in config.cjs instead of _app.tss.
:::
Checking for Unused/Unsupported Classes
:::danger ALWAYS CHECK app.tss FOR ERRORS
At the end of every generated app.tss, look for this section:
```tss
// Unused or unsupported classes
// .my-typo-class
// .non-existent-utility
```
These are classes used in your XMLs or Controllers that have NO definition anywhere:
- Not in
utilities.tss(generated from PurgeTSS utilities) - Not in
_app.tss(your custom styles) - Not in any other
.tssfile in thestyles/folder
This means:
- You have a typo in your class name
- You're using a class that doesn't exist in PurgeTSS
- You need to define the class in
_app.tssorconfig.cjs
As part of any analysis, ALWAYS check the end of app.tss and report any unused/unsupported classes to the user!
:::
How `utilities.tss` Works
:::info UTILITIES.TSS REGENERATION
./purgetss/styles/utilities.tss contains ALL available PurgeTSS utility classes.
It regenerates when ./purgetss/config.cjs changes - this is where you define:
- Custom colors
- Custom spacing scales
- Ti Element styles
- Any project-specific utilities
If a class appears in "Unused or unsupported classes" in app.tss, it means it's truly not defined anywhere - not even in your config.cjs customizations.
:::
Quick Start
```bash
purgetss create 'MyApp' -d -v fa
# -d: Install dev dependencies (ESLint, Tailwind)
# -v: Copy icon fonts (fa, mi, ms, f7)
```
:::tip NEW PROJECT: Clean Up Default app.tss
For new projects created with purgetss create, the default app/styles/app.tss contains a large commented template.
You can safely DELETE this file - PurgeTSS will regenerate it on the first build with only the classes you actually use, and create a clean _app.tss backup.
This prevents carrying around unnecessary commented code and ensures a fresh start.
:::
Critical Rules (Low Freedom)
β PREFER `$.UI.create()` for Dynamic Components
:::tip RECOMMENDED FOR DYNAMIC COMPONENTS
When creating components dynamically in Controllers, use $.UI.create() instead of Ti.UI.create() to get full PurgeTSS utility class support:
```javascript
// β RECOMMENDED - Full PurgeTSS support
const view = $.UI.create('View', {
classes: ['w-screen', 'h-auto', 'bg-white', 'rounded-lg']
})
// β AVOID - No PurgeTSS classes
const view = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
backgroundColor: '#ffffff',
borderRadius: 8
})
```
See [Dynamic Component Creation](references/dynamic-component-creation.md) for complete guide.
:::
π¨ RESPECT USER FILES
NEVER delete any existing .tss files (like index.tss, detail.tss) or other project files without explicit user consent.
How to handle migration to PurgeTSS:
- ONLY replace custom classes with PurgeTSS utility classes if the user explicitly requests it.
- When requested:
- Analyze the definitions in the existing .tss files.
- Update the XML/Controller components with equivalent PurgeTSS utility classes.
- WAIT for user confirmation before suggesting or performing any file deletion.
- If the user prefers keeping manual
.tssfiles for specific styles, respect that choice and only use PurgeTSS for new or requested changes.
π¨ NO FLEXBOX - Titanium Doesn't Support It
:::danger FLEXBOX CLASSES DO NOT EXIST
The following are NOT supported:
- β
flex,flex-row,flex-col - β
justify-between,justify-center,justify-start,justify-end - β
items-centerfor alignment (exists but setswidth/height: FILL)
Use Titanium layouts instead:
- β
horizontal- Children left to right - β
vertical- Children top to bottom - β
Omit layout class - Defaults to
composite(absolute positioning)
:::tip CRITICAL: Understanding Layout Composition
When building complex UIs, carefully choose the layout mode for each container:
vertical - Stack elements top to bottom (most common):
```xml
```
horizontal - Arrange elements left to right:
```xml
```
composite (default) - Absolute positioning with top, left, etc.:
```xml
```
Common Issue: If you see elements appearing in unexpected positions (e.g., a header bar "behind" content), check if parent containers have conflicting layout modes. Each container's layout affects its direct children only.
:::
π¨ PLATFORM-SPECIFIC PROPERTIES REQUIRE MODIFIERS
:::danger CRITICAL: Platform-Specific Properties Require Modifiers
Using Ti.UI.iOS. or Ti.UI.Android. properties WITHOUT platform modifiers causes cross-platform compilation failures.
WRONG - Adds iOS code to Android (causes failure):
```tss
// β BAD - Adds Ti.UI.iOS to Android project
"#mainWindow": {
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
}
```
CORRECT - Use platform modifiers in TSS:
```tss
// β GOOD - Only adds to iOS
"#mainWindow[platform=ios]": {
statusBarStyle: Ti.UI.iOS.StatusBar.LIGHT_CONTENT
}
```
OR use PurgeTSS platform modifier classes:
```xml
```
Properties that ALWAYS require platform modifiers:
- iOS:
statusBarStyle,modalStyle,modalTransitionStyle,systemButton - Android:
actionBarconfiguration - ANY
Ti.UI.iOS.,Ti.UI.Android.constant
When suggesting platform-specific code:
- Check if user's project supports that platform
- ALWAYS use
[platform=ios]or[platform=android]TSS modifier - OR use PurgeTSS platform classes like
ios:bg-blue-500
For complete reference on platform modifiers, see [Platform Modifiers](references/platform-modifiers.md).
:::
Other Mandatory Rules
- NO
p-padding classes: Titanium does NOT support a nativepaddingproperty onView,Window,ScrollView, orTableView. Always use margins on children (m-) to simulate internal spacing. - View defaults to
SIZE: Usew-screen/h-screento fill space when needed. rounded-full: To get a perfect circle, userounded-full-XX(where XX is the width/height of the square element).rounded-full-XXincludes size: These classes already setwidth,height, andborderRadius. Do not addw-XX h-XX/wh-XXunless you need to override.m-xxon FILL elements: Addingm-4to aw-screenelement pins it to all four edges (top, bottom, left, right). This will stretch the component vertically to fill the parent unless you explicitly addh-auto(Ti.UI.SIZE) to constrain it to its content.w-XX+h-XXβwh-XX: If both width and height use the same scale value, prefer a singlewh-XX(order doesn't matter:w-10 h-10andh-10 w-10are equivalent).- Use
wh-shortcuts: PurgeTSS provides a complete scale of combined width/height utilities:
- Numeric Scale: wh-0 to wh-96 (e.g., wh-16 sets both to 64px).
- Fractions: wh-1/2, wh-3/4, up to wh-11/12 for proportional sizing.
- Special Values: wh-auto (explicit SIZE), wh-full (100%), and wh-screen (FILL).
- Using these instead of separate w- and h- classes improves XML readability and reduces generated TSS size.
:::tip LAYOUT TIP: EDGE PINNING
If using margins (m-) causes your Label or Button to stretch unexpectedly, it is due to Titanium's Edge Pinning rule (2 opposite pins = computed dimension). Use the wh-auto class to explicitly force SIZE behavior and prevent stretching.
:::
- NEVER add
compositeclass explicitly - That's the default, usehorizontal/verticalwhen needed - Arbitrary values use parentheses:
w-(100px),bg-(#ff0000)- NO square brackets mode: 'all'required inconfig.cjsfor Ti Elements styling- Classes use
kebab-case:.my-class, IDs usecamelCase:#myId
Common Anti-Patterns
WRONG:
```xml
```
CORRECT:
```xml
```
WRONG (Dynamic Components):
```javascript
// Manual styling with Ti.UI.create()
const view = Ti.UI.createView({
width: Ti.UI.FILL,
backgroundColor: '#fff',
borderRadius: 8
})
```
CORRECT (Dynamic Components):
```javascript
// PurgeTSS classes with $.UI.create()
const view = $.UI.create('View', {
classes: ['w-screen', 'bg-white', 'rounded-lg']
})
```
Class Verification Workflow
:::danger CRITICAL: VERIFY CLASSES BEFORE SUGGESTING
NEVER guess or hallucinate classes based on other CSS Frameworks knowledge!
PurgeTSS shares naming with some CSS Frameworks but has DIFFERENT classes for Titanium.
Always verify a class exists before suggesting it.
:::
Verification Steps
- Check if it's a KNOWN anti-pattern
- See [PROHIBITED Classes](references/class-index.md#prohibited-tailwind-classes-that-do-not-exist)
- Common mistakes: flex-row, justify-between, p-4 on Views (p-* not supported on Views)
- Check the Class Index
- See [Class Index](references/class-index.md) for available patterns
- Constant properties like keyboard-type-, return-key-type- have dedicated classes
- Search the project when unsure
```bash
# Search for a class pattern in the project's utilities.tss
grep -E "keyboard-type-" ./purgetss/styles/utilities.tss
grep -E "return-key-type-" ./purgetss/styles/utilities.tss
grep -E "^'bg-" ./purgetss/styles/utilities.tss
```
- After making changes
- Check app.tss for "Unused or unsupported classes" section at the end
- Report any typos or non-existent classes to the user
What HAS Classes vs What DOESN'T
| Has Classes in PurgeTSS | Does NOT Have Classes |
| ----------------------- | ------------------------------------- |
| keyboard-type-email | hintText (use attribute) |
| return-key-type-next | passwordMask (use attribute) |
| text-center | autocorrect (use attribute) |
| bg-blue-500 | autocapitalization (use attribute) |
| w-screen | flex-row β use horizontal |
| wh-16 | justify-between β use margins |
| rounded-lg | w-full β use w-screen |
| m-4, gap-4 | p-4 on View β use m-4 on children |
:::tip
When in doubt, prefer using the search command above to verify. It's better to spend 5 seconds verifying than suggesting a class that doesn't exist and will appear in the "unused classes" warning.
:::
Reference Guides
Load these only when needed:
Essential References
- [Class Index](references/class-index.md) - Quick patterns, prohibited classes, verification commands (LOAD FIRST when unsure about a class)
- [Dynamic Component Creation](references/dynamic-component-creation.md) -
$.UI.create()andAlloy.createStyle()for creating components in Controllers (READ FIRST for dynamic components)
Setup & Configuration
- [Installation & Setup](references/installation-setup.md) - First run, VS Code, LiveView
- [CLI Commands](references/cli-commands.md) - All
purgetsscommands - [Migration Guide](references/migration-guide.md) - Migrating existing apps from manual TSS to PurgeTSS
Customization
- [Deep Customization](references/customization-deep-dive.md) - config.cjs, colors, spacing, Ti Elements
- [Custom Rules](references/custom-rules.md) - Styling Ti Elements, IDs, classes
- [Apply Directive](references/apply-directive.md) - Extracting utility combinations
- [Configurable Properties](references/configurable-properties.md) - All 80+ customizable properties
Layout & Styling
- [UI/UX Design Patterns](references/ui-ux-design.md) - Complete guide to mobile UI components with PurgeTSS (cards, lists, forms, buttons, navigation, modals, accessibility)
- [Grid Layout System](references/grid-layout.md) - 12-column grid, responsive layouts
- [Smart Mappings](references/smart-mappings.md) - How gap, shadows, and grid work under the hood
- [Arbitrary Values](references/arbitrary-values.md) - Parentheses notation for custom values
- [Platform Modifiers](references/platform-modifiers.md) - ios:, android:, tablet:, handheld:
- [Opacity Modifier](references/opacity-modifier.md) - Color transparency with /50 syntax
- [Titanium Resets](references/titanium-resets.md) - Default styles for Ti elements
Performance
- [Performance Tips](references/performance-tips.md) - Optimizing PurgeTSS apps (bridge crossings, ListView, animations)
Components
- [TiKit UI Components](references/tikit-components.md) - Ready-to-use Alerts, Avatars, Buttons, Cards, Tabs built with PurgeTSS
Fonts & Animations
- [Icon Fonts](references/icon-fonts.md) - Font Awesome 7, Material Icons, custom icon libraries
- [Animation Component](references/animation-system.md) - Declarative
API
:::tip TEXT FONTS (Google Fonts, Roboto, etc.)
For text fonts, see [CLI Commands β build-fonts](references/cli-commands.md#purgetss-build-fonts-alias-bf).
:::
Examples
For complete WRONG vs CORRECT examples including:
- Titanium layout patterns (horizontal, vertical, composite)
- Grid with percentages
- Gap usage
- Manual .tss anti-patterns
- Dynamic component creation with
$.UI.create()andAlloy.createStyle()
See [EXAMPLES.md](references/EXAMPLES.md) and [Dynamic Component Creation](references/dynamic-component-creation.md)
Related Skills
For tasks beyond styling, use these complementary skills:
| Task | Use This Skill |
| -------------------------------------------- | -------------- |
| Project architecture, services, controllers | ti-expert |
| Complex UI components, ListViews, gestures | ti-ui |
| Alloy MVC concepts, data binding, TSS syntax | alloy-guides |
| Native features (camera, location, push) | ti-howtos |
More from this repository6
alloy-howtos skill from maccesar/titanium-sdk-skills
ti-ui skill from maccesar/titanium-sdk-skills
alloy-expert skill from maccesar/titanium-sdk-skills
ti-guides skill from maccesar/titanium-sdk-skills
ti-howtos skill from maccesar/titanium-sdk-skills
alloy-guides skill from maccesar/titanium-sdk-skills