jaredh159 / tailwind-react-native-classnames

simple, expressive API for tailwindcss + react-native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to style pressed event of a pressable

Ali-Aref opened this issue · comments

This is my Pressable with the Stylesheet api

<Pressable
	style={({ pressed }) => [{ 
		opacity: pressed ? 0.5 : 1.0 }
	]}>
	<Text>SOme teXt</Text>
</Pressable>

how to style that using twrnc ? I want to change the background and border colors when the button is pressed.

this should work:

<Pressable
  style={({ pressed }) => [tw.style(pressed ? `bg-black` : `bg-white`)]}
>
  <Text>Press me</Text>
</Pressable>