Skip to content
Ballpoint

Margin Note

A handwritten aside out in the margin, with an arrow (or a line) drawn to the words it's about, and the words themselves underlined, circled, boxed or highlighted; under the line on narrow screens.

Only in Ballpoint

Every box is drawn as four pulls of the pen, and the corners crosstook three tries to get right the way they do when you sketch one quickly. The seed keeps the wobble the same on the server and in the browser.

Installation

pnpm dlx shadcn@latest add @ballpoint/margin-note

Usage

tsx
import { MarginNote } from "@/components/ui/margin-note"

<p className="max-w-xs">
  Every box is drawn as four pulls, and{" "}
  <MarginNote note="took three tries">the corners cross</MarginNote>.
</p>

Examples

Left, and in red

Flip the side, or use red for a correction.

This notethe other margin sits on the left, where the first words of a line leave room for it.

Use red for a correction: the figure was 4,000check this!, not 400.

In an essay

Notes along a paragraph, one in ink and one in red pen.

A good pen is one you forget you are holdingnot the expensive one. It starts on the first try, writes as fast as you think, and leaves a line you would not mind being read incheck this! ten years. The paper matters just as much.

Marking the words

mark underlines, circles, boxes or highlights what the note is about, in the note's colour.

The note can underline the wordsunderlined.

Ada Lovelaceringed, for a name gets a ring.

A highlight for 14 Octoberthe date.

And a box round the 4,000check the figure.

Arrows, lines, none

The pointer drawn as an arrow, a plain line, or left out; and the note tilted the other way.

The default is a curved arrowpointer="arrow" to the words.

Quieter still is a plain linepointer="line", tilted the other way.

And with nothing between them, a mark does the workno pointer, in pencil.

A review

Notes on a draft, in ink, red pen and pencil, each with its own mark and width.

Launch post, draft 2

  • We are proud to announcegood opening a library drawn by hand.
  • It ships in Novemberstill right?.
  • With forty componentsask legal to start.

API reference

note
ReactNode

What's written in the margin.

side
default "right"
"left" | "right"

Which margin. Below lg the note drops in under the line instead.

color
default "ink"
"ink" | "red" | "pencil"

The ink, the red pen for a correction, or pencil, lighter and slanted.

className
string

Styles the note; --margin-note-width (9rem) and --margin-note-gap (2.5rem) set its size and distance.

pointer
default "arrow"
"arrow" | "line" | "none"

What is drawn from the note to the words: a headed arrow, a plain line, or nothing.

mark
default "none"
"none" | "underline" | "circle" | "box" | "highlight"

A mark drawn on the words themselves, in the note's colour (it uses Annotate).

tilt
default -1.5
number

Degrees the note is turned from level.

width
default "9rem"
string

How wide the note is out in the margin, as a CSS length.

seed
string | number

Pins the drawing.

Pen settings

The drawing also takes draw, weight and speed, as props or from the nearest InkProvider. What each one does.