react-native-dynamic-responsive 1.0.0 β†’ 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,44 +1,133 @@
1
- # react-native-dynamic-responsive
1
+ # πŸ“± react-native-dynamic-responsive
2
2
 
3
- The **best responsive package** for React Native! A **super lightweight**, production-ready responsive styling library built for the modern era of mobile apps.
3
+ ### Dynamic, Lightweight & TypeScript-First Responsive UI for React Native
4
4
 
5
- Whether you are using **Expo** or **React Native CLI**, this package works seamlessly out of the box to handle dynamic orientation changes, foldable devices (inner/outer screen swapping), and tablets seamlesslyβ€”all without breaking a sweat!
5
+ Build React Native interfaces that adapt naturally to **different screen sizes, orientations, tablets, foldable devices, and dynamic window dimensions**.
6
6
 
7
- If you are looking for the ultimate `react-native-size-matters` alternative that fully supports dynamic screen sizes and hooks, you've found it.
7
+ `react-native-dynamic-responsive` provides a simple, familiar API for responsive scaling while giving modern React Native applications a **dynamic, hook-based styling approach**.
8
8
 
9
- ## 🌟 Features
10
- - **Universal Compatibility**: 100% compatible with both **Expo** (managed & bare workflows) and **React Native CLI**.
11
- - **Ultra Lightweight**: Zero dependencies (only peer dependencies on React & React Native).
12
- - **Dynamic & Reactive**: Styles instantly recalculate when screen dimensions change (e.g., when a user unfolds a device or rotates their screen).
13
- - **Familiar API**: Uses industry-standard scaling terminology (`ms`, `s`, `vs`) inspired by `react-native-size-matters`.
14
- - **Hooks-First Architecture**: Built for modern React Native apps using a `useStyles` pattern to avoid stale `StyleSheet.create` evaluations.
9
+ Built for:
10
+
11
+ - πŸ“± Phones
12
+ - πŸ“² Tablets
13
+ - πŸ“– Foldable devices
14
+ - ↔️ Portrait & landscape
15
+ - βš›οΈ React Native CLI
16
+ - πŸš€ Expo
17
+ - πŸ”· TypeScript
18
+
19
+ **Zero runtime dependencies. No native configuration required.**
20
+
21
+ ## πŸ“± Responsive UI Across Devices
22
+
23
+ Build once and adapt your interface across phones, landscape layouts, tablets, and foldable devices.
24
+
25
+ <p align="center">
26
+ <img
27
+ src="https://gitlab.com/code_dharmendra/react-native-dynamic-responsive/-/raw/main/assets/responsive-preview.png"
28
+ alt="react-native-dynamic-responsive showing responsive UI across phone, landscape, tablet and foldable layouts"
29
+ width="100%"
30
+ />
31
+ </p>
32
+
33
+ <p align="center">
34
+ <strong>Phone</strong> Β· <strong>Landscape</strong> Β· <strong>Tablet</strong> Β· <strong>Foldable</strong>
35
+ </p>
36
+
37
+ ---
38
+
39
+ ## ✨ Why react-native-dynamic-responsive?
40
+
41
+ Traditional responsive utilities are often designed around a fixed screen size.
42
+
43
+ Modern devices are different.
44
+
45
+ A React Native application can experience:
46
+
47
+ ```
48
+ Phone
49
+ ↓
50
+ Rotation
51
+ ↓
52
+ Landscape
53
+ ↓
54
+ Split Screen
55
+ ↓
56
+ Tablet
57
+ ↓
58
+ Foldable
59
+ ↓
60
+ Inner / Outer Display
61
+
62
+ ```
63
+
64
+ The available screen dimensions can change while your application is running.
65
+
66
+ `react-native-dynamic-responsive` is designed around this reality.
67
+
68
+ ### The goal
69
+
70
+ > **Write responsive styles once and let the layout adapt to the current screen dimensions.**
71
+
72
+ ```
73
+ const styles = useStyles((r) => ({
74
+ container: {
75
+ width: r.isTablet ? r.wp(70) : r.wp(90),
76
+ padding: r.ms(16),
77
+ },
78
+
79
+ title: {
80
+ fontSize: r.ms(24),
81
+ },
82
+ }));
83
+
84
+ ```
15
85
 
16
86
  ---
17
87
 
18
- ## πŸš€ Installation
88
+ # πŸš€ Installation
19
89
 
20
- ```bash
90
+ ```
21
91
  npm install react-native-dynamic-responsive
22
- # or
92
+
93
+ ```
94
+
95
+ or:
96
+
97
+ ```
23
98
  yarn add react-native-dynamic-responsive
