-
Notifications
You must be signed in to change notification settings - Fork 44
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
Responsive - deactivate stickybox on mobile devices #46
Comments
did you find a solution to it ? I have same challenge |
@johnson444 well for now I define a conditionnal component like :
Where |
@adrienlamotte Thx ! Will do this as well. If I have time I will look closer into the package. If I find a better way I will let you know |
This solution might work, when the children can be re-rendered. In case that the children should not be re-rendered this might kill some flow. I would prefer like a prop
|
A simple and fast solution to remove stickyBox on mobile is to add a css class and use @media to cancel the sticky effect according to the desired width. Here is an example :
I hope it helps ++. |
@Arnaud-Desportes Nice solution, thanks for sharing! |
You saved me lots of hours, Thanks for the solution! |
MUI 5 solution thanks to @Arnaud-Desportes import React from 'react';
import { SxProps, Theme, styled } from '@mui/material/styles';
import ReactStickyBox, { StickyBoxCompProps } from 'react-sticky-box';
export interface StickyBoxProps extends StickyBoxCompProps {
disabled?: boolean;
sx?: SxProps<Theme>;
}
const StickyBox = styled(ReactStickyBox, {
shouldForwardProp: (prop) => ['disabled'].every((key) => key !== prop),
})<StickyBoxProps>(({ theme, disabled }) =>
theme.unstable_sx({
...(disabled && {
position: 'inherit !important',
top: 'inherit !important',
}),
}),
);
export default StickyBox; |
Hello,
Most of the time when using a sticky sidebar, you want the sidebar not to be sticky on small devices.
Is there any way to achieve this ?
Thank you for your work, great lib btw :)
The text was updated successfully, but these errors were encountered: