react-native-web-hover
Advanced tools
Comparing version
{ | ||
"name": "react-native-web-hover", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Some enhanced elements for react-native-web to support hover on the web", | ||
@@ -5,0 +5,0 @@ "main": "lib/commonjs/index", |
@@ -21,7 +21,44 @@ # react-native-web-hover | ||
## Usage | ||
We recommend the "Pressable" component. You can see all the examples here: | ||
``` | ||
import { Hoverable, Pressable, } from 'react-native-web-hover' | ||
// The Pressable, you can still provide normal styles or children without functions! | ||
<Pressable | ||
style={({ hovered, focused, pressed }) => [ | ||
styles.buttonRoot, | ||
hovered && styles.buttonHovered, | ||
focused && styles.buttonFocused, | ||
pressed && styles.buttonPressed | ||
]} | ||
> | ||
{({ hovered, focused, pressed }) => ( | ||
<View style={styles.buttonInner}> | ||
<Text style={styles.buttonLabel}> | ||
{label} | ||
</Text> | ||
</View> | ||
)} | ||
</Pressable> | ||
// The Hoverable | ||
<Hoverable> | ||
{({ hovered }) => ( | ||
<Button | ||
title="legacy button" | ||
onPress={() => {}} | ||
color={hovered ? "black" : "grey"} | ||
/> | ||
)} | ||
</Hoverable> | ||
``` | ||
We recommend the "Pressable" component. You can see examples here: | ||
https://codesandbox.io/s/young-surf-bbmzz?file=/src/App.tsx | ||
If you want to update the hover inside FlatList, ScrollViews or VirtualizedList when the user scrolls, don't forget to import these views from this library. | ||
### Nested Scrollables | ||
If you want to update the hover inside **NESTED** FlatList, ScrollViews or VirtualizedList when the user scrolls, don't forget to import these views from this library. | ||
import { Hoverable, Pressable, ScrollView, FlatList, VirtualizedList } from 'react-native-web-hover' | ||
@@ -28,0 +65,0 @@ |
58158
1.51%72
105.71%