99
+
24
100
  ```
25
101
 
102
+ ### No native setup
103
+
104
+ The library is designed to work without additional native configuration.
105
+
106
+ You can use it directly in:
107
+
108
+ - Expo
109
+ - Expo Router
110
+ - React Native CLI
111
+
26
112
  ---
27
113
 
28
- ## πŸ“– Quick Start
114
+ # ⚑ Quick Start
29
115
 
30
- The best way to use this package is via the `useStyles` hook. This ensures your styles re-render instantly on fold/unfold or screen rotation.
116
+ The recommended API is `useStyles()`.
31
117
 
32
- ```tsx
118
+ ```
33
119
  import React from 'react';
34
120
  import { View, Text } from 'react-native';
35
- import { useStyles, useResponsive, ResponsiveUtils } from 'react-native-dynamic-responsive';
121
+
122
+ import {
123
+ useStyles,
124
+ useResponsive,
125
+ ResponsiveUtils,
126
+ } from 'react-native-dynamic-responsive';
36
127
 
37
128
  export const MyComponent = () => {
38
- // Optional: Pull device status if you need logic inside your component
39
129
  const { isTablet, isFold } = useResponsive();
40
-
41
- // 1. Pass the createStyles function to the hook
130
+
42
131
  const styles = useStyles(createStyles);
43
132
 
44
133
  return (
@@ -46,90 +135,1204 @@ export const MyComponent = () => {
46
135
  <Text style={styles.title}>
47
136
  {isTablet ? 'Tablet View' : 'Phone View'}
48
137
  </Text>
138
+
139
+ <Text>
140
+ {isFold ? 'Foldable Device' : 'Standard Device'}
141
+ </Text>
49
142
  </View>
50
143
  );
51
144
  };
52
145
 
53
- // 2. Define your styles outside the component to keep things clean.
54
- // The `r` parameter (ResponsiveUtils) gives you access to real-time scaling functions!
55
146
  const createStyles = (r: ResponsiveUtils) => ({
56
147
  container: {
57
- // scale (s): Standard scaling based on width
58
- padding: r.s(16),
59
-
60
- // moderateScale (ms): Smart scaling that prevents things from getting too big on tablets
61
- marginTop: r.ms(20),
62
-
63
- // width/height percentages (wp/hp)
64
- width: r.isTablet ? r.wp(50) : r.wp(100),
65
-
66
- backgroundColor: '#fff',
148
+ width: r.isTablet ? r.wp(70) : r.wp(90),
149
+ padding: r.ms(16),
67
150
  },
151
+
68
152
  title: {
69
- // Use ms() for typography!
70
153
  fontSize: r.ms(24),
71
- fontWeight: 'bold',
72
- }
154
+ fontWeight: '700',
155
+ },
73
156
  });
157
+
74
158
  ```
75
159
 
76
160
  ---
77
161
 
78
- ## πŸ›  Advanced Usage
162
+ # 🧠 How It Works
79
163
 
80
- ### Available Scaling Functions
164
+ The library provides a responsive utility object containing scaling functions and device information.
81
165
 
82
- When using `useStyles((r) => { ... })` or `const r = useResponsive()`, you have access to the following utilities on the `r` object:
166
+ Instead of calculating screen dimensions manually inside every component:
83
167
 
84
- | Function | Description | Best Used For |
85
- | :--- | :--- | :--- |
86
- | **`r.ms(size, factor?)`** | Moderate Scale. Scales based on width but less aggressively. | **Typography, icons, padding/margins** |
87
- | **`r.s(size)`** | Standard Scale. Scales directly proportional to screen width. | Widths, horizontal spacing |
88
- | **`r.vs(size)`** | Vertical Scale. Scales directly proportional to screen height. | Heights, vertical spacing |
89
- | **`r.wp(percent)`** | Width Percentage. e.g., `r.wp(50)` = 50% of screen width | Containers, Modals |
90
- | **`r.hp(percent)`** | Height Percentage. e.g., `r.hp(50)` = 50% of screen height | Containers, Modals |
168
+ ```
169
+ Dimensions.get('window')
91
170
 
92
- ### Available Device Flags
171
+ ```
93
172
 
94
- You can easily trigger different UI logic without importing `Platform` or `Dimensions` manually:
173
+ you can use:
95
174
 
96
- - `r.isTablet` (Width >= 768)
97
- - `r.isFold` (Width >= 600 & < 768)
98
- - `r.isPhone` (Width < 600)
99
- - `r.isSmallPhone` (Width <= 360)
100
- - `r.isLandscape` (Width > Height)
175
+ ```
176
+ const styles = useStyles((r) => ({
177
+ card: {
178
+ width: r.wp(90),
179
+ padding: r.ms(16),
180
+ },
181
+ }));
101
182
 
102
- ### Legacy / Static Usage (Not Recommended for Foldables)
183
+ ```
103
184
 
104
- If you have an older codebase and need to use the scaling utilities inside standard, static `StyleSheet.create`, you can still import them directly.
185
+ The responsive style function receives the current responsive context.
105
186
 
106
- *Note: These will evaluate only once when the file loads, so they will not update dynamically if a foldable device unfolds.*
187
+ When the relevant screen dimensions change, the hook can recalculate the responsive styles for the component.
107
188
 
