All Projects โ†’ davidhellmann โ†’ tailwindcss-fluid-type

davidhellmann / tailwindcss-fluid-type

Licence: MIT license
A plugin that makes the use of Fluid Type a breeze.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to tailwindcss-fluid-type

wrapped
GitHub Wrapped, inspired by Spotify Wrapped
Stars: โœญ 159 (+74.73%)
Mutual labels:  tailwind, tailwindcss
Next-JS-Landing-Page-Starter-Template
๐Ÿš€ Free NextJS Landing Page Template written in Tailwind CSS 3 and TypeScript โšก๏ธ Made with developer experience first: Next.js 12 + TypeScript + ESLint + Prettier + Husky + Lint-Staged + VSCode + Netlify + PostCSS + Tailwind CSS
Stars: โœญ 521 (+472.53%)
Mutual labels:  tailwind, tailwindcss
tailwind-ui-components
Free Tailwind CSS UI Components - Crafted for modern websites, landing pages and web apps. TailGrids Core is free and open-source so, feel free to use with your personal or commercial projects. If you would like to show your support and love, don't forget to give us a star ๐ŸŒŸ
Stars: โœญ 49 (-46.15%)
Mutual labels:  tailwind, tailwindcss
hepsiburada
Hepsiburada.com Tailwind/VueJS/CSS Clone
Stars: โœญ 39 (-57.14%)
Mutual labels:  tailwind, tailwindcss
Figmatocode
Generate responsive pages and apps on HTML, Tailwind, Flutter and SwiftUI.
Stars: โœญ 2,299 (+2426.37%)
Mutual labels:  tailwind, tailwindcss
eleventy solo starter njk
Further development suspended as of 2021-09-11. Please refer instead to https://www.11ty.dev/docs/starter/ for a wide selection of other Eleventy starter sets.
Stars: โœญ 22 (-75.82%)
Mutual labels:  tailwind, tailwindcss
cra-tailwindcss
Integrate Tailwind CSS in a Create React App setup
Stars: โœญ 105 (+15.38%)
Mutual labels:  tailwind, tailwindcss
EddieHubCommunity.github.io
Information about our community
Stars: โœญ 88 (-3.3%)
Mutual labels:  tailwind, tailwindcss
Goodwork
Self hosted project management and collaboration tool powered by TALL stack
Stars: โœญ 1,730 (+1801.1%)
Mutual labels:  tailwind, tailwindcss
Awesome Tailwindcss
๐Ÿ˜Ž Awesome things related to Tailwind CSS
Stars: โœญ 7,791 (+8461.54%)
Mutual labels:  tailwind, tailwindcss
tailwind
๐Ÿง›๐Ÿปโ€โ™‚๏ธ Dark theme for Tailwind
Stars: โœญ 25 (-72.53%)
Mutual labels:  tailwind, tailwindcss
responsive-modular-scale.css
Responsive typography using CSS variables
Stars: โœญ 19 (-79.12%)
Mutual labels:  typography, modular-scale
tailwindcss-variables
Easily create css variables without the need for a css file!
Stars: โœญ 47 (-48.35%)
Mutual labels:  tailwind, tailwindcss
vite-react-ts-tailwind-firebase-starter
Starter using Vite + React + TypeScript + Tailwind CSS. And already set up Firebase(v9), Prettier and ESLint.
Stars: โœญ 108 (+18.68%)
Mutual labels:  tailwind, tailwindcss
react-tailwind
This is a complementary React code for the tailwindcss project.
Stars: โœญ 29 (-68.13%)
Mutual labels:  tailwind, tailwindcss
css-to-tailwind
Convert plain CSS to TailwindCSS classes. Demo: https://transform.tools/css-to-tailwind
Stars: โœญ 19 (-79.12%)
Mutual labels:  tailwind, tailwindcss
coc-tailwind-intellisense
Coc.nvim extension for Tailwind CSS IntelliSense
Stars: โœญ 117 (+28.57%)
Mutual labels:  tailwind, tailwindcss
react-heroicons
Heroicons as React components
Stars: โœญ 39 (-57.14%)
Mutual labels:  tailwind, tailwindcss
Twin.macro
๐Ÿฆนโ€โ™‚๏ธ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, stitches and goober) at build time.
Stars: โœญ 5,137 (+5545.05%)
Mutual labels:  tailwind, tailwindcss
Universal Resume
Minimal and formal rรฉsumรฉ (CV) website template for print, mobile, and desktop. https://bit.ly/ur_demo
Stars: โœญ 1,349 (+1382.42%)
Mutual labels:  typography, tailwindcss

๐Ÿ‘‰๐Ÿป tailwindcss-fluid-type

Tailwincss Fluid Type

A plugin that makes the use of Fluid Type a breeze.

๐Ÿ‘‰๐Ÿป Installation

Install the plugin from npm:

# Using npm
npm install tailwindcss-fluid-type

# Using Yarn
yarn add tailwindcss-fluid-type

Then add the plugin to your tailwind.config.js file and do your settings if you're not happy with the defaults:

// tailwind.config.js
module.exports = {
    theme: {
        // ...
    },
    // You can disable the fontSize core plugin if you don't need the defaults. 
    // If you don't disable it, the fluid-type plugin simply overrule the defaults.
    // Or you can use both alongside when you set an prefix in the settings
    corePlugins: {
        fontSize: false,
        // ...
    },
    plugins: [
        require('tailwindcss-fluid-type'),
        // ...
    ],
};

๐Ÿ‘‰๐Ÿป Usage

Nothing changed here to the default tailwindcss configuration:

<article>
    <h1 class="text-xl">Fluid type</h1>
</article>

๐Ÿ‘‰๐Ÿป Configuration

The plugin comes with a default configuration (see below) but it's possible to customize this config for your project. As default, we use rem for better accessibility, but you can also use px.

Default configuration

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            // your fluid type settings
            // works only with unitless numbers
            // This numbers are the defaults settings
            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
            },
            // Creates the text-xx classes
            // This are the default settings and analog to the tailwindcss defaults
            // Each `lineHeight` is set unitless and we think that's the way to go especially in context with fluid type.
            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],
            }
        },
    },
    variants: {
        fluidType: ['responsive']
    }
};

Fluid type configuration without lineHeight

It is also possible to set just the fontSize without set the lineHeight

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            values: {
                // ...
                'base': 0,
                // ...
            }
        }
    }
};

Fluid type configuration with lineHeight & letterSpacing

And yes, you can also set the letterSpacing & lineHeight as you know from the tailwind documentation. letterSpacing can be all values that you like.

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            values: {
                // ...
                'base': [0,
                    {
                        lineHeight: 1.6,
                        letterSpacing: '-0.1rem',
                    }
                ],
                // ...
            }
        }
    }
};

๐Ÿ‘‰๐Ÿป Samples

Just set the fontSize property

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            settings: {
                fontSizeMin: 1.125,
                fontSizeMax: 1.25,
                ratioMin: 1.125,
                ratioMax: 1.2,
                screenMin: 20,
                screenMax: 96,
                unit: 'rem',
                prefix: ''
            },
            values: {
                // ...
                'base': 0,
                // ...
            }
        }
    }
};
<p class="text-base">The quick brown fox jumps over the lazy dogs</p>
.text-base {
    font-size: clamp(1.125rem, calc(1.125rem + (1.25 - 1.125) * ((100vw - 20rem) / (96 - 20))), 1.25rem);
}

Set the fontSize & lineHeight property

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            settings: {
                fontSizeMin: 1.125,
                fontSizeMax: 1.25,
                ratioMin: 1.125,
                ratioMax: 1.2,
                screenMin: 20,
                screenMax: 96,
                unit: 'rem',
                prefix: ''                
            },
            values: {
                // ...
                'base': [0, 1.6],
                // ...
            }
        }
    }
};
<p class="text-base">The quick brown fox jumps over the lazy dogs</p>
.text-base {
    font-size: clamp(1.125rem, calc(1.125rem + (1.25 - 1.125) * ((100vw - 20rem) / (96 - 20))), 1.25rem);
    line-height: 1.6;
}

Set the fontSize, lineHeight & letterSpacing property

// tailwind.config.js
module.exports = {
    theme: {
        fluidType: {
            settings: {
                fontSizeMin: 1.125,
                fontSizeMax: 1.25,
                ratioMin: 1.125,
                ratioMax: 1.2,
                screenMin: 20,
                screenMax: 96,
                unit: 'rem',
                prefix: '',
            },
            values: {
                // ...
                'base': [0, {
                    lineHeight: 1.6,
                    letterSpacing: '-0.1rem',
                }],
                // ...
            }
        }
    }
};
<p class="text-base">The quick brown fox jumps over the lazy dogs</p>
.text-base {
    font-size: clamp(1.125rem, calc(1.125rem + (1.25 - 1.125) * ((100vw - 20rem) / (96 - 20))), 1.25rem);
    line-height: 1.6;
    letter-spacing: -0.1rem;
}

Set a value as string

// tailwind.config.js
module.exports = {
    theme: {
        extend: {
            fluidType: {
                values: {
                    // ...
                    '2xs': '11px',
                    // ...
                }
            }
        }
    }
};
<p class="text-2xs">The quick brown fox jumps over the lazy dogs</p>
.text-2xs {
    font-size: 11px;
}

Set a prefix

// tailwind.config.js
module.exports = {
    theme: {
        extend: {
            fluidType: {
                settings: {
                    // ...
                    prefix: 'fluid-',
                },
            }
        }
    }
};
<p class="fluid-text-base">The quick brown fox jumps over the lazy dogs</p>
.fluid-text-base {
    font-size: clamp(1.125rem, calc(1.125rem + (1.25 - 1.125) * ((100vw - 20rem) / (96 - 20))), 1.25rem);
    line-height: 1.6;
    letter-spacing: -0.1rem;
}

๐Ÿ‘‰๐Ÿป Live Demo

Fluid Type Live Demo

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].