Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add cursor pointer to view via stylesehet in react native

I am new to React Native, been looking for an answer in google but could not find one. How can I add a cursor pointer to my View element with a nested TouchableOpacity element? I tried to use as property in stylesheet create method but got error that cursor in not a valid style property. Thank's in advance for any info.

like image 670
Elivan K. Avatar asked Feb 18 '18 12:02

Elivan K.


People also ask

How do you add a pointer to CSS?

Apply the CSS property cursor:pointer; to the elements. (This is the default style when a cursor hovers over a button.) Apply the CSS property cursor:url(pointer. png); using a custom graphic for your pointer.

What is curser pointer in CSS?

The cursor property of CSS allows you to specify the type of cursor that should be displayed to the user. One good usage of this property is in using images for submit buttons on forms. By default, when a cursor hovers over a link, the cursor changes from a pointer to a hand.


3 Answers

The cursor is the mouse pointer, which is associated with the web browser and clicking links. Since React-Native is for mobile platforms, the typical situation is the user is tapping things with a finger, and so a 'cursor' or 'pointer' indicating the current mouse position is not necessary. The user just taps on the element.

I suggest using link styling, or button styling to indicate to the user that they can "click" specific text elements.

like image 112
ryan0 Avatar answered Oct 05 '22 04:10

ryan0


UPDATE

Web is now supported by react native, so just do

cursor: 'pointer'
like image 42
BloodyMonkey Avatar answered Oct 05 '22 04:10

BloodyMonkey


For those using typescript

<View style={{
      alignItems:'flex-end',
      //@ts-ignore
      cursor:'pointer'
  }} >{text}</View>
like image 39
Alex Totolici Avatar answered Oct 05 '22 04:10

Alex Totolici