Optimal Implementation of Gradient Button with Hover and Press States in Tamagui #3351
Unanswered
felpereira
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am developing a stylized button with a gradient using Tamagui and have encountered challenges related to handling hover and press states. Currently, I have wrapped the
LinearGradient
component with aPressable
to capture interaction events. I would like to know if this is the most appropriate approach or if there is a more efficient way to implement this functionality.Current Code:
Questions:
Is there a more efficient way to handle hover and press states when styling a button with a gradient in Tamagui? Currently, I am using local states (
useState
) along with the hooksuseMemo
anduseCallback
to manage the gradient colors based on user interactions. Is this the recommended approach, or is there a more optimized method to achieve this behavior?Is it necessary to wrap the
LinearGradient
component with aPressable
to ensure click events function correctly? I have observed that when removing thePressable
and attempting to use theLinearGradient
directly with aButton
component from Tamagui, click events are not triggered as expected. Is there a specific reason for this behavior? Is there a way to make theButton
work directly with theLinearGradient
without the need for an externalPressable
?Additional Context:
I appreciate any assistance and guidance the community can provide.
Beta Was this translation helpful? Give feedback.
All reactions