Skip to content

Typography component or way to use typography styles #1050

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
fernandopasik opened this issue Mar 29, 2020 · 11 comments
Closed

Typography component or way to use typography styles #1050

fernandopasik opened this issue Mar 29, 2020 · 11 comments
Assignees
Labels
Type: Feature New feature or request

Comments

@fernandopasik
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'm trying to style individual elements with the material typography guidelines.

Describe the solution you'd like
Implement @material/mwc-typography component

Describe alternatives you've considered
I've tried to import @material/typography/dist/mdc.typography.css to use the css classes in my component like .mdc-typography--body1, but I can't find an easy way or tool to include that style in my lit-html components

@fernandopasik fernandopasik added the Type: Feature New feature or request label Mar 29, 2020
@fernandopasik
Copy link
Contributor Author

My current workaround far from ideal is to use just the css variables

.my-class {
    font-size: var(--mdc-typography-body1-font-size, 1rem);
    line-height: var(--mdc-typography-body1-line-height, 1.5rem);
    font-weight: var(--mdc-typography-body1-font-weight, 400);
}

@asyncLiz asyncLiz self-assigned this Mar 30, 2020
@asyncLiz
Copy link
Collaborator

This is definitely on our roadmap!

I would recommend a plugin/loader for your build system that can turn a CSS file into a LitElement CSSResult, and use that to import @material/typography in the meantime.

import {style} from '@material/typography/dist/mdc.typography.css';

You can then include the style CSSResult in your LitElement styles.

Alternatively, you can include the raw CSS string into a <style> tag of your component's render function. Not as ideal, but it may be easier to get a CSS-to-string loader set up than CSS-to-CSSResult.

@fernandopasik
Copy link
Contributor Author

Thanks for the quick response and the suggestion.

Would it be another alternative to use a sass plugin and call the right mixin for the typography style (which mixin would that be)?

@asyncLiz
Copy link
Collaborator

Absolutely. You could transform Sass into your component's CSS. You'll want the typography() mixin and provide it one of the text styles.

@use "@material/typography";

.my-headline {
  @include typography.typography(headline1);
}

@Alos
Copy link

Alos commented Dec 29, 2020

It would be awesome if this was implemented out of the box

@aress31
Copy link

aress31 commented Apr 9, 2021

@asyncLiz would you mind providing working code or a tutorial on the steps to follow to be able to use Material typography in MWC based project (without SASS, just following the open-wc standard)?

@aress31
Copy link

aress31 commented Jun 27, 2021

Any update on this feature? :)

@fernandopasik
Copy link
Contributor Author

Is there a new strategy for typography in the new implementation yet?

@asyncLiz
Copy link
Collaborator

Is there a new strategy for typography in the new implementation yet?

I don't believe so, not yet 😔

That might need to be a 1.1 feature

@thekvd
Copy link

thekvd commented Oct 19, 2023

New to github so forgive if this is bad form. I created a CSS file with the defaults and some global variables suggested on the demo site. Not sure if this will be helpful for others but it was for me so I'm sharing it here: https://github.com/thekvd/material-web-typography/

@asyncLiz
Copy link
Collaborator

asyncLiz commented Mar 6, 2024

Long time coming, but this feature has been added. Check out our typography guide for usage docs!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Type: Feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants