Linecove

Linecove

A cove is the inward corner of a text highlight, where a shorter line steps in from a longer one. Customize the color and radius. Try it out below.

Code Text

without rounding

with rounding

Installation

The package is ESM and includes TypeScript types. It has no runtime dependencies.

npm install linecove

Usage

Attach it to an element. The browser selection stays in place, so copy and paste still work. Inside that element, the native highlight is hidden and Linecove draws the rounded shape instead. Call destroy() when the element goes away.

import { attachLiveSelection } from "linecove";

const article = document.querySelector("article");
if (!article) throw new Error("Missing article");

const highlight = attachLiveSelection(article, {
  radius: 6,
  color: "#ADD6FF",
  paddingInline: 1,
});