{"id":4012,"url":"https://github.com/nirsky/react-native-size-matters","last_synced_at":"2025-05-14T03:10:48.847Z","repository":{"id":40828183,"uuid":"111529249","full_name":"nirsky/react-native-size-matters","owner":"nirsky","description":"A lightweight, zero-dependencies, React-Native utility belt for scaling the size of your apps UI across different sized devices.","archived":false,"fork":false,"pushed_at":"2023-10-03T09:23:09.000Z","size":3657,"stargazers_count":2421,"open_issues_count":3,"forks_count":153,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-07T10:47:02.002Z","etag":null,"topics":["javascript","react-native","scaling","tablet"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nirsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-21T09:44:14.000Z","updated_at":"2025-05-06T18:38:24.000Z","dependencies_parsed_at":"2024-06-18T11:27:45.040Z","dependency_job_id":null,"html_url":"https://github.com/nirsky/react-native-size-matters","commit_stats":{"total_commits":60,"total_committers":8,"mean_commits":7.5,"dds":0.5333333333333333,"last_synced_commit":"cbbd64c94ce1dfc95a3027dbad40916a5718907f"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirsky%2Freact-native-size-matters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirsky%2Freact-native-size-matters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirsky%2Freact-native-size-matters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nirsky%2Freact-native-size-matters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nirsky","download_url":"https://codeload.github.com/nirsky/react-native-size-matters/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253082858,"owners_count":21851170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","react-native","scaling","tablet"],"created_at":"2024-01-05T20:16:58.429Z","updated_at":"2025-05-14T03:10:43.829Z","avatar_url":"https://github.com/nirsky.png","language":"JavaScript","funding_links":[],"categories":["Components","JavaScript","Others"],"sub_categories":["UI"],"readme":"# 📐 react-native-size-matters\n[![NPM version](https://img.shields.io/npm/v/react-native-size-matters.svg?color=steelblue)](https://www.npmjs.com/package/react-native-size-matters) \n[![Actions Status: test](https://github.com/nirsky/react-native-size-matters/workflows/Test/badge.svg)](https://github.com/nirsky/react-native-size-matters/actions?query=workflow%3ATest)\n[![TypeScript](https://badgen.net/npm/types/env-var)](https://github.com/nirsky/react-native-size-matters/blob/master/index.d.ts)\n![npm](https://img.shields.io/npm/dw/react-native-size-matters)\n[![npm bundle size](https://img.shields.io/bundlephobia/min/react-native-size-matters)](https://bundlephobia.com/package/react-native-size-matters@latest)\n\nA lightweight, zero-dependencies, React-Native utility belt for scaling the size of your apps UI across different sized devices.\n\n\u003ca href=\"./examples/ipad.gif\"\u003e\n    \u003cimg src=\"./examples/ipad.gif\" width=\"320\"/\u003e\n\u003c/a\u003e\n\n## Installation\n```js\nnpm install --save react-native-size-matters\n//or:\nyarn add react-native-size-matters\n```\n\n## Motivation\nWhen developing with react-native, you need to manually adjust your app to look great on a variety of different screen sizes. That's a tedious job.  \nreact-native-size-matters provides some simple tooling to make your scaling a whole lot easier.  \nThe idea is to develop once on a standard ~5\" screen mobile device and then simply apply the provided utils.  \n📖 \u0026nbsp;You can read more about what led to this library on my blog post, which can be found in [this repo](./examples/BlogPost) or at [Medium](https://medium.com/soluto-engineering/size-matters-5aeeb462900a).\n\n## API\n### Scaling Functions\n```js\nimport { scale, verticalScale, moderateScale } from 'react-native-size-matters';\n\nconst Component = props =\u003e\n    \u003cView style={{\n        width: scale(30),\n        height: verticalScale(50),\n        padding: moderateScale(5)\n    }}/\u003e;\n```\n\n\n* `scale(size: number)`  \nWill return a linear scaled result of the provided size, based on your device's screen width.\n* `verticalScale(size: number)`  \nWill return a linear scaled result of the provided size, based on your device's screen height.\n\n* `moderateScale(size: number, factor?: number)`  \nSometimes you don't want to scale everything in a linear manner, that's where moderateScale comes in.  \nThe cool thing about it is that you can control the resize factor (default is 0.5).  \nIf normal scale will increase your size by +2X, moderateScale will only increase it by +X, for example:  \n➡️ \u0026nbsp;\u0026nbsp;scale(10) = 20  \n➡️ \u0026nbsp;\u0026nbsp;moderateScale(10) = 15  \n➡️ \u0026nbsp;\u0026nbsp;moderateScale(10, 0.1) = 11  \n* `moderateVerticalScale(size: number, factor?: number)`  \nSame as moderateScale, but using verticalScale instead of scale.\n\nAll scale functions can be imported using their shorthand alias as well:\n```js\nimport { s, vs, ms, mvs } from 'react-native-size-matters';\n```\n\n\n### ScaledSheet\n```js\nimport { ScaledSheet } from 'react-native-size-matters';\n\nconst styles = ScaledSheet.create(stylesObject)\n```\n\nScaledSheet will take the same stylesObject a regular StyleSheet will take, plus a special (optional) annotation that will automatically apply the scale functions for you:\n* `\u003csize\u003e@s` - will apply `scale` function on `size`.\n* `\u003csize\u003e@vs` - will apply `verticalScale` function on `size`.\n* `\u003csize\u003e@ms` - will apply `moderateScale` function with resize factor of 0.5 on `size`.\n* `\u003csize\u003e@mvs` - will apply `moderateVerticalScale` function with resize factor of 0.5 on `size`.\n* `\u003csize\u003e@ms\u003cfactor\u003e` - will apply `moderateScale` function with resize factor of `factor` on size.\n* `\u003csize\u003e@mvs\u003cfactor\u003e` - will apply `moderateVerticalScale` function with resize factor of `factor` on size.\n\nScaledSheet also supports rounding the result, simply add `r` at the end of the annotation. \n\nExample:\n```js\nimport { ScaledSheet } from 'react-native-size-matters';\n\nconst styles = ScaledSheet.create({\n    container: {\n        width: '100@s', // = scale(100)\n        height: '200@vs', // = verticalScale(200)\n        padding: '2@msr', // = Math.round(moderateScale(2))\n        margin: 5\n    },\n    row: {\n        padding: '10@ms0.3', // = moderateScale(10, 0.3)\n        width: '50@ms', // = moderateScale(50)\n        height: '30@mvs0.3' // = moderateVerticalScale(30, 0.3)\n    }\n});\n```\n\n\u003chr/\u003e\n\n* [Changing the Default Guideline Sizes](./examples/change-guideline-sizes.md)\n* [Examples](./examples/README.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirsky%2Freact-native-size-matters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnirsky%2Freact-native-size-matters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnirsky%2Freact-native-size-matters/lists"}