JSFiddle - React, Tailwind, and code Playground
HTML
<canvas id="canvas"></canvas>
JavaScript
var $canvas = jQuery('#canvas'),
context = $canvas[0].getContext('2d');
// Set absolute width and height values
$canvas
.css({
width: 300,
height: 300,
border: '1px solid black'
});
// Font style and color
context.font = "12pt Tahoma";
context.fillStyle = '#000000';
// Set some text
context.fillText('Hello World', 20, 20);
// Clear the full canvas using {fillStyle} color
context.fillStyle = '#FFFFFF';
context.fillRect(0, 0, $canvas.width(), $canvas.height());
// Set new text
context.fillStyle = '#000000';
context.fillText('Stackoverflow', 50, 50);