Skip to the content

Weight field

A heading whose letters grow bolder under the pointer.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Instrument Sans and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    Nothing to size: a letter grows into the space around it and no line moves. Leave the heading without overflow: hidden, which would clip the thick outline, and without background-clip: text, which every letter would lose; the colour under the pointer is the tint setting.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-weight-field Marks the heading whose letters grow bolder: it goes on the heading itself, or on any text element, and takes no value: leave the value field empty. The script splits its text into letters when the page loads and the fonts are in, and puts the heading back as it was with destroy(); in the Designer the heading stays plain text, editable.
    data-weight-field-area On a parent of the heading, the section of the preview for one: the pointer moving anywhere inside it drives the letters, so the heading answers as the pointer approaches and not only once it is on the text. It takes no value. Without it, only the heading's own box listens. [ Optional ]
    data-weight-field-state Written by the engine on the heading: ready once the letters are built, static under reduced motion. Never written by hand. data-weight-field-mode, stroke or weight, is written beside it and is what the stylesheet reads to apply the outline. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-weight-field-mode stroke How a letter grows bolder. Options: stroke (the outline thickens in the letter's own ink, with any typeface, and no letter moves), weight (the real weight of a variable font moves between minWeight and maxWeight, each letter held in a cell of its resting width; a font of fixed cuts jumps from cut to cut in this mode).
    data-weight-field-stroke 0.06 Thickness added to the outline of the letter right under the pointer, in em of the heading, stroke mode; the letters around it take a share of it.
    data-weight-field-min-weight 400 Weight of a letter far from the pointer, weight mode, on the font's wght axis.
    data-weight-field-max-weight 700 Weight of the letter right under the pointer, weight mode.
    data-weight-field-radius 3.4 Reach of the pointer, in em of the heading: how far from the pointer a letter still answers.
    data-weight-field-follow 0.35 Time a letter takes to reach its thickness once the pointer has moved, in seconds.
    data-weight-field-tint inherit Ink of the letter under the pointer, mixed into the heading's colour as the letter grows. Options: inherit (the heading's own colour, the letter only grows), or any CSS colour.
    data-weight-field-idle wave What the heading does with no pointer on it: on a phone, before the mouse has come in, and a moment after it has left. Options: wave (a slow pass sweeps the heading from left to right, again and again), none (the heading rests at its resting thickness until a pointer comes).
    data-weight-field-idle-period 4 Time the idle pass takes to cross the heading, in seconds.

What it does

Weight field is a text animation for Webflow and vanilla JavaScript, with no library. Also called font weight hover effect, variable font hover effect or proximity text effect.

A heading whose letters grow bolder under the pointer. Each letter answers the distance to the pointer: the closest ones are heavy, the ones at the edge of its reach barely touched, and every letter eases to its thickness over a short moment, so a pass of the mouse reads as a weight moving through the line rather than a switch. The bolder letter takes a tint on the way, the heading's own ink or a colour of your own. What grows is the outline of each letter, drawn in its own ink, so any typeface works, a variable one or a family of fixed cuts, and no letter and no line moves while it plays: the words are kept whole, the lines frozen where they fell at rest. The reach around the pointer is a flat ellipse, so the line under the pointer reacts and the lines above and below stay at rest. Without a pointer, on a phone or before the mouse has come in, a slow pass sweeps the heading from left to right, so the effect is seen without anyone touching it. Under reduced motion the heading stands still. A second mode moves the real weight of a variable font instead of the outline, each letter kept in a cell of its resting width. Pattern type variable font hover, font weight on hover, proximity text effect.

Updated

Questions

Select the Heading, open the Settings panel and add the custom attribute data-weight-field with an empty value. The script splits the heading into letters once the fonts are in, and each letter thickens as the pointer comes near. To have the letters answer before the pointer reaches the text, add data-weight-field-area, empty too, on the section around the heading. In the Designer the heading stays plain and editable, since the canvas runs no Embed.

No. By default what grows is the outline of each letter, drawn in its own ink with -webkit-text-stroke, so a family of fixed cuts thickens as smoothly as a variable font and no letter changes width. A variable font with a wght axis can move its real weight instead: set data-weight-field-mode="weight", and data-weight-field-min-weight and data-weight-field-max-weight give the two ends of the axis.

Set data-weight-field-tint on the heading to any CSS colour, #ff4a00 in the preview. The letter's colour is mixed from the heading's ink and that tint as the letter grows, so the ones at the edge of the reach barely change. inherit, the default, keeps the heading's own colour and the letters only grow.

data-weight-field-radius is the reach in em of the heading, 3.4 by default: lower it to a spotlight on one letter, raise it to have half the line follow the pointer. data-weight-field-follow, 0.35 by default, is the time in seconds a letter takes to reach its thickness; a lower value snaps, a higher one trails the pointer and lingers after it.

A slow pass sweeps the heading from left to right, again and again, every 4 seconds by default (data-weight-field-idle-period), so the effect is seen without anyone touching it. The same pass runs on a desktop before the mouse has come in and a moment after it has left. data-weight-field-idle="none" turns it off, and under reduced motion the heading stands still.