HoldButton
Requires a deliberate hold before confirming an action.
When to use
- Add a deliberate step to an action that is hard to undo.
Examples
Confirm by holding
Loading the example
<k:HoldButton text="Hold to confirm" doneText="Confirmed" confirm=".onConfirm"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.BasicHold", {
onConfirm() {
Toast.show("Action confirmed");
}
}));Release a shipment
Loading the example
<k:Stack gap="10">
<k:Text text="{/status}"/>
<k:HoldButton id="release" text="Hold to release" doneText="Released" icon="truck" duration="1200" confirm=".onRelease"/>
<k:Button kind="ghost" text="Reset example" press=".onReset"/>
</k:Stack>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.ReleaseHold", {
onRelease() {
this.getView().getModel().setProperty("/status", "Shipment SH-104 is ready for pickup.");
Toast.show("Shipment released");
},
onReset() {
this.byId("release").setDone(false);
this.getView().getModel().setProperty("/status", "Shipment SH-104 is awaiting release.");
}
}));Keyboard
- Space
- Hold until the action is confirmed.
- Enter
- Press twice while focus stays on the button.
API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
text | string | Button text | |
doneText | string | Text after confirmation | |
icon | string | check | Icon name |
duration | int | 900 | Hold time in milliseconds |
done | boolean | false | Whether the action has been confirmed |
enabled | boolean | true | Whether the button can be used |
Events
| Name | Type | Description |
|---|---|---|
confirm | The action was confirmed |