One method that can be used to achieve a similar result is by following this formula:
const { width } = useWindowDimension();
const percentage = width * 0.8; // 80% of the window
<ComponentOrElement style={ width: percentage } />
However, this calculation is based on the width
(or sometimes the height
) of the element. What I actually want is to achieve the same effect but based on scaling transformation. Here's an example:
const { width } = useWindowDimension();
const percentage = width * 0.8; // 80% of the window?
<ComponentOrElement style={ transform: [ { scale: percentage } ] } />
It's worth noting that scaling typically ranges from 0
to 1
, representing a factor rather than specific pixels or dp.
Any suggestions on how to apply this scaling?