108
- ```tsx
109
- import { StyleSheet, View } from 'react-native';
110
- import { ms, s, vs } from 'react-native-dynamic-responsive';
189
+ This makes the API particularly useful for:
111
190
 
112
- const StaticComponent = () => <View style={styles.box} />;
191
+ - orientation changes
192
+ - fold/unfold transitions
193
+ - tablet layouts
194
+ - dynamic window sizes
195
+ - split-screen layouts
113
196
 
114
- const styles = StyleSheet.create({
115
- box: {
116
- width: s(100),
117
- height: vs(100),
118
- padding: ms(10),
119
- }
197
+ ---
198
+
199
+ # ⚑ Performance
200
+
201
+ Performance is a first-class consideration.
202
+
203
+ `react-native-dynamic-responsive` is designed to remain lightweight while providing dynamic responsive behavior.
204
+
205
+ ## πŸͺΆ Zero Runtime Dependencies
206
+
207
+ The package has:
208
+
209
+ ```
210
+ 0 Runtime Dependencies
211
+
212
+ ```
213
+
214
+ React and React Native are used as peer dependencies.
215
+
216
+ This helps keep the dependency tree small and avoids introducing additional runtime libraries into your application.
217
+
218
+ ---
219
+
220
+ ## 🧩 No Native Module Setup
221
+
222
+ The responsive logic is designed to work from the React Native layer.
223
+
224
+ You don't need to install an additional native module just to perform responsive scaling.
225
+
226
+ That means:
227
+
228
+ ```
229
+ npm install
230
+ ↓
231
+ Import package
232
+ ↓
233
+ Use responsive utilities
234
+
235
+ ```
236
+
237
+ No additional native linking workflow is required.
238
+
239
+ ---
240
+
241
+ ## πŸ”„ Dynamic Updates Only When Dimensions Matter
242
+
243
+ Responsive styles are useful because screen dimensions can change.
244
+
245
+ Examples:
246
+
247
+ ```
248
+ Portrait
249
+ ↓
250
+ Landscape
251
+
252
+ Folded
253
+ ↓
254
+ Unfolded
255
+
256
+ Outer Screen
257
+ ↓
258
+ Inner Screen
259
+
260
+ Full Screen
261
+ ↓
262
+ Split Screen
263
+
264
+ ```
265
+
266
+ The recommended `useStyles()` API is intended for these dynamic scenarios.
267
+
268
+ For applications where dimensions never need to change dynamically, static utility functions are also available.
269
+
270
+ ---
271
+
272
+ ## ⚠️ Performance Best Practices
273
+
274
+ For the best performance:
275
+
276
+ ### βœ… Keep style factories outside components
277
+
278
+ Recommended:
279
+
280
+ ```
281
+ const createStyles = (r: ResponsiveUtils) => ({
282
+ container: {
283
+ padding: r.ms(16),
284
+ },
120
285
  });
286
+
287
+ const MyComponent = () => {
288
+ const styles = useStyles(createStyles);
289
+
290
+ return <View style={styles.container} />;
291
+ };
292
+
293
+ ```
294
+
295
+ Avoid recreating the complete style factory unnecessarily inside the component.
296
+
297
+ ---
298
+
299
+ ### βœ… Use `useStyles()` for dynamic layouts
300
+
301
+ If your UI needs to react to:
302
+
303
+ - rotation
304
+ - fold/unfold
305
+ - window resizing
306
+
307
+ use:
308
+
309
+ ```
310
+ useStyles()
311
+
312
+ ```
313
+
314
+ ---
315
+
316
+ ### βœ… Use static utilities when dynamic behavior isn't required
317
+
318
+ For fixed/static styling:
319
+
320
+ ```
321
+ import { ms, s, vs } from 'react-native-dynamic-responsive';
322
+
323
+ ```
324
+
325
+ This can be useful for existing applications that don't need dynamic screen updates.
326
+
327
+ ---
328
+
329
+ ## πŸ“¦ Bundle & Dependency Philosophy
330
+
331
+ The library follows a simple philosophy:
332
+
333
+ ```
334
+ Small API
335
+ +
336
+ Zero runtime dependencies
337
+ +
338
+ React Native primitives
339
+ +
340
+ TypeScript
341
+ =
342
+ Low complexity
343
+
344
+ ```
345
+
346
+ There are no unnecessary UI components, animation systems, state managers, or styling frameworks bundled into the package.
347
+
348
+ The library focuses specifically on responsive calculations and responsive style handling.
349
+
350
+ ---
351
+
352
+ # 🌟 Features
353
+
354
+ ### πŸ“± Responsive Scaling
355
+
356
+ Scale dimensions according to the current screen size.
357
+
358
+ ### πŸ“ Width & Height Percentages
359
+
360
+ Create layouts using percentage-based dimensions.
361
+
362
+ ### πŸ”„ Dynamic Screen Updates
363
+
364
+ React to changes in screen dimensions.
365
+
366
+ ### πŸ“– Foldable Support
367
+
368
+ Useful for devices where the available display area changes between folded and unfolded states.
369
+
370
+ ### πŸ“² Tablet Detection
371
+
372
+ Easily adapt layouts for larger screens.
373
+
374
+ ### ↔️ Orientation Detection
375
+
376
+ Detect portrait and landscape layouts.
377
+
378
+ ### βš›οΈ Hooks-First API
379
+
380
+ Modern React API using:
381
+
382
+ ```
383
+ useStyles()
384
+ useResponsive()
385
+
386
+ ```
387
+
388
+ ### πŸ”· TypeScript
389
+
390
+ Type-friendly responsive utilities.
391
+
392
+ ### πŸš€ Expo Compatible
393
+
394
+ Works with Expo applications.
395
+
396
+ ### βš›οΈ React Native CLI Compatible
397
+
398
+ Works with standard React Native CLI applications.
399
+
400
+ ### πŸͺΆ Lightweight
401
+
402
+ Zero runtime dependencies.
403
+
404
+ ---
405
+
406
+ # πŸ“ Responsive Utilities
407
+
408
+ The responsive utility object provides familiar scaling functions.
409
+
410
+ ```
411
+ const styles = useStyles((r) => ({
412
+ container: {
413
+ width: r.wp(90),
414
+ height: r.hp(40),
415
+ padding: r.s(16),
416
+ marginTop: r.vs(20),
417
+ },
418
+
419
+ title: {
420
+ fontSize: r.ms(24),
421
+ },
422
+ }));
423
+
424
+ ```
425
+
426
+ ---
427
+
428
+ ## Available Functions
429
+
430
+ | Function | Description | Example |
431
+ | --------------------- | --------------------------- | ---------- |
432
+ | `r.s(size)` | Standard horizontal scaling | `r.s(16)` |
433
+ | `r.ms(size, factor?)` | Moderate scaling | `r.ms(24)` |
434
+ | `r.vs(size)` | Vertical scaling | `r.vs(20)` |
435
+ | `r.wp(percent)` | Percentage of screen width | `r.wp(90)` |
436
+ | `r.hp(percent)` | Percentage of screen height | `r.hp(50)` |
437
+
438
+ ---
439
+
440
+ # πŸ“± Device Detection
441
+
442
+ Use `useResponsive()` when your UI needs device-specific behavior.
443
+
444
+ ```
445
+ const r = useResponsive();
446
+
447
+ ```
448
+
449
+ You can then access:
450
+
451
+ ```
452
+ r.isPhone
453
+ r.isTablet
454
+ r.isFold
455
+ r.isSmallPhone
456
+ r.isLandscape
457
+
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Device Flags
463
+
464
+ | Flag | Condition |
465
+ | -------------- | --------------------- |
466
+ | `isPhone` | Width < 600 |
467
+ | `isFold` | Width β‰₯ 600 and < 768 |
468
+ | `isTablet` | Width β‰₯ 768 |
469
+ | `isSmallPhone` | Width ≀ 360 |
470
+ | `isLandscape` | Width > Height |
471
+
472
+ > These thresholds are intended as practical defaults. They should not be treated as a universal hardware classification standard.
473
+
474
+ ---
475
+
476
+ # πŸ”„ Orientation
477
+
478
+ You can easily create different layouts for portrait and landscape.
479
+
480
+ ```
481
+ const styles = useStyles((r) => ({
482
+ container: {
483
+ width: r.isLandscape
484
+ ? r.wp(70)
485
+ : r.wp(90),
486
+ },
487
+ }));
488
+
489
+ ```
490
+
491
+ Example:
492
+
493
+ ```
494
+ PORTRAIT
495
+
496
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
497
+ β”‚ β”‚
498
+ β”‚ Content β”‚
499
+ β”‚ β”‚
500
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
501
+
502
+
503
+ ↓ ROTATE
504
+
505
+
506
+ LANDSCAPE
507
+
508
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
509
+ β”‚ Content β”‚
510
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
511
+
121
512
  ```
122
513
 
123
514
  ---
124
515
 
125
- ## πŸ‘€ Author
516
+ # πŸ“– Foldable Devices
517
+
518
+ Foldable devices introduce an additional responsive challenge.
519
+
520
+ The available display area can change significantly between:
521
+
522
+ ```
523
+ Folded
524
+ ↓
525
+ Outer Display
526
+
527
+ Unfolded
528
+ ↓
529
+ Inner Display
530
+
531
+ ```
532
+
533
+ A responsive layout should not assume that the original screen dimensions remain constant.
534
+
535
+ Using:
536
+
537
+ ```
538
+ const styles = useStyles((r) => ({
539
+ container: {
540
+ width: r.isFold
541
+ ? r.wp(90)
542
+ : r.wp(70),
543
+ },
544
+ }));
545
+
546
+ ```
126
547
 
127
- **Dharmendra**
128
- App Developer
129
- [LinkedIn Profile](https://www.linkedin.com/in/dharmendra-appdeveloper)
548
+ your component can adapt its layout according to the current responsive state.
130
549
 
131
550
  ---
132
551
 
133
- ## πŸ“ License
552
+ # πŸ“² Tablet Layouts
553
+
554
+ Tablet layouts often require different proportions from phone layouts.
555
+
556
+ Instead of maintaining completely separate styles:
557
+
558
+ ```
559
+ const styles = useStyles((r) => ({
560
+ container: {
561
+ width: r.isTablet
562
+ ? r.wp(70)
563
+ : r.wp(92),
564
+
565
+ padding: r.isTablet
566
+ ? r.ms(24)
567
+ : r.ms(16),
568
+ },
569
+ }));
570
+
571
+ ```
572
+
573
+ This keeps the responsive logic close to the styles that use it.
574
+
575
+ ---
576
+
577
+ # 🎨 Responsive Typography
578
+
579
+ Responsive scaling can also be used for typography.
580
+
581
+ ```
582
+ const styles = useStyles((r) => ({
583
+ heading: {
584
+ fontSize: r.ms(28),
585
+ lineHeight: r.ms(34),
586
+ },
587
+
588
+ body: {
589
+ fontSize: r.ms(16),
590
+ lineHeight: r.ms(24),
591
+ },
592
+ }));
593
+
594
+ ```
595
+
596
+ Use moderate scaling where aggressive scaling could make typography or spacing unnecessarily large on bigger screens.
597
+
598
+ ---
599
+
600
+ # 🧩 `useStyles()`
601
+
602
+ `useStyles()` is the recommended API for dynamic responsive styles.
603
+
604
+ ```
605
+ const styles = useStyles((r) => ({
606
+ container: {
607
+ padding: r.ms(16),
608
+ width: r.wp(90),
609
+ },
610
+
611
+ title: {
612
+ fontSize: r.ms(24),
613
+ },
614
+ }));
615
+
616
+ ```
617
+
618
+ ### Why use it?
619
+
620
+ It keeps responsive calculations together with the style definition while allowing the styles to respond to the current responsive state.
621
+
622
+ ---
623
+
624
+ # πŸ” `useResponsive()`
625
+
626
+ Use `useResponsive()` when you need responsive information directly inside your component.
627
+
628
+ ```
629
+ const {
630
+ isPhone,
631
+ isTablet,
632
+ isFold,
633
+ isSmallPhone,
634
+ isLandscape,
635
+ } = useResponsive();
636
+
637
+ ```
638
+
639
+ Example:
640
+
641
+ ```
642
+ return (
643
+ <View>
644
+ {isTablet ? (
645
+ <TabletNavigation />
646
+ ) : (
647
+ <MobileNavigation />
648
+ )}
649
+ </View>
650
+ );
651
+
652
+ ```
653
+
654
+ ---
655
+
656
+ # πŸ› οΈ ResponsiveUtils
657
+
658
+ The style factory receives a `ResponsiveUtils` object.
659
+
660
+ ```
661
+ const createStyles = (r: ResponsiveUtils) => ({
662
+ container: {
663
+ width: r.wp(90),
664
+ padding: r.ms(16),
665
+ },
666
+ });
667
+
668
+ ```
669
+
670
+ This gives you access to the responsive scaling utilities and device state from one place.
671
+
672
+ ---
673
+
674
+ # πŸ†š Dynamic vs Static Usage
675
+
676
+ ## Dynamic usage
677
+
678
+ Recommended when dimensions can change:
679
+
680
+ ```
681
+ const styles = useStyles((r) => ({
682
+ container: {
683
+ width: r.wp(90),
684
+ padding: r.ms(16),
685
+ },
686
+ }));
687
+
688
+ ```
689
+
690
+ Use this for:
691
+
692
+ - foldables
693
+ - orientation changes
694
+ - tablets
695
+ - split-screen
696
+ - dynamic window dimensions
697
+
698
+ ---
699
+
700
+ ## Static usage
701
+
702
+ Useful for existing codebases or styles that don't need to react to dimension changes.
703
+
704
+ ```
705
+ import { StyleSheet } from 'react-native';
706
+ import {
707
+ ms,
708
+ s,
709
+ vs,
710
+ } from 'react-native-dynamic-responsive';
711
+
712
+ const styles = StyleSheet.create({
713
+ box: {
714
+ width: s(100),
715
+ height: vs(100),
716
+ padding: ms(10),
717
+ },
718
+ });
719
+
720
+ ```
721
+
722
+ ### Important
723
+
724
+ Static utilities are evaluated as normal JavaScript values when your styles are created.
725
+
726
+ If your application needs to respond to changing screen dimensions, prefer:
727
+
728
+ ```
729
+ useStyles()
730
+
731
+ ```
732
+
733
+ ---
734
+
735
+ # πŸ›οΈ Real-World Use Cases
736
+
737
+ ## E-commerce
738
+
739
+ Responsive:
740
+
741
+ - product grids
742
+ - product cards
743
+ - filters
744
+ - banners
745
+ - checkout screens
746
+
747
+ ## Dashboards
748
+
749
+ Adapt layouts between:
750
+
751
+ ```
752
+ Phone β†’ Tablet β†’ Large Screen
753
+
754
+ ```
755
+
756
+ ## Social Applications
757
+
758
+ Responsive:
759
+
760
+ - feeds
761
+ - profile layouts
762
+ - media cards
763
+ - navigation
764
+
765
+ ## Enterprise Applications
766
+
767
+ Support different company devices without maintaining completely separate layouts.
768
+
769
+ ## Foldable Applications
770
+
771
+ Adapt the UI when available display dimensions change.
772
+
773
+ ## Design Systems
774
+
775
+ Create reusable responsive spacing and typography rules across an application.
776
+
777
+ ---
778
+
779
+ # πŸ” Security & Dependencies
780
+
781
+ The package is intentionally lightweight.
782
+
783
+ ### Runtime dependencies
784
+
785
+ ```
786
+ 0
787
+
788
+ ```
789
+
790
+ ### Peer dependencies
791
+
792
+ ```
793
+ React
794
+ React Native
795
+
796
+ ```
797
+
798
+ The package does not require additional runtime libraries for responsive calculations.
799
+
800
+ For security-sensitive production environments, always review the exact package version and dependency tree used by your application.
801
+
802
+ ---
803
+
804
+ # πŸ§ͺ Testing & Production Readiness
805
+
806
+ Responsive behavior should be tested on more than one screen size.
807
+
808
+ Recommended testing matrix:
809
+
810
+ | Device Type | Portrait | Landscape |
811
+ | -------------- | -------- | --------- |
812
+ | Small Phone | βœ… | βœ… |
813
+ | Standard Phone | βœ… | βœ… |
814
+ | Large Phone | βœ… | βœ… |
815
+ | Tablet | βœ… | βœ… |
816
+ | Foldable | βœ… | βœ… |
817
+
818
+ Also test:
819
+
820
+ - screen rotation
821
+ - split-screen mode where supported
822
+ - navigation transitions
823
+ - modal layouts
824
+ - keyboard interaction
825
+ - safe-area handling
826
+ - very small and very large content
827
+ - text scaling/accessibility settings
828
+
829
+ > Responsive scaling solves dimension-related layout problems. It does not replace good accessibility, safe-area handling, content wrapping, or platform-specific UI testing.
830
+
831
+ ---
832
+
833
+ # ⚠️ What This Library Does NOT Do
834
+
835
+ `react-native-dynamic-responsive` is focused on responsive calculations and responsive style handling.
836
+
837
+ It does **not** attempt to replace:
838
+
839
+ - React Native `SafeAreaView`
840
+ - accessibility APIs
841
+ - navigation libraries
842
+ - animation libraries
843
+ - design systems
844
+ - state management
845
+ - device-specific business logic
846
+
847
+ Use the right tool for each responsibility.
848
+
849
+ ---
850
+
851
+ # πŸ’‘ When Should I Use This?
852
+
853
+ Use this package when your application needs:
854
+
855
+ ```
856
+ Different screen sizes
857
+ +
858
+ Dynamic dimensions
859
+ +
860
+ Responsive spacing
861
+ +
862
+ Responsive typography
863
+ +
864
+ Tablet layouts
865
+ +
866
+ Orientation handling
867
+ +
868
+ Foldable support
869
+
870
+ ```
871
+
872
+ It is especially useful when you want a simple responsive API without introducing a large styling framework.
873
+
874
+ ---
875
+
876
+ # πŸ€” Frequently Asked Questions
877
+
878
+ ## Does it work with Expo?
879
+
880
+ Yes.
881
+
882
+ The package is designed to work with Expo projects.
883
+
884
+ ---
885
+
886
+ ## Does it work with Expo Router?
887
+
888
+ Yes.
889
+
890
+ Expo Router is built on top of React Native navigation patterns, so the responsive utilities can be used inside your screens and components normally.
891
+
892
+ ---
893
+
894
+ ## Does it work with React Native CLI?
895
+
896
+ Yes.
897
+
898
+ No separate React Native CLI-specific implementation is required for normal usage.
899
+
900
+ ---
901
+
902
+ ## Does it require native configuration?
903
+
904
+ The package is designed to be used without additional native configuration.
905
+
906
+ Install it and import the utilities directly.
907
+
908
+ ---
909
+
910
+ ## Does it support TypeScript?
911
+
912
+ Yes.
913
+
914
+ The package is written for a TypeScript-friendly development experience.
915
+
916
+ ---
917
+
918
+ ## Does it support tablets?
919
+
920
+ Yes.
921
+
922
+ You can use:
923
+
924
+ ```
925
+ r.isTablet
926
+
927
+ ```
928
+
929
+ and responsive width/height utilities to create tablet-specific layouts.
930
+
931
+ ---
932
+
933
+ ## Does it support foldable devices?
934
+
935
+ The responsive APIs are designed to respond to changing screen dimensions, making them suitable for foldable layouts.
936
+
937
+ You can also use:
938
+
939
+ ```
940
+ r.isFold
941
+
942
+ ```
943
+
944
+ for the package's configured fold-device classification.
945
+
946
+ ---
947
+
948
+ ## Does it automatically make my entire application responsive?
949
+
950
+ No.
951
+
952
+ The library provides the tools.
953
+
954
+ Your application still needs responsive layout decisions.
955
+
956
+ For example:
957
+
958
+ ```
959
+ r.isTablet
960
+ ? tabletLayout
961
+ : mobileLayout
962
+
963
+ ```
964
+
965
+ The package handles the responsive calculations; your UI determines how those calculations should be used.
966
+
967
+ ---
968
+
969
+ ## Is it a replacement for Flexbox?
970
+
971
+ No.
972
+
973
+ React Native Flexbox remains the primary layout system.
974
+
975
+ This library complements Flexbox by providing responsive dimensions, scaling and device information.
976
+
977
+ ---
978
+
979
+ ## Is it a replacement for `Dimensions`?
980
+
981
+ Not completely.
982
+
983
+ You can still use React Native's APIs when you need low-level device/window information.
984
+
985
+ This library provides a more convenient responsive styling layer on top of those concepts.
986
+
987
+ ---
988
+
989
+ ## Does it work with `StyleSheet.create()`?
990
+
991
+ Yes, through the static utilities:
992
+
993
+ ```
994
+ ms()
995
+ s()
996
+ vs()
997
+
998
+ ```
999
+
1000
+ However, if your layout needs to react to changing dimensions, use:
1001
+
1002
+ ```
1003
+ useStyles()
1004
+
1005
+ ```
1006
+
1007
+ ---
1008
+
1009
+ ## Does it work with React Native Web?
1010
+
1011
+ The core API is designed around React Native responsive behavior.
1012
+
1013
+ If React Native Web compatibility is important for your application, test the specific APIs you use against your target web environment before relying on device-specific flags.
1014
+
1015
+ ---
1016
+
1017
+ ## Will it make my app slower?
1018
+
1019
+ The library is designed to be lightweight and has zero runtime dependencies.
1020
+
1021
+ Dynamic responsive behavior necessarily involves responding to dimension changes. The recommended approach is to use `useStyles()` for components that actually need dynamic responsive behavior rather than unnecessarily applying responsive hooks everywhere.
1022
+
1023
+ ---
1024
+
1025
+ ## Does it use a state management library?
1026
+
1027
+ No.
1028
+
1029
+ It does not require Redux, Zustand, MobX, Recoil or another state management library.
1030
+
1031
+ ---
1032
+
1033
+ ## Does it require Reanimated?
1034
+
1035
+ No.
1036
+
1037
+ Responsive scaling and dimension handling do not require React Native Reanimated.
1038
+
1039
+ ---
1040
+
1041
+ ## Does it provide UI components?
1042
+
1043
+ No.
1044
+
1045
+ This package focuses on responsive utilities and styling rather than providing buttons, cards, modals or other UI components.
1046
+
1047
+ ---
1048
+
1049
+ ## Can I use it with my existing design system?
1050
+
1051
+ Yes.
1052
+
1053
+ The scaling utilities can be used inside your existing component and design-system architecture.
1054
+
1055
+ For example:
1056
+
1057
+ ```
1058
+ const spacing = r.ms(16);
1059
+ const radius = r.ms(12);
1060
+ const titleSize = r.ms(24);
1061
+
1062
+ ```
1063
+
1064
+ ---
1065
+
1066
+ # πŸ”„ Migration From `react-native-size-matters`
1067
+
1068
+ If your application already uses concepts such as:
1069
+
1070
+ ```
1071
+ ms()
1072
+ s()
1073
+ vs()
1074
+
1075
+ ```
1076
+
1077
+ the familiar scaling terminology can make migration easier.
1078
+
1079
+ Example:
1080
+
1081
+ ```
1082
+ import {
1083
+ ms,
1084
+ s,
1085
+ vs,
1086
+ } from 'react-native-dynamic-responsive';
1087
+
1088
+ ```
1089
+
1090
+ For dynamic responsive behavior, prefer:
1091
+
1092
+ ```
1093
+ const styles = useStyles((r) => ({
1094
+ container: {
1095
+ padding: r.ms(16),
1096
+ },
1097
+ }));
1098
+
1099
+ ```
1100
+
1101
+ ### Important
1102
+
1103
+ This package is not intended to be a drop-in replacement for every API or behavior of another responsive library.
1104
+
1105
+ Review your existing scaling configuration and test your UI across your target devices after migration.
1106
+
1107
+ ---
1108
+
1109
+ # πŸ“Š Responsive Design Example
1110
+
1111
+ ### Without responsive rules
1112
+
1113
+ ```
1114
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1115
+ β”‚ PHONE β”‚
1116
+ β”‚ β”‚
1117
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
1118
+ β”‚ β”‚ CARD β”‚ β”‚
1119
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
1120
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1121
+
1122
+
1123
+ ↓
1124
+
1125
+
1126
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
1127
+ β”‚ TABLET β”‚
1128
+ β”‚ β”‚
1129
+ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
1130
+ β”‚ β”‚ CARD β”‚ β”‚
1131
+ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
1132
+ β”‚ β”‚
1133
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
1134
+
1135
+ ```
1136
+
1137
+ ### With responsive rules
1138
+
1139
+ ```
1140
+ const styles = useStyles((r) => ({
1141
+ card: {
1142
+ width: r.isTablet
1143
+ ? r.wp(45)
1144
+ : r.wp(90),
1145
+
1146
+ padding: r.ms(16),
1147
+
1148
+ borderRadius: r.ms(12),
1149
+ },
1150
+ }));
1151
+
1152
+ ```
1153
+
1154
+ The same component can use different dimensions based on the available screen.
1155
+
1156
+ ---
1157
+
1158
+ # 🎯 Design Philosophy
1159
+
1160
+ `react-native-dynamic-responsive` follows a few simple principles:
1161
+
1162
+ ### 1. Keep the API small
1163
+
1164
+ Developers should not need to learn an entire styling framework.
1165
+
1166
+ ### 2. Prefer familiar concepts
1167
+
1168
+ Functions such as:
1169
+
1170
+ ```
1171
+ s()
1172
+ ms()
1173
+ vs()
1174
+ wp()
1175
+ hp()
1176
+
1177
+ ```
1178
+
1179
+ are intentionally easy to understand.
1180
+
1181
+ ### 3. Dynamic where it matters
1182
+
1183
+ Dynamic responsive behavior is useful when the available screen changes.
1184
+
1185
+ ### 4. Avoid unnecessary dependencies
1186
+
1187
+ Zero runtime dependencies keeps the package focused.
1188
+
1189
+ ### 5. TypeScript-friendly
1190
+
1191
+ The API should be comfortable for modern React Native projects.
1192
+
1193
+ ### 6. Don't hide React Native
1194
+
1195
+ The library complements React Native rather than trying to replace its layout system.
1196
+
1197
+ ---
1198
+
1199
+ # πŸ›£οΈ Roadmap
1200
+
1201
+ Potential future improvements may include:
1202
+
1203
+ - More responsive breakpoint utilities
1204
+ - Additional device classification options
1205
+ - Improved responsive configuration
1206
+ - More examples
1207
+ - Performance benchmarks
1208
+ - Expanded test coverage
1209
+ - Additional documentation
1210
+ - Community feedback-driven improvements
1211
+
1212
+ The roadmap may change based on real-world usage and developer feedback.
1213
+
1214
+ ---
1215
+
1216
+ # πŸ› Troubleshooting
1217
+
1218
+ ## Styles are not updating after rotation
1219
+
1220
+ Make sure you are using:
1221
+
1222
+ ```
1223
+ useStyles()
1224
+
1225
+ ```
1226
+
1227
+ for dynamic styles rather than creating static values with `StyleSheet.create()`.
1228
+
1229
+ ---
1230
+
1231
+ ## Tablet layout is not triggering
1232
+
1233
+ Check the current width used by your application and the configured tablet threshold.
1234
+
1235
+ You can inspect:
1236
+
1237
+ ```
1238
+ const r = useResponsive();
1239
+
1240
+ console.log({
1241
+ isTablet: r.isTablet,
1242
+ isFold: r.isFold,
1243
+ isPhone: r.isPhone,
1244
+ isLandscape: r.isLandscape,
1245
+ });
1246
+
1247
+ ```
1248
+
1249
+ ---
1250
+
1251
+ ## My layout is still overflowing
1252
+
1253
+ Responsive scaling does not automatically solve every layout problem.
1254
+
1255
+ Also check:
1256
+
1257
+ - Flexbox configuration
1258
+ - `flexShrink`
1259
+ - `flexWrap`
1260
+ - text length
1261
+ - minimum/maximum dimensions
1262
+ - safe areas
1263
+ - keyboard behavior
1264
+ - accessibility font scaling
1265
+
1266
+ ---
1267
+
1268
+ # πŸ“¦ Package Philosophy
1269
+
1270
+ This library intentionally focuses on one problem:
1271
+
1272
+ > **Making React Native layouts easier to adapt to changing screen dimensions.**
1273
+
1274
+ It does not try to become:
1275
+
1276
+ - a UI framework
1277
+ - a navigation library
1278
+ - an animation framework
1279
+ - a state manager
1280
+ - a complete design system
1281
+
1282
+ Small responsibility.
1283
+
1284
+ Simple API.
1285
+
1286
+ Predictable behavior.
1287
+
1288
+ ---
1289
+
1290
+ # ⭐ Support the Project
1291
+
1292
+ If this library helps you build responsive React Native applications:
1293
+
1294
+ ### ⭐ Star the project
1295
+
1296
+ Stars help other developers discover the library.
1297
+
1298
+ ### πŸ“¦ Install it
1299
+
1300
+ Try it in your next React Native project.
1301
+
1302
+ ### πŸ› Report issues
1303
+
1304
+ Found something unexpected? Open an issue with a reproducible example.
1305
+
1306
+ ### πŸ’‘ Share feedback
1307
+
1308
+ Ideas and real-world use cases help shape future releases.
1309
+
1310
+ ### 🀝 Contribute
1311
+
1312
+ Pull requests and documentation improvements are welcome.
1313
+
1314
+ ---
1315
+
1316
+ # πŸ‘¨β€πŸ’» Author
1317
+
1318
+ ## Dharmendra
1319
+
1320
+ React Native / Full Stack Developer
1321
+
1322
+ Building tools for modern React Native applications.
1323
+
1324
+ ---
1325
+
1326
+ # πŸ“„ License
1327
+
1328
+ MIT License
1329
+
1330
+ Copyright Β© Dharmendra
1331
+
1332
+ ---
1333
+
1334
+ ## πŸ“± Build Once. Adapt Everywhere.
1335
+
1336
+ ### `react-native-dynamic-responsive`
134
1337
 
135
- MIT License.
1338
+ **Responsive UI for modern React Native applications.**