this post was submitted on 12 Feb 2024
100 points (98.1% liked)

Programming

17407 readers
70 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] DmMacniel@feddit.de 61 points 9 months ago (3 children)

It should show the current state, just like a checkbox shows if its option is enabled, an input box its current value etc. Everything else doesn't make sense.

[–] ptz@dubvee.org 21 points 9 months ago* (last edited 9 months ago) (3 children)

Exactly. A light switch* shows its current state, and toggle buttons are effectively an equivalent to that.

*Standard, two-way garden variety light switch

[–] nxdefiant@startrek.website 14 points 9 months ago (1 children)

I'd argue that a light switch has an indicator that shows the current state, separate from the switch.

[–] SmartmanApps@programming.dev 4 points 9 months ago

Not if the globe has blown out, in which case you need the switch to indicate which state it is in (unless you like to live dangerously and change globes in lights that may be still on :-) ).

[–] NewPerspective@lemmy.world 4 points 9 months ago (1 children)

Light switches are a bad example. Up doesn't mean on and down doesn't mean off when you have multiple switches for the same thing.

These switches visibly have 2 states and switching it means you want the other one. In tech it's less obvious that there are only two states and that toggling the button will do something in particular. Recall the play and pause button on your media app. That button could change the state in any number of ways but in order to convey to the user what will happen BEFORE the button is pressed, the player shows what action will take place.

You're already in the current state, that rarely adds info. Toggles should indicate what they will do.

[–] ptz@dubvee.org 1 points 9 months ago

When I think "toggle" switch, I think in terms of binary states: on or off. Which is why I used a light switch as an example rather than a media play/pause button which can have multiple states. In that scenario, yes, it would be more intuitive for the button to display the action it will perform.

Up doesn't mean on and down doesn't mean off when you have multiple switches for the same thing.

A close-up of a light switch showing the label for off

[–] karlhungus@lemmy.ca 3 points 9 months ago (1 children)

In my experience only kinda, and by convention (up is on), and three-way switches break this (indicator becomes the light itself).

[–] abhibeckert@lemmy.world 4 points 9 months ago* (last edited 9 months ago)

That's not the convention in my country. Up is off here. And no switches have labels either.

[–] BrianTheeBiscuiteer@lemmy.world 13 points 9 months ago (2 children)

Without seeing an example I would've said a button (actual button, not a checkbox or slider) should show the future state. If a button says "Cancel" I would expect the state to go from a pending state to a cancelled state. Same with a button that says "Submit". So if it's some kind of toggle, like play/pause, I would think hitting ⏸️ means I'm currently playing and I want to pause.

[–] DmMacniel@feddit.de 10 points 9 months ago

Buttons don't show what is currently happening, but what action, with the provided user input via toggles, input boxes, checkboxes if any, should be taken. In your example, your Cancel Button should Cancel the transaction.

[–] SmartmanApps@dotnet.social 2 points 9 months ago

@BrianTheeBiscuiteer @DmMacniel
I see now there's some confusion. When it said "toggle button", I thought a Switch was being discussed, but when I clicked on the OP I see it actually does mean button, so we've got some people talking about switches and some people talking about buttons (and yeah, a switch should show current state, but a button should show what would happen if you clicked it).

[–] SmartmanApps@programming.dev 3 points 9 months ago (1 children)

This would be correct if the post was about switches (which TBF many people made that mistake, including me initially), but it's about buttons - buttons should show what action will result from clicking on them. e.g. "Cancel" on a button which is going to cancel your process. For a play/pause button it should show play if you're paused (if I click on this it will start playing) and pause if you're playing (if I click on this it will pause).

[–] DmMacniel@feddit.de 1 points 9 months ago* (last edited 9 months ago) (1 children)

oh yeah true, I was thinking of toggle buttons instead of buttons that keep their state/don't release: like the formatting buttons (bold, italic, underline, ...) in a word processor. The latter strangely are also named ToggleButtons so that's a big confusion.

[–] SmartmanApps@programming.dev 1 points 9 months ago

Yeah, the wording isn't clear, and some people are talking about switches and some people are talking about buttons. I work with MAUI, and in MAUI a "ToggleButton" is called a Switch, so there's no confusion there, but the OP specifically said a button which toggles. i.e. a button which has 2 states instead of just one. A play button which turns into a pause button when you press it and vice-versa. I think the OP may have been confused between switches and buttons themselves - which are indeed labelled in opposite ways to each other (switch - current state, button - state that it will cause to happen when pressed) - which led to the question.