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
Copy file name to clipboardExpand all lines: apps/public-docsite-v9/src/Concepts/Migration/KeepingDesignConsistent.stories.mdx
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ As detailed in the _/Concepts/Developer/Styling Components_ topic, you can creat
102
102
If you do create custom styles, we strongly recommend using design tokens.
103
103
This ensures styles update with theme changes.
104
104
105
-
## You can recompose components with custom styles
105
+
## You can recompose components with different styles
106
106
107
107
Fluent v9 has a powerful composition model using React hooks.
108
108
Each component is separated into a hook that maps props to state, a hook that uses state to set className styles on each slot, and a render function that outputs each slot with applied props.
This approach is meant as an escape-hatch when all other customizations are not enough for your use case.
155
+
156
+
**⚠ Be careful **
157
+
158
+
- Never change any state properties other than `className`.
159
+
- Never dynamically change hooks at runtime. This will lead to unstable hook calls.
160
+
- Custom style hooks are called from within the component and receive the component state.
161
+
- Be judicious with creating styles and making `mergeClasses` call as you may affect the performance.
162
+
163
+
You can pass `FluentProvider.customStyleHooks_unstable` a set of custom style hooks. The custom style hooks are considered unstable and the API may change at any time.
164
+
Each custom style hook can update root or slot class names.
To override existing styles, use `makeStyles` to create your custom styles and then call `mergeClasses` with state `className` and the your new styles.
185
+
To completely replace existing styles, overwrite the state `className`.
186
+
187
+
When `FluentProvider` are nested, custom style hooks will be shallow merged.
0 commit comments