Font fluid

Dynamic font size relative to viewport width.

Preview


Try resizing your browser to see font size change

Module & Import


js

import { fontFluid } from 'gadjet/dist/module/style/font-fluid.js';

Function signature


fontFluid({
    vwMin: number = 300,
    vwMax: number = 1200,
    fontSizeMin: number = 16,
    fontSizeMax: number = 18
}) => string;

param { vwMin: number = 300 }

Minimum viewport width in px unit to calculate font size ratio.

param { vwMax: number = 1200 }

Maximum viewport in px width to calculate font size ratio.

param { fontSizeMin: number = 16 }

Minimum font size at vwMin.

param { fontSizeMax: number = 18 }

Maximum font size at vwMax.

return

CSS string

Usage


js

import { addStyle, fontFluid } from 'gadjet';

addStyle`
html {
    ${fontFluid({
        vwMin: 300,
        vwMax: 1200,
        fontSizeMin: 16,
        fontSizeMax: 18
    })}
}`;
gadjet
Getting Started Style Portion UI