nirsky / react-native-size-matters

A lightweight, zero-dependencies, React-Native utility belt for scaling the size of your apps UI across different sized devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use this with styled-components?

Joshandrews43 opened this issue · comments

Currently looking to use this for my production app to extend it to ipad, but the app is styled with styled components. Is there a way to integrate this with styled components? I think this is the cleanest solution I've found for RN adaptability.

While ScaledSheet can't be used with styled-components, there's no problem using the scale utils.
Example:

import styled from 'styled-components/native';
import { scale, verticalScale, moderateScale } from 'react-native-size-matters';

const Container = styled.View`
    width: ${scale(100)};
    height: ${verticalScale(180)};
    background-color: papayawhip;
    margin: ${moderateScale(15)};
    padding: 5;
`;