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

Setting different gutter width for different screen resolutions #173

Open
bdeepu opened this issue May 11, 2021 · 1 comment
Open

Setting different gutter width for different screen resolutions #173

bdeepu opened this issue May 11, 2021 · 1 comment

Comments

@bdeepu
Copy link

bdeepu commented May 11, 2021

Hi,

Thanks for this wonderful grid system, I really loved it and is pretty handy too.

I just have one question, is there a way I can change the gutterwidth based on screensize? Or else is it possible to set the gutter width in 'em' instead of 'px'?

For example, I would like to set the gutter width as 40px for screen resolution above 1600 and gutterwidth 30 for screen resolution aboue 1200 and so on.

At present I set the gutter width using the below configuration.

setConfiguration({
gridColumns: 24,
gutterWidth: 40
});

Any help in this would be highly appreaciated.

Thanks in advance.

@ArthurClemens
Copy link

This is how I would do it:

const screenClass = useScreenClass();

const defaultGutterWidth = 20;
const gutterWidths = {
  xl: 30,
  xxl: 40,
};
const gutterWidth = gutterWidths[screenClass] || defaultGutterWidth;

const RowWithGutter = (props) => (
  <Row {...props} gutterWidth={gutterWidth} />
);

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