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

[Question]: How can I set the $base-font-size property with theming? #14392

Closed
1 task done
fegyi001 opened this issue Aug 4, 2023 · 3 comments
Closed
1 task done

[Question]: How can I set the $base-font-size property with theming? #14392

fegyi001 opened this issue Aug 4, 2023 · 3 comments

Comments

@fegyi001
Copy link

fegyi001 commented Aug 4, 2023

Question for Carbon

I'm trying to fine-tune carbon styles in my (angular) app. However, I'm unable to override the default 16px font size. I would like to set it to 14px.

When I try to use @carbon/layout and modify it like so (as mentioned in the docs):

@use 'carbon-components/scss/themes';
@use 'carbon-components/scss/theme' with (
  $fallback: themes.$g10,
  $theme: (),
);

@use '@carbon/layout' with (
  $base-font-size: 14px
);

I get the following error: This module was already loaded, so it can't be configured using "with".

image

Is it possible to set the theme so that it accepts my overridden value?

Thanks in advance!

Code of Conduct

@tw15egan
Copy link
Collaborator

tw15egan commented Aug 4, 2023

Can you do @use '@carbon/layout/scss/convert' with ($base-font-size: 14px); before the theme import? Any Stackblitz example would also help debugging. Here is a previous in-depth example of some custom theming: https://stackblitz.com/edit/github-hf5kjr-t9xs4w?file=src%2Findex.scss

@Yaren-IT
Copy link

Based on the code snippet you shared, it appears that you're on the right path. However, since a previous @use directive has already imported @carbon/layout, there's a conflict that needs to be addressed. To tackle this, you should adjust the order of your code like this:

// Import the @carbon/layout directive before @carbon/themes
@use '@carbon/layout' with (
  $base-font-size: 14px
);

@use 'carbon-components/scss/themes';
@use 'carbon-components/scss/theme' with (
  $fallback: themes.$g10,
  $theme: (),
);

// Continue with your previous @use directives and other styling rules...

@tay1orjones
Copy link
Member

Additionally, the layout module can be accessed through carbon-components itself which can help with these config issues.

@use 'carbon-components/scss/layout' with (
  $base-font-size: 14px
);
@use 'carbon-components/scss/themes';
@use 'carbon-components/scss/theme' with (
  $fallback: themes.$g10,
  $theme: (),
);

These options should resolve the issue, please open a new issue if not. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants