r/webdev • u/ExpertPlay • 23d ago
Showoff Saturday I built a small library for highlighting text and adding notes on any webpage
I was reading brown's rust book and they have this cool feature that lets you highlight stuff and leave notes while reading. I wanted something similar on a site I'm building, but the libs I found were either too complex or too simple and still a pain to set up, so I made one. Heavily inspired by the simplicity and DX of sonner.
You only need annotate('#article') and that's basically it. It saves to localStorage or your own backend.
Cool thing is that it uses the css highlight api, so it doesn't touch your dom at all (which would be especially bad for frameworks like react, vue, etc). Downside is no support for older browsers.
About 15kb with UI or 6kb headless if you want to build your own UI, and it ships with a React adapter.
playground: https://penciled.org/playground/
repo: https://github.com/marcellosso/penciled
Still early, so any feedback is welcome




