You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `part="root"` is special — it maps to the standard `style` prop instead of `rootStyle`. This means styles applied to a component's class name automatically reach the root element:
109
+
110
+
```jsx
111
+
// This:
112
+
<Button styleName="my-button"/>
113
+
styl`
114
+
.my-button
115
+
background green
116
+
`
117
+
118
+
// Effectively becomes:
119
+
<Button style={{ background:'green' }} />
120
+
```
121
+
122
+
You don't need to write `::part(root)` explicitly — just style the class directly. This makes `part="root"` work seamlessly with any component that accepts a `style` prop, including third-party components and React Native built-ins.
123
+
104
124
## Complete Example
105
125
106
126
Here's a full example showing a customizable Card component:
@@ -111,7 +131,7 @@ import { styl } from 'cssxjs'
111
131
112
132
exportfunctionCard({ title, children }) {
113
133
return (
114
-
<div part="root" styleName="card">
134
+
<div part="root" styleName="root">
115
135
<div part="header" styleName="header">
116
136
<h3 part="title" styleName="title">{title}</h3>
117
137
</div>
@@ -122,7 +142,7 @@ export function Card({ title, children }) {
0 commit comments