cyntler / hamburger-react

Animated hamburger menu icons for React.js weighs only 1.5 KB.
https://hamburger-react.netlify.app
MIT License
963 stars 36 forks source link

Styled-components class not attached to element #32

Closed Irian closed 3 years ago

Irian commented 3 years ago

Good day,

thank you for creating this library, it looks nice!

I would like to show it only on a small screen size while using Styled-components. I therefore tried to instantiate the Hamburger as follows:

const StyledHamburger = styled(Hamburger)`
    @media(min-width: 770px){
        display: none;
    }
`;

However, as the className is not attached to the element, this does not work. See the Styled-components documentation for more information.

luukdv commented 3 years ago

Hi!

The reason for not passing a className is because it could be error-prone, with users accidentally overwriting required styles. I realized a while ago this might not be the best reasoning though, so in the next major/breaking version this will be changed. Until that moment, you could wrap the component in a <div> on which you apply these styles, or use the .hamburger-react className manually.

Irian commented 3 years ago

Thanks for the quick reply! I did figure something like that and have indeed used the .hamburger-react className to get it done. I am looking forward to the next version!