I'm wondering if there is a possibility to create something like "selectIcon" in shiny. I would like to have a selecter with only icons or e.g. colours.
selectizeInput('colours', '',
choices = c("blue", "red"),
selected = "blue")
But insead of words "blue" and "red" I would like to display colored squares. This should be also the case for selected option. Let's say that I have .png
files for all my options. How can I include these files in selectizeInput()
?
This is a very similar question to this one however there was no working solution for me as I have no knowledge of js.
I tried something like this
selectizeInput('colours', '',
choices = c("blue", "red"),
selected = "blue",
options = list(render = I(
"{
option: function(item, escape) {
return '<div><img src=\"item.png\" width = 20 />' + escape(item.name) + '</div>'
}
}"))
but without any success. The options are now undefined
. No figures are displayed.
I appreciate any help.