问题
What is the difference between a toggle button and switch? As they provide same feature, what is the specific use case to use a toggle button or a switch?
Toggle button:
Switch:
回答1:
This is more of a User Experience question than just Coding. Here is my answer:
The description of the control says it:
Toggle is a button : sap.m.ToggleButton
whereas
switch is a user input. sap.m.Switch
However, the main difference lies in the User Experience and usage.
Here is what the Fiori Guideline says: When to use Switch
- You need to emphasize the On/Off characteristic within a dialog.
- You need to clearly show the mode or state that a setting is in.
- You need a toggle switch for binary settings when changes become effective immediately after the user changes them. For example, if the user needs to set data transmission or accept/reject business objects.
vs
Behavior of Buttons
To summarize, I can say: Switch primarily represents a state(a physical state like a fan "On' or "Off") and the text should not be too big.
whereas, a button is an action mostly a verb which user performs and this can be a longer text like "Activate
You can read a little more on the difference based on UX with an example: Difference between switch and toggle
来源:https://stackoverflow.com/questions/50525778/difference-between-toggle-button-and-switch