Styled-system: Is it possible use `css` from `styled-components` in variants?

Created on 30 Dec 2019  路  3Comments  路  Source: styled-system/styled-system

I have this code:

import styled, { css } from "styled-components";
import { compose, space, typography, color, SpaceProps, ColorProps, TypographyProps, variant } from "styled-system";

const navigationVariant = css`
    background-color: red;
    font-weight: 600;
    text-decoration: none;
`;

export const LinkPrimitive = styled.a<LinkPrimitiveProps>`
    ${variant({
        variants: {
            navigation: navigationVariant,
        },
    })}
    ${compose(space, typography, color)}
`;

interface LinkPrimitiveProps extends SpaceProps, TypographyProps, ColorProps {
    variant?: "navigation";
}

But in browser it is translate to:

0: background-color:red;
    font-weight: 600;
    -webkit-text-decoration: none;
    text-decoration: none;

As you can see, the first property is translate to 0: background-color:red; when should it be background-color:red;.

question

Most helpful comment

Could it be a new feature?

All 3 comments

No, variants only support objects as arguments

Could it be a new feature?

@jxnblk sorry for the comment on the closed issue, but are there any limitations on template literals support? If not, would you be open for a PR implementing it? Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinSuttle picture kevinSuttle  路  4Comments

D1no picture D1no  路  4Comments

wmarkowitz picture wmarkowitz  路  4Comments

gausie picture gausie  路  4Comments

philholden picture philholden  路  5Comments