I have a button group on a page that is used for a selection. After the selection is made I want the button group to still be visible so the user can see the selection they made, but I don't want them to be able to use it anymore. Is there a way to disable to the button group?
<div class="btn-group-vertical">
<button type="button" class="btn btn-primary btn-lg">Option 1</button>
<button type="button" class="btn btn-primary btn-lg">Option 2</button>
<button type="button" class="btn btn-primary btn-lg">Option 3</button>
</div>
I wanted to keep the styling too, So I left out the disabled field and just counter-acted the CSS with a new class
display-only
:And the CSS:
..Seems to work well for me.
Before v4.0.0, Bootstrap Toggle buttons do not honor .disabled or [disabled] :
https://github.com/twbs/bootstrap/issues/21237
You can use the disabled attribute on the buttons to disable their use, as described in the Bootstrap docs. It essentially involves adding the attribute 'disabled' to the button element, like so;
You can use jQuery to dynamically add this attribute once you've done whatever you want to do
And if you wanted to re-enable it
Bear in mind that the above would apply this behaviour to all button groups with this class name. If you don't want that you'll need to add an ID to the btn group div and use that in the jQuery selector.