All Projects β†’ react-native-toolkit β†’ React Native Responsive Dimensions

react-native-toolkit / React Native Responsive Dimensions

Licence: mit
Resposive fontSize, height and width for react-native components, that automatically adjusts itself based on screen-size of the device.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React Native Responsive Dimensions

Easygrid
EasyGrid - VanillaJS Responsive Grid
Stars: ✭ 77 (-68.31%)
Mutual labels:  responsive, responsive-design
Quasar Apexcharts
πŸ“Š πŸ“ˆ πŸ“‰ Project using Quasar framework and ApexCharts.
Stars: ✭ 94 (-61.32%)
Mutual labels:  hacktoberfest, responsive
Vue Responsive
A plugin for responsive handling with vue.js
Stars: ✭ 86 (-64.61%)
Mutual labels:  responsive, responsive-design
Textblock
Continuously responsive typesetting β€” Demo:
Stars: ✭ 536 (+120.58%)
Mutual labels:  responsive, responsive-design
Responsively App
A modified web browser that helps in responsive web development. A web developer's must have dev-tool.
Stars: ✭ 14,425 (+5836.21%)
Mutual labels:  hacktoberfest, responsive
Rocssti
RΓ–CSSTI : pour dΓ©marrer vos CSS avec la patate !
Stars: ✭ 46 (-81.07%)
Mutual labels:  responsive, responsive-design
Ts Website
A website for your TeamSpeak 3 server
Stars: ✭ 239 (-1.65%)
Mutual labels:  hacktoberfest, responsive-design
FlexBoxFX
FlexBoxFX is a JavaFX implementation of CSS3 flexbox.
Stars: ✭ 65 (-73.25%)
Mutual labels:  responsive, responsive-design
Paper Kit 2 Angular
Free Bootstrap 4 UI Kit for Angular 2+
Stars: ✭ 133 (-45.27%)
Mutual labels:  responsive, responsive-design
Container Query
A PostCSS plugin and Javascript runtime combination, which allows you to write container queries in your CSS the same way you would write media queries.
Stars: ✭ 119 (-51.03%)
Mutual labels:  responsive, responsive-design
Argon Dashboard
Argon - Dashboard for Bootstrap 4 by Creative Tim
Stars: ✭ 429 (+76.54%)
Mutual labels:  responsive, responsive-design
Hugo Theme M10c
A minimalistic (m10c) blog theme for Hugo
Stars: ✭ 223 (-8.23%)
Mutual labels:  hacktoberfest, responsive
React Native Responsive Grid
Bringing the Web's Responsive Design to React Native
Stars: ✭ 369 (+51.85%)
Mutual labels:  responsive, responsive-design
Flutterwebsite
The flutter.dev website recreated in Flutter. https://gallery.codelessly.com/flutterwebsites/flutterwebsite
Stars: ✭ 76 (-68.72%)
Mutual labels:  responsive, responsive-design
Layout
Flutter | Create responsive layouts for mobile, web and desktop
Stars: ✭ 312 (+28.4%)
Mutual labels:  responsive, responsive-design
Natural Gallery Js
A lazy load, infinite scroll and natural layout list gallery
Stars: ✭ 93 (-61.73%)
Mutual labels:  hacktoberfest, responsive
breaking-point
BREAKING-POINT lets you quickly define and subscribe to screen (i.e. window) breakpoints in your re-frame application
Stars: ✭ 36 (-85.19%)
Mutual labels:  responsive, responsive-design
science-fiction-magazines-blog
Blog template (concept) is inspired by stylish science fiction magazines of the 80-90s.
Stars: ✭ 24 (-90.12%)
Mutual labels:  responsive, responsive-design
React Most Wanted
React starter kit with "Most Wanted" application features
Stars: ✭ 1,867 (+668.31%)
Mutual labels:  hacktoberfest, responsive
Argon Design System
Argon - Design System for Bootstrap 4 by Creative Tim
Stars: ✭ 2,307 (+849.38%)
Mutual labels:  responsive, responsive-design

πŸ“πŸ“± React Native Responsive Dimensions πŸŒπŸ“

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! 😎

Build Status Maintainability Test Coverage

Version Downloads Bundlephobia

Star on GitHub Watch on GitHub Twitter Follow


Compatible with Expo & React Native Web πŸš€

PRs Welcome πŸ‘βœ¨

Installation

#npm
npm install --save react-native-responsive-dimensions

#yarn
yarn add react-native-responsive-dimensions

Usage

While working with mobile devices, there are two kinds of dimensions you will have to focus on

  • Window Dimensions οΉ£ which is the size of the window / view port on which your app is being displayed
  • Screen Dimensions οΉ£ this is the total screen dimensions of your device (your app may occupy the entire screen or only a portion of the screen)

Working with Window Dimensions

import { StyleSheet } from "react-native";
import {
  responsiveHeight,
  responsiveWidth,
  responsiveFontSize
} from "react-native-responsive-dimensions";

const styles = StyleSheet.create({
  container: {
    justifyContent: "center",
    height: responsiveHeight(50), // 50% of window height
    width: responsiveWidth(50), // 50% of window width
    alignItems: "center"
  },
  sampleText: {
    fontSize: responsiveFontSize(2) // 2% of total window size
  }
});

Working with Screen Dimensions

import { StyleSheet } from "react-native";
import {
  responsiveScreenHeight,
  responsiveScreenWidth,
  responsiveScreenFontSize
} from "react-native-responsive-dimensions";

const styles = StyleSheet.create({
  container: {
    justifyContent: "center",
    height: responsiveScreenHeight(50), // 50% of Screen height
    width: responsiveScreenWidth(50), // 50% of Screen width
    alignItems: "center"
  },
  sampleText: {
    fontSize: responsiveScreenFontSize(2) // 2% of total screen size
  }
});

Responsive hooks

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

Sample Usage

import React from "react";
import { View } from "react-native";
import {
  useResponsiveHeight,
  useResponsiveWidth
} from "react-native-responsive-dimensions";

const App = () => {
  const height = useResponsiveHeight(25);
  const width = useResponsiveWidth(25);

  return <View style={{ height, width }} />;
};

Reacting to dimension changes with 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.

import React, { useCallback } from "react";
import { View, LayoutAnimation } from "react-native";
import {
  useResponsiveHeight,
  useResponsiveWidth,
  useDimensionsChange
} from "react-native-responsive-dimensions";

const App = () => {
  const height = useResponsiveHeight(25);
  const width = useResponsiveWidth(25);

  useDimensionsChange(
    useCallback(({ window, screen }) => {
      LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
    }, [])
  );

  return <View style={{ height, width }} />;
};

Examples

Why Responsive Dimensions

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].