Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access custom theme values #1754

Open
meesfrenkelfrank opened this issue Dec 8, 2020 · 1 comment
Open

Access custom theme values #1754

meesfrenkelfrank opened this issue Dec 8, 2020 · 1 comment
Labels

Comments

@meesfrenkelfrank
Copy link

I have to create a responsive grid with CSS grid.

In my theme.js I have:

template: {
    xs: {
      rows: 'auto',
      columns: 'auto',
    },
    sm: {
      rows: 'auto',
      columns: 'repeat(2,1fr)',
    },
    md: {
      rows: 'auto',
      columns: 'repeat(4,1fr)',
    },
    lg: {
      rows: 'auto',
      columns: 'repeat(6,1fr)',
    },
  },

Now in my component I want to do something like this:

<Grid
        gridTemplateColumns={[template.xs.columns, template.sm.columns, template.md.columns]}
        gridGap="30px"
      >
        {items?.map((item) => (
          <MyItem />
        ))}
</Grid>

But then I get:

any
'template' is not defined.eslintno-undef
Cannot find name 'template'.ts(2304)

Is this the correct approach and what do I have to do to get this working?

@TyMick
Copy link

TyMick commented Jan 9, 2021

I take it template is a property in your theme object? You'll need to get your theme object itself using your CSS-in-JS library. Here are the theming docs for styled-components and for Emotion, to get you started—not sure which one you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants