I believe it can't be done with standard shiny. You can try to apply some css/js magic if you know it (e.g., turn not selectable items to red color and give a message to user if they chose it anyways, or maybe you can directly disable clicking on them with js/css, not sure, see sendCustomMessage()
).
Another option would be to use updateSelectInput()
to discard not needed items from the dropdown when you need it.
update:
I did a quick search on it -- as I can see it is doable with html option disabled
, e.g.
<select>
<option value="volvo" disabled>Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi">Audi</option>
</select>
All you need to do is to generate shiny's selectInput
on the server (probably with renderUI()
) and add that disabled
option to the elements you need to disable