Skip to content

Always return value with 'px' unit in the spacing function #16205

@rashdeva

Description

@rashdeva

Hi guys,

We use styled-components as CSS framework and when we call the spacing function with the single argument we have to put 'px' unit in the end, but with multiple arguments, we don't need to do it. It's a little confusing because by changing the number of arguments a developer should add or remove 'px' unit.

Expected Behavior 🤔

Example:

padding: ${props => props.theme.spacing(2)};
padding: ${props => props.theme.spacing(1, 2)};

Result

padding: 16px;
padding: 8px 16px;

Current Behavior 😯

Example:

padding: ${props => props.theme.spacing(2)};
padding: ${props => props.theme.spacing(1, 2)};

Result

padding: 16;   <---- Here is no PX unit
padding: 8px 16px;

So, now when we use single argument we always put 'px' in the end as the example below:

padding: ${props => props.theme.spacing(2)}px;

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeIntroduces changes that are not backward compatible.type: new featureExpand the scope of the product to solve a new problem.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions