stylo-rn
v1.0.3
Published
A Tailwind-like classNames utility for React Native powered by a fast Trie-based style lookup.Write utility classes in your components and convert them into React Native style objects instantly.
Maintainers
Readme
stylo-rn:
# Stylo RN
A **Tailwind-like classNames utility for React Native** powered by a fast **Trie-based style lookup**.
Write utility classes in your components and convert them into React Native style objects instantly.
---
## 📦 Installation
```bash
npm install stylo-rn🚀 Usage
import { classNames } from 'stylo-rn';
const styles = classNames('p-2 mt-3 bg-red-500 text-xs text-red-300');
console.log(styles);
// {
// padding: 8,
// marginTop: 12,
// backgroundColor: '#EF4444',
// fontSize: 12,
// color: '#FCA5A5'
// }🛠 Adding New Classes
If you want to add new utility classes:
Open
src/stylesMap.jsAdd your new class mapping to the object. Example:
"border-dotted": { borderStyle: "dotted" }In the
src/folder, run:node bundle.jsThis regenerates the
serializedTrie.jsonfile with your updated classes.
📂 Project Structure
src/
├── stylesMap.js # All style class definitions
├── bundle.js # Script to generate serializedTrie.json
├── styleParser.js # classNames() method
├── Trie.js # Trie implementation
└── serializedTrie.json # Auto-generated style lookup data
index.js # Entry point for the package⚡ Why Stylo RN?
- Fast lookups – Styles are stored in a serialized Trie for O(k) lookups.
- Extendable – Add your own custom utility classes easily.
📜 License
MIT License.
