I am trying to display a list of all possible material icons so the user can select one to use on their website. My code needs to display all the material icons there are. I'm unsure how my code should correctly find the 'icon list'.
One way I could achieve this is to store an array of all possible values in a javascript file. So I would have an array like so: [..., 'restore', 'restore_from', ...]
. But that means I need to create an array 900 long and manually update it every time google releases more icons.
Another way is to iterate the hex codes, so I simply iterate values from DFD4
to E358
. This works (see code below) but some values are blank (see below image). So it's not a full-proof solution.
Do you know how I can list all material icons without having to manually build and maintain a list of icons?
Hex iteration technique:
var values = Array.from({length: 58200-57300},(v,k)=>57300+k);
$.each(values, function(i, iconId) {
iconId = '&#x' + iconId.toString(16) + ';';
var icon = $('<i class="material-icons" aria-hidden="true">'+ iconId +'</i>');
});