@codervigi/rn-shad-hooks
v0.1.0
Published
React hooks for rn-shad components - theme management and haptic feedback
Maintainers
Readme
@rn-shad/hooks
React hooks for rn-shad components - theme management and haptic feedback.
Installation
npm install @rn-shad/hooks @rn-shad/themesHooks
useTheme
Access and manage theme colors in your components.
import { ThemeProvider, useTheme } from '@rn-shad/hooks';
import { defaultTheme } from '@rn-shad/themes';
// Wrap your app with ThemeProvider
function App() {
return (
<ThemeProvider theme={defaultTheme}>
<YourApp />
</ThemeProvider>
);
}
// Use theme in components
function MyComponent() {
const { colors } = useTheme();
return (
<View style={{ backgroundColor: colors.background }}>
<Text style={{ color: colors.foreground }}>Hello</Text>
</View>
);
}useHaptic
Trigger haptic feedback on iOS and Android.
import { useHaptic } from '@rn-shad/hooks';
function MyButton() {
const haptic = useHaptic();
const handlePress = () => {
haptic.trigger('selection');
// Your logic here
};
return <Pressable onPress={handlePress}>...</Pressable>;
}Available feedback types:
selection- Light tap (iOS: selection, Android: clock tick)impactLight- Light impactimpactMedium- Medium impactimpactHeavy- Heavy impactsuccess- Success notificationwarning- Warning notificationerror- Error notification
License
MIT
