TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Bootstrap Toggle Buttons

181 点作者 fox91超过 12 年前

23 条评论

carsongross超过 12 年前
Dude, these are great, ignore the haters. People understand slider toggles and, for top level, high value on/off values or mobile versions of a UI these will be fine.<p>Just keep polishing them and getting them cross browser. I'll be forking the project and using them.
评论 #4595043 未加载
评论 #4595256 未加载
jorde超过 12 年前
I would strongly advice against using these. While these type of toggle switches work great on mobile, they can we really confusing on desktop/mobile web: where does one click to change state, which state is active etc.<p>Matt Gemmell wrote a good post about toggle switches some time ago: <a href="http://mattgemmell.com/2011/11/01/on-off-switches/" rel="nofollow">http://mattgemmell.com/2011/11/01/on-off-switches/</a>
评论 #4595244 未加载
mybuddymichael超过 12 年前
Please don't use these. I've seen too many mobile users get confused by these sliders, wondering why they can't manually slide them.
评论 #4594645 未加载
评论 #4594630 未加载
评论 #4594655 未加载
评论 #4594775 未加载
latchkey超过 12 年前
I had toggles like this on my site and found that a checkbox was a lot less confusing. It is just too hard to tell if state is successfully saved and if clicking things turns it on or off.<p>The behavior I ended up implementing is... when the box is clicked, it is immediately hidden and replaced with a loading animation while the ajax request is hitting the server saving state. When that finishes, it shows a icon-thumbs-up for a second and then the checkbox again (either checked or unchecked).
评论 #4595187 未加载
notJim超过 12 年前
I'm wary of these, because form elements tend to be very, very very veryvery platform-dependent, and users (like me!) develop expectations about how toggles (i.e., checkboxes) should behave on the platform they're using.<p>I know this isn't your intent, but when the behavior of something like this fails to match my expectations, it is extra irritating, because I feel the author thought having something pretty and iOS-looking was more important than it being usable for me. Either that, or else s/he decided that I'm too stupid to know what I like, and decided to shove an iOS form-control down my throat.<p>That being said, I must admit that these are visually gorgeous, and their behavior seems pretty excellent at first blush. (But again, I am unsure how I will feel once I start seeing them pop up and inevitably being <i>even slightly</i> misused in the wild. I also haven't tried them on my phone yet.)
dreamdu5t超过 12 年前
Please package this as a Component for better interoperability and modularity.<p><a href="https://github.com/component/component" rel="nofollow">https://github.com/component/component</a> <a href="https://github.com/component/component/wiki/F.A.Q" rel="nofollow">https://github.com/component/component/wiki/F.A.Q</a><p>Twitter bootstrap isn't modular or supported by a package manager.
jfarmer超过 12 年前
Funny. I just started using these.<p>The assumption that the "toggle" is 50% of the width is hard coded into the library. I went to change it and, holy cow, the code is a mess.<p>I got it to work, but had to disable the click-and-slide behavior.<p>Be warned if you decide to change any of its behavior!
a904guy超过 12 年前
Looks great.<p>Two things,<p>#1: If you modify the attribute checked of the input, the state doesn't change.<p>#2: I don't see a programmatic way of changing the state from your source without re-initializing all the elements?
评论 #4595851 未加载
markdotto超过 12 年前
Mattia DMed me about this earlier today asking if it could be included in the Bootstrap core. For the time being, I've decided against it as it's another custom form element and we're not implementing anything like that at this point.<p>That said, if any iOS style switches were done very well, we can explore adding them down the line. I'm not against them 100%, but custom form elements can get tricky. I'm not going to discourage their development—tons of folks have created their own implementation of this. I look forward to them improving over time.<p>Looking at this again, I'll try to shoot him some feedback so he can improve them and we can get closer to a solution that's fit for the Bootstrap core.
zachinglis超过 12 年前
I'm mixed on using these buttons. I've seen people in user research tests use them well, and then I've seen people use them horribly in such a situation too. However, there are times when they're perfectly acceptable.<p>I've forked and pull requested.<p>The background states were light at the top and darker at the bottom giving a button feel, rather than an inset feel. :)
hayksaakian超过 12 年前
These are terrible for ui/ux. not only do they not behave as you would expect, by actually sliding Them, but this pattern is inconsistent with mobile ui native to both IOS and especially android recently where they actually slide.
arrowgunz超过 12 年前
So sad to see people discouraging the effort.
J-H超过 12 年前
Someone should come up with an unofficial list of all these bootstrap additions. They're really great, but I always forget about them when I'm actually get to doing work.
评论 #4596085 未加载
评论 #4637133 未加载
dmix超过 12 年前
Ugh I hate these on airbrake. They never work properly.
shtylman超过 12 年前
It seems to me that the on state of the button should have the outline around the blue area (of the default button) also be blue instead of gray. Keeping the border gray when the slider goes to "on" gives the button the wrong appearance. The blue area doesn't look like it has been uncovered but instead looks like a tab sticking out of the side.
maytc超过 12 年前
Awesome, one suggestion I would make is that the buttons should ignore input in when translating between on and off. It seems awkward that it will just keep switching on and off even though I have stop giving it input, or accidentally double clicking on it and set it back to what ever it was.
评论 #4598243 未加载
ryduh超过 12 年前
For some reason, I had expected this to be default in Bootstrap. Thanks for posting this
评论 #4595766 未加载
Tyr42超过 12 年前
I've managed to break it and get a few pixels of pink showing through at the corners in OSX Chrome. <a href="http://imgur.com/9jT7m" rel="nofollow">http://imgur.com/9jT7m</a> Look good otherwise
ripperdoc超过 12 年前
Looks nice, can you set their color and apperance using clases in the same way as normal Bootstrap buttons, e.g .btn .btn-primary, etc?
javajosh超过 12 年前
Dear Matias, why do you require us to put a div around the input? Why not just make this targetable by class?
j45超过 12 年前
Very nice. I wish these were in the core bootstrap to let people who need to use them, use them.
MatthewPhillips超过 12 年前
I would recommend getting rid of the styling options and let people style in their own CSS.
评论 #4595124 未加载
antidaily超过 12 年前
Interesting. I always expected the way to do this was with radio buttons.
评论 #4594774 未加载
评论 #4594637 未加载