Skip to content

Commit 9df5805

Browse files
committed
docs: improve runtime tw usage example with better patterns
1 parent 9225f95 commit 9df5805

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/src/content/docs/guides/runtime-tw.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ import { useState } from "react";
2626

2727
export function RuntimeExample({ color }) {
2828
const [isActive, setIsActive] = useState(false);
29-
29+
const bgColor = tw`bg-${color}-500 active:bg-${color}-700`;
30+
const textColor = tw`text-${color}-500`;
3031
return (
3132
<View className="flex-1 p-4 bg-gray-100">
3233
<Pressable
3334
onPress={() => setIsActive(!isActive)}
35+
style={bgColor.style}
3436
className={`p-4 rounded-lg ${isActive ? "bg-green-500" : "bg-red-500"}`}
3537
>
36-
<Text style={tw`text-${color}-500 font-bold text-center`}>{isActive ? "Active" : "Inactive"}</Text>
38+
<Text style={textColor.style} className="font-bold text-center">
39+
{isActive ? "Active" : "Inactive"}
40+
</Text>
3741
</Pressable>
3842
</View>
3943
);

0 commit comments

Comments
 (0)