Typography · 28 of 33

Variable Axis Hover

Weight and Width change dynamically

HTML · CSS · No dependencies · MIT

HTML

<!-- Requires a variable font, e.g. Roboto Flex from Google Fonts:
<link href="https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,slnt,wdth,wght@8..144,-10..0,25..151,100..1000&display=swap" rel="stylesheet"> -->

<h2 class="variable-axis-text">Variable</h2>

CSS

.variable-axis-text {
  font-family: 'Roboto Flex', sans-serif;
  font-size: 3.5rem;
  text-align: center;
  font-variation-settings: 'wght' 100, 'wdth' 100, 'slnt' 0;
  transition: font-variation-settings 0.5s ease;
  cursor: pointer;
}

.variable-axis-text:hover {
  font-variation-settings: 'wght' 900, 'wdth' 150, 'slnt' -10;
  color: #7c5cff;
}