npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@liiift-studio/hoverboldly

v1.1.0

Published

Variable font weight hover and bold interactions without layout shift — wght increase with automatic wdth/tracking compensation

Downloads

516

Readme

Hover Boldly

Every browser reflows text when you hover to bold — words push down, lines shift. Bold Lock measures the exact width difference using Canvas measureText, then compensates with letter-spacing so the line never moves. One measurement pass on mount; zero reflow on hover.

hoverboldly.com · npm · GitHub

TypeScript · Canvas measurement · React + Vanilla JS


Install

npm install @liiift-studio/hoverboldly

Usage

Next.js App Router: this library uses browser APIs. Add "use client" to any component file that imports from it.

React component

import { BoldLockText } from '@liiift-studio/hoverboldly'

<BoldLockText normalWeight={300} hoverWeight={700} transitionDuration={150}>
  Hover over this text...
</BoldLockText>

React hook

import { useBoldLock } from '@liiift-studio/hoverboldly'

// Inside a React component:
const ref = useBoldLock({ normalWeight: 300, hoverWeight: 700 })
return <p ref={ref}>{children}</p>

The hook attaches all event listeners on mount and removes them on unmount or when options change.

Vanilla JS — interactive bold-lock

applyBoldLock attaches event listeners and returns a cleanup function.

import { applyBoldLock } from '@liiift-studio/hoverboldly'

const el = document.querySelector('p')
const cleanup = applyBoldLock(el, { normalWeight: 300, hoverWeight: 700 })

// Later — remove all listeners and reset styles:
cleanup()

Vanilla JS — static bold-shift (CSS :hover { font-weight: bold })

For elements that use a CSS rule to apply bold, applyBoldShift pre-compensates with letter-spacing so there is no reflow when the style activates.

import { applyBoldShift } from '@liiift-studio/hoverboldly'

const el = document.querySelector('p')
applyBoldShift(el, { normalWeight: 400, boldWeight: 700 })

TypeScript

import type { BoldLockOptions, BoldShiftOptions } from '@liiift-studio/hoverboldly'

const lockOpts: BoldLockOptions = { normalWeight: 300, hoverWeight: 700, mode: 'word' }
const shiftOpts: BoldShiftOptions = { normalWeight: 400, boldWeight: 700 }

Options

BoldLockOptions (interactive hover)

| Option | Default | Description | |--------|---------|-------------| | normalWeight | computed font-weight | wght axis value at rest | | hoverWeight | 700 | wght axis value on hover | | transitionDuration | 150 | Transition duration in milliseconds. Set to 0 to disable | | mode | 'element' | 'element' — whole element activates together. 'word' — each word is an independent hover target | | as | 'p' | HTML element to render. (React component only) |

BoldShiftOptions (static CSS bold)

| Option | Default | Description | |--------|---------|-------------| | normalWeight | 400 | wght axis value at rest | | boldWeight | 700 | wght axis value when bold |


How it works

In 'element' mode, Canvas measureText reads the element's full text content at both weights once on mount. The width delta is distributed across character gaps as a negative letter-spacing, applied on mouseenter and reversed on mouseleave — total line width stays identical at both weights.

In 'word' mode, each word is measured and compensated independently so individual words can hover without affecting their neighbours.

Both modes respond to mouse, touch (touchstart/touchend), and keyboard (focusin/focusout), so the effect works on mobile and for keyboard navigation. prefers-reduced-motion: reduce disables the CSS transition, keeping the weight change instantaneous but still happening.

applyBoldShift injects a scoped <style> rule targeting the element by a generated data-bold-shift attribute. There is no automatic cleanup — remove the <style> element and data-bold-shift attribute manually if needed.

Line break safety: The compensation is applied as letter-spacing at the element level (or per-word in 'word' mode), not via line wrapping. Line breaks are the browser's natural layout and are unaffected by the weight change or its compensation.


Dev notes

next in root devDependencies

package.json at the repo root lists next as a devDependency. This is a Vercel detection workaround — not a real dependency of the npm package. Vercel's build system inspects the root package.json to detect the framework; without next present it falls back to a static build and skips the Next.js pipeline, breaking the /site subdirectory deploy.

The package itself has zero runtime dependencies. Do not remove this entry.


Future improvements

  • Axis-agnostic mode — support hovering any variable font axis, not just wght; e.g. hoverAxis: 'wdth', hoverValue: 125
  • ResizeObserver re-measurement — re-run compensation when the element's font-size changes on resize (e.g. with responsive clamp() typography), so the letter-spacing delta stays accurate at all viewport widths
  • Multi-weight cycles — hover through a sequence of weights rather than a single toggle (normal → semi-bold → bold → normal)
  • Bold-shift cleanup — expose a removeBoldShift(el) utility to remove the injected <style> rule and data-bold-shift attribute
  • Transition easing — expose the CSS transition-timing-function as an option alongside transitionDuration

Current version: v1.0.2