JSFiddle - React, Tailwind, and code Playground

JavaScript

var allocated = 5; // default 5MB allocation
var total = 0;
for(var x in localStorage) {  
    var amount = (localStorage[x].length * 2) / 1024 / 1024;  
    total += amount;  
}
var remaining = allocated - total;
console.log( 'Used: ' + total + ' MB');
console.log( 'Remaining: ' + remaining + ' MB');