-
-
Notifications
You must be signed in to change notification settings - Fork 78.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Checkbox button #24040
Comments
Hi @pnxsaz
What you are describing is a radio input not a checkbox. That behaviour is build in HTML. I don't think checkboxes have hover state. Sorry I must be completely lost with your usecase |
Behaviour is similar as radio button but allows to unselect. There is an example at stackoverflow link. Component is https://getbootstrap.com/docs/4.0/components/buttons/#checkbox-and-radio-buttons. |
I can understand the "allow to have either none or only one selected" use case (only way to do this with radio buttons is to have a neutral extra radio button acting as the "none"). Not sure how clear it would be to users, unless it's made explicit with the label/legend for the group |
Not with radio but with checkbox button. Here is one more example from stackoverflow http://jsfiddle.net/X597P/ |
@pnxsaz that fiddle uses 3 lines of bootstrap compatible javascript to accomplish that. real-world code would contain just a bit more code to limit the unselecting to the same checkbox group |
Ok, I get it now the "allow to have either none or only one selected". Thanks a lot for the clarification. Do you guys think this use case is common enough that it should belong in Bootstrap? @pnxsaz To be honest I never had to deal with it that's why I might be biased, but I think this makes a perfect case for a bootstrap plugin project. Your example seems to me the same as this: None is selected, unless you select one, right? why would you use checkboxes for something that is a radio btn. |
@andresgalante those are radio buttons, I meant checkbox. There is already button.js file/plugin which could be little bit changed and extended to add possible option. |
Yeap I got it, you want to make checkboxes behave like radios. My point is don't do it and this does not belong in bootstrap. Hacking HTML just because, is wrong. |
You can make radio buttons look like checkboxes with custom forms, change |
@andresgalante radio buttons will have one extra button to behave as non selected as you created the example. Checkbox buttons will not have that extra button. However the outcome is the same. There is similar discussion at stackoverflow link I provided in comment section in which I don't wish to go into 😉 Sometimes designers or developers wish to do something bit different. Is the number of views on that stackoverflow question relevant for this to be included I'm not sure. It's just a suggestion. @bkdotcom just an example to try describing behaviour. |
Please, don't add this feature to Bootstrap. |
@alecpl agreed. For a framework that agonizes whether or not to change the cursor on button hover, this doesn't belong. |
How about using validation? Think about the more generalized case where you have multiple options but only certain combinations are possible; if the number of combinations is low you could do radio buttons for each one of them but otherwise checkboxes with validation might be the only sensible way. |
This can be easily achieved with Angular Forms Validation. Somehow |
Will close this one as it seems to be too specific or confusing for user. Active/hover effect belong to different issue. Thanks for your feedback. |
Hello,
is there a plan to add support for - only select one checkbox in group?
https://stackoverflow.com/questions/9709209/html-select-only-one-checkbox-in-a-group
Also what do you think about changing colors for active/hover btn checkbox? They are the same now and it's not easy to differentiate is checked or not on hover when clicking.
Thanks
The text was updated successfully, but these errors were encountered: