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

Box does not accept variants in theme #2456

Closed
hutber opened this issue Nov 11, 2020 · 8 comments
Closed

Box does not accept variants in theme #2456

hutber opened this issue Nov 11, 2020 · 8 comments

Comments

@hutber
Copy link

hutber commented Nov 11, 2020

Currently it seems I am unable to use a variant on the Box component. I believe this is not meant to be the case?

 <Box
      variant="share"
    >

Output:

<div variant="share" class="css-0"></div>

Versions:

    "@chakra-ui/color-mode": "^1.0.0-next.3",
    "@chakra-ui/core": "^1.0.0-rc.7",
    "@chakra-ui/media-query": "^1.0.0-rc.7",

Theme:
image

Output:
image

@segunadebayo
Copy link
Member

segunadebayo commented Nov 11, 2020

Hi @hutber,

Box is a generic component and cannot accept variant in theme. I'd recommend that you create a wrapper component and use the useStyleConfig described there: https://next.chakra-ui.com/docs/theming/component-style#usestyleconfig-api

You can also consider using the layer and text styles described here: https://next.chakra-ui.com/docs/features/text-and-layer-styles

@ljosberinn
Copy link
Contributor

On a sidenote, you have version mismatching going on there:

"@chakra-ui/color-mode": "^1.0.0-next.3",
    "@chakra-ui/core": "^1.0.0-rc.7",
    "@chakra-ui/media-query": "^1.0.0-rc.7",

they should all be on the same version, notably rc.8 and unless you explicitly use one of those modules, there's no reason to install anything besides @chakra-ui/core.

@hutber
Copy link
Author

hutber commented Nov 12, 2020

Thank you guys, it would be great if there was a list of items that weren't styleable?

@with-heart
Copy link
Contributor

Box should be the only one!

@davisuga
Copy link

Box should be the only one!

And Flex too

@LucasZapico
Copy link

I know this is closed, but it would be great to throw an error or warning on this. I spun on this for a bit trying to debug before I did the trusty Google search. 🤷‍♂️

@omarryhan
Copy link

Box is a generic component and cannot accept a variant theme.

Is this a technical limitation @segunadebayo? Because from an API design perspective, I think it's confusing.

My use case: I want to create a card, and I think a div/Box is the most relevant element from ChakraUI. Any alternative that you'd recommend?

@ndewhurst
Copy link

FWIW the links from Segun's comment were broken when I tried to access them, but these appear to be the corresponding URLs for the current documentation:

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

No branches or pull requests

8 participants