Gathering detailed insights and metrics for react-native-responsive-dimensions
Gathering detailed insights and metrics for react-native-responsive-dimensions
Gathering detailed insights and metrics for react-native-responsive-dimensions
Gathering detailed insights and metrics for react-native-responsive-dimensions
react-native-responsive-screen
Make React Native views responsive for all devices with the use of 2 simple methods.
react-cool-dimensions
React hook to measure an element's size and handle responsive components.
react-native-responsive-fontsize
Simple method for resposive fontSize based on screen-size of the device in React-Native
react-native-responsive-ui
Responsive UIs for React Native
npm install react-native-responsive-dimensions
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
477 Stars
50 Commits
39 Forks
9 Watching
18 Branches
3 Contributors
Updated on 22 Nov 2024
Minified
Minified + Gzipped
TypeScript (80.4%)
JavaScript (11.86%)
Shell (7.75%)
Cumulative downloads
Total Downloads
Last day
31.9%
15,488
Compared to previous day
Last week
44.7%
75,168
Compared to previous week
Last month
7.3%
238,920
Compared to previous month
Last year
160.5%
2,469,921
Compared to previous year
1
19
Responsive height, width and responsive fontSize for your react native components!
The dimensions auto adjust based on the window size (view port) or the screen size of the device 🙌🏽
Support for responsive dimension hooks to help auto-adjust dimensions for devices whose display or screen sizes may change such as foldable phones or browser windows! 😎
1#npm 2npm install --save react-native-responsive-dimensions 3 4#yarn 5yarn add react-native-responsive-dimensions
While working with mobile devices, there are two kinds of dimensions you will have to focus on
1import { StyleSheet } from "react-native"; 2import { 3 responsiveHeight, 4 responsiveWidth, 5 responsiveFontSize 6} from "react-native-responsive-dimensions"; 7 8const styles = StyleSheet.create({ 9 container: { 10 justifyContent: "center", 11 height: responsiveHeight(50), // 50% of window height 12 width: responsiveWidth(50), // 50% of window width 13 alignItems: "center" 14 }, 15 sampleText: { 16 fontSize: responsiveFontSize(2) // 2% of total window size 17 } 18});
1import { StyleSheet } from "react-native"; 2import { 3 responsiveScreenHeight, 4 responsiveScreenWidth, 5 responsiveScreenFontSize 6} from "react-native-responsive-dimensions"; 7 8const styles = StyleSheet.create({ 9 container: { 10 justifyContent: "center", 11 height: responsiveScreenHeight(50), // 50% of Screen height 12 width: responsiveScreenWidth(50), // 50% of Screen width 13 alignItems: "center" 14 }, 15 sampleText: { 16 fontSize: responsiveScreenFontSize(2) // 2% of total screen size 17 } 18});
The above responsive dimension methods do not auto update once the value is set. They are suitable for using within StyleSheet.create
method as the values don't change once set. However, you might want your views to respond to dimension changes such as screen rotation, device folding (in foldable devices) & browser window resizing (react-native-web).
The values set by these hooks auto respond to changes. The following hooks are available for use ﹣
useResponsiveHeight
useResponsiveWidth
useResponsiveFontSize
useResponsiveScreenHeight
useResponsiveScreenWidth
useResponsiveScreenFontSize
useDimensionsChange
1import React from "react"; 2import { View } from "react-native"; 3import { 4 useResponsiveHeight, 5 useResponsiveWidth 6} from "react-native-responsive-dimensions"; 7 8const App = () => { 9 const height = useResponsiveHeight(25); 10 const width = useResponsiveWidth(25); 11 12 return <View style={{ height, width }} />; 13};
useDimensionsChange
useDimensionsChange
basically calls a function whenever the dimensions update with new window & screen dimensions as arguments. This is a good place to include your layout animations if your UI layout reacts to dimension updates and you want to make the transitions smooth.
1import React, { useCallback } from "react"; 2import { View, LayoutAnimation } from "react-native"; 3import { 4 useResponsiveHeight, 5 useResponsiveWidth, 6 useDimensionsChange 7} from "react-native-responsive-dimensions"; 8 9const App = () => { 10 const height = useResponsiveHeight(25); 11 const width = useResponsiveWidth(25); 12 13 useDimensionsChange( 14 useCallback(({ window, screen }) => { 15 LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); 16 }, []) 17 ); 18 19 return <View style={{ height, width }} />; 20};
I built responsive dimensions as a personal tool to tackle some of my problems I face during my everyday app development. You might want to use it if your usecase comes under one of the following scenarios.
While working with React Native UI (especially animations) there are lots of scenarios that require calculating a certain percentage of the display area.
If your app supports tablets then you might want to scale some of your fonts & UI Components based on the display size.
If you are using react-native-web or targetting foldable devices your UI needs to react to the changes in the window dimensions.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is archived
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
63 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More