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
Use only design token based classes that are generated from our design system. Never use Tailwind's default color palette, arbitrary colors like hex or rgb values or font sizes. Always use the `Text` component for text styling instead of Tailwind's typography classes.
className="hover:bg-hover active:bg-pressed"// When no prop exists
146
156
>
147
157
Content
148
158
</Box>;
149
159
```
150
160
161
+
### React Native
162
+
163
+
Use `useTailwind` hook from `@metamask/design-system-twrnc-preset` instead of importing `twrnc` directly. The preset automatically handles light/dark theme switching and design token integration.
164
+
151
165
❌ **Avoid**
152
166
153
167
```tsx
154
-
const styles = {
155
-
backgroundColor: '#F2F4F6',
156
-
padding: '16px',
157
-
};
158
-
159
-
<divstyle={styles}>Content</div>;
160
-
```
168
+
importtwfrom'twrnc';
161
169
162
-
### React Native
170
+
const styles =StyleSheet.create({
171
+
container: {
172
+
backgroundColor: colors.background.default,
173
+
padding: 16,
174
+
},
175
+
});
163
176
164
-
Use `useTailwind` hook from `@metamask/design-system-twrnc-preset` instead of importing `twrnc` directly. The preset automatically handles light/dark theme switching and design token integration.
@@ -288,17 +287,32 @@ Example [eslint.config.mjs](https://github.com/MetaMask/metamask-design-system/b
288
287
### Anti-patterns to Avoid
289
288
290
289
-**No Arbitrary Values**: Don't use `[]` syntax for arbitrary values unless absolutely necessary
290
+
291
291
-**No Direct Styles**: Avoid inline `style` objects
292
292
-**No @apply**: Don't use `@apply` in CSS files
293
293
-**Avoid Style Mixing**: Try to avoid mixing Tailwind with other styling approaches like inline styles in the same component when not necessary. Style mixing may be necessary for custom animations or dynamic values that can't be achieved with Tailwind alone. However, combining component props with Tailwind classes via `className`/`twClassName`/`tw` is acceptable when no equivalent prop exists
294
-
-**No Default Colors**: Never use Tailwind's default color palette
295
-
-**No Direct Typography**: Never use typography classes directly
0 commit comments