r/webdev • • Oct 17 '26

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

48 Upvotes

13 comments sorted by

4

u/kcure Oct 17 '26

looks cool thanks for sharing

2

u/ExpertPlay Oct 18 '26

thank you!

1

u/FPSectus Oct 19 '26

Great idea, it's going to make reading academic articles so much easier, you're my hero.

1

u/lepture full-stack Oct 18 '26

It looks clean and beauty. Thanks for sharing.

1

u/OkGoOn Oct 18 '26

as someone who highlights text when they read it, i loathe when sites add these features.

1

u/[deleted] Oct 18 '26

[removed] — view removed comment

0

u/ExpertPlay Oct 19 '26

thanks man, appreciate it! Yeah I went with localStorage by default to keep things simple (and lightweight haha) but yeah, that is a good idea, and I bet one could achieve this using the custom storage api https://www.penciled.org/recipes/rest-storage/
You could plug in something like https://remote.storage/

1

u/[deleted] Oct 17 '26

[removed] — view removed comment

1

u/ExpertPlay Oct 19 '26

thanks man. Yeah it is such a neat API