A Fabric.js post-it note extension.

Include the fabric.postit.js script file after fabric.js:
...
<script src="lib/fabric.js"></script>
<script src="dist/fabric.postit.js"></script>
(A minified version is also available: dist/fabric.postit.min.js)
A note can be initialized with its initial text content and additional arguments:
const note = new fabric.Postit('hello world', {
width: 200,
height: 200,
top: 20,
left: 20,
fontFamily: 'Arial, Helvetica',
noteColor: '#00ff4c',
stripColor: '#00cc3d'
})
Properties can be altered like so:
note.set('fontSize', 30)
note.set({ noteColor: 'yellow', stripColor: 'red' })
fabricCanvas.requestRenderAll()
The following custom properties can be read and changed.
StringThe text to display on the Post-it Note.
Number10The padding between the box and text, in pixels.
Stringcenterleft, center, rightThe text alignment.
StringSans-serifThe font family.
Number20The font size.
Stringnormalnormal, italic, onbliqueString400The font weight. Either a number (400, 700, 900) or a string (normal, bold etc).
String#000The text color.
String#ffffaaThe note’s background color.
Number5The border-radius of the bottom-left and bottom-right corners of the note.
Number30The height of the sticky strip on top of the note, in pixels. Use 0 for no sticky strip.
String#ffff00The background color of the sticky strip.
The Postit is actually a group consisting of three elements, which can be accessed as properties:
Postit.tbox → fabric.TextboxPostit.note → fabric.RectPostit.strip → fabric.RectIf you like what I’ve made here, you can sponsor me with a donation. Thank you so much!
This plugin is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with the code. More Information
The development of this component was funded by Zygomatic.