@@ -7,42 +7,49 @@ CSSX extends JSX with custom props for styling.
77Apply class-based styles to an element. Works like ` className ` but with scoped, processed styles.
88
99``` jsx
10- < div styleName= " card featured" > Content< / div>
10+ < View styleName= " card featured" >
11+ < Text > Content< / Text >
12+ < / View>
1113```
1214
1315** Syntax Options:**
1416
1517``` jsx
1618// String — simple static class
17- < div styleName= " card" / >
19+ < View styleName= " card" / >
1820
1921// Array with object — recommended for dynamic classes
20- < div styleName= {[' card' , variant, { active, disabled }]} / >
22+ < View styleName= {[' card' , variant, { active, disabled }]} / >
2123```
2224
2325### Array Pattern (Recommended)
2426
2527Use arrays with an object at the end for modifiers:
2628
2729``` jsx
28- function Card ({ variant, highlighted, compact }) {
30+ import { View , Text } from ' react-native'
31+
32+ function Card ({ variant, highlighted, compact, children }) {
2933 return (
30- < div styleName= {[' card' , variant, { highlighted, compact }]}>
31- Content
32- < / div >
34+ < View styleName= {[' card' , variant, { highlighted, compact }]}>
35+ < Text > {children} < / Text >
36+ < / View >
3337 )
3438
3539 styl`
3640 .card
3741 background white
38- border 1px solid #ddd
42+ border-width 1px
43+ border-color #ddd
3944 padding 16px
4045
4146 &.featured
42- border 2px solid gold
47+ border-width 2px
48+ border-color gold
4349
4450 &.highlighted
45- box-shadow 0 0 10px gold
51+ shadow-color gold
52+ shadow-radius 10px
4653
4754 &.compact
4855 padding 8px
@@ -62,18 +69,19 @@ The pattern:
6269For truly dynamic values, combine ` styleName ` with the ` style ` prop:
6370
6471``` jsx
72+ import { View , Text } from ' react-native'
73+
6574function ProgressBar ({ progress }) {
6675 return (
67- < div styleName= " bar" style= {{ width: ` ${ progress} %` }}>
68- {progress}%
69- < / div >
76+ < View styleName= " bar" style= {{ width: ` ${ progress} %` }}>
77+ < Text > {progress}% < / Text >
78+ < / View >
7079 )
7180
7281 styl`
7382 .bar
7483 height 20px
7584 background-color #4caf50
76- transition width 0.3s
7785 `
7886}
7987```
@@ -85,12 +93,14 @@ function ProgressBar({ progress }) {
8593Expose an element for external styling via ` :part() ` .
8694
8795``` jsx
96+ import { Pressable , Text } from ' react-native'
97+
8898function Button ({ children }) {
8999 return (
90- < button part= " root" styleName= " root" >
91- < span part= " icon" > ★< / span >
92- < span part= " text" > {children}< / span >
93- < / button >
100+ < Pressable part= " root" styleName= " root" >
101+ < Text part= " icon" styleName = " icon " > ★< / Text >
102+ < Text part= " text" styleName = " text " > {children}< / Text >
103+ < / Pressable >
94104 )
95105}
96106```
0 commit comments