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

Styling of sticky #288

Open
judygab opened this issue Jun 7, 2019 · 2 comments
Open

Styling of sticky #288

judygab opened this issue Jun 7, 2019 · 2 comments

Comments

@judygab
Copy link

judygab commented Jun 7, 2019

I'm submitting a feature request

Code Sandbox

So currently if I pass any additional styling to {style} it updates the style if the container even when it's not sticky. Is there a way to change the style of a component only when it sticks?
And another thing related to this would be how to use to in the same side by side. I've tried and one overlaps another one.

@annetters
Copy link

It would be great to apply certain styles depending on if the item is sticky or not. Or at least the ability to toggle a CSS class.

@annetters
Copy link

annetters commented Sep 9, 2019

Hi @judygab,

I was able to do this with a CSS class by using the built-in isSticky property. Example:

<StickyContainer>
    <Sticky>
        {({ style, isSticky }) => (
            <div style={{ ...style }} className={(isSticky ? 'is-sticky' : 'not-sticky')}>
                <ProfileHeader />
            </div>
        )}
    </Sticky>
    <div>Stuff that does not stick goes here.</div>
<StickyContainer>

Then your CSS class would be something like...

.is-sticky {background: red;}
.not-sticky {background: blue;}

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

2 participants