question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to access the final font-size values for use elsewhere in CSS?

See original GitHub issue

For instance with the core fontSize plugin, I can do this:

:root {
 --foo: theme('fontSize.lg');
}

…but since the fluid type plugin calculates the final values at build time, that doesn’t work.

I realize I could use @apply in a lot of cases, but it would be useful to have direct access to the values.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
drdogbot7commented, Aug 18, 2022

This looks great, thank you!

1reaction
davidhellmanncommented, Aug 17, 2022

You can try it out: npm i tailwindcss-fluid-type@next

And under plugins in your tailwind.config.js:

 plugins: [
    require('tailwindcss-fluid-type')({
      settings: {
        fontSizeMin: 1.125, // 1.125rem === 18px
        fontSizeMax: 1.25, // 1.25rem === 20px
        ratioMin: 1.125, // Multiplicator Min
        ratioMax: 1.2, // Multiplicator Max
        screenMin: 20, // 20rem === 320px
        screenMax: 96, // 96rem === 1536px
        unit: 'rem', // default is rem but it's also possible to use 'px'
        prefix: '', // set a prefix to use it alongside the default font sizes
      },
      values: {
        xs: [-2, 1.6],
        sm: [-1, 1.6],
        base: [0, 1.6],
        lg: [1, 1.6],
        xl: [2, 1.2],
        '2xl': [3, 1.2],
        '3xl': [4, 1.2],
        '4xl': [5, 1.1],
        '5xl': [6, 1.1],
        '6xl': [7, 1.1],
        '7xl': [8, 1],
        '8xl': [9, 1],
        '9xl': [10, 1],
      },
    }),
  ],
Read more comments on GitHub >

github_iconTop Results From Across the Web

font-size - CSS: Cascading Style Sheets - MDN Web Docs
There are several ways to specify the font size, including keywords or numerical values for pixels or ems. Choose the appropriate method ...
Read more >
How to get the actual rendered font when it's not defined in ...
I suggest this function: function css( element, property ) { return window.getComputedStyle( element, null ).getPropertyValue( property ); }.
Read more >
How To Style Text Elements with Font, Size, and Color in ...
To get started, open fonts.google.com in you browser. There are many different fonts you can choose from in Google Fonts. This tutorial will...
Read more >
Accessible Font Sizing, Explained
First, resizing text. We want to provide users with low vision a way to choose how fonts are displayed. Not in a crazy...
Read more >
CSS Font-Size: A Tutorial on Text Sizing in CSS
One of the most common ways to set the size of a font is to use pixels. Pixels are a good unit of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found