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

NextJS apply styles only to map and not globally #14

Open
CDEV500 opened this issue May 24, 2023 · 3 comments
Open

NextJS apply styles only to map and not globally #14

CDEV500 opened this issue May 24, 2023 · 3 comments

Comments

@CDEV500
Copy link

CDEV500 commented May 24, 2023

When following the nextJS example, the way the css is being loaded into the module still applies the styles globally. This causes all font's on our app to become the font within that stylesheet. Do you have an example on how to only apply the styles to the map component?

@benelan
Copy link
Owner

benelan commented May 25, 2023

Are you talking about the fonts specified in styles/global.css? That was generated by NextJS's bootstrapping CLI; you can replace it with your own global styles.

For reference, here is NextJS's doc about CSS styling.

styles/EsriMap.module.css is using CSS modules, so anything you put in there won't be applied globally.

@CDEV500
Copy link
Author

CDEV500 commented May 26, 2023

@benelan appreciate your response.

The CSS import in the styles/EsriMap.module.css does appear to be applying globally. Below are two screenshots with the @import 'https://js.arcgis.com/4.25/@arcgis/core/assets/esri/themes/light/main.css'; and without.

Screenshot 2023-05-25 at 11 05 37 PM Screenshot 2023-05-25 at 11 06 08 PM

Both images are un-styled text added into index.js. Could this be due to the calcite font family being applied to :root in the CSS? I believe in next this still applies globally even from the module.

@benelan
Copy link
Owner

benelan commented Jun 7, 2023

Sorry for the delay. Yeah I'm able to repro, thanks for reporting the issue. While I look into it, using !important when defining your global CSS is a workaround for now.

:root {
  font: italic small-caps bold 16px/2 cursive !important;
}

Although this will override the fonts within the map as well, in case that's not your intention. It's worth trying to set fonts with !important in a class and use the class for everything except the map. I will look for a better solution though.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants