Hold Confirm
React Native (Expo)
A React Native press and hold button for risky actions that fills while held and drains back if released early.
A button for actions that should not happen by accident, such as deleting an account. A colour fills the button while it is held and the action runs when it is full; letting go early drains it back and nothing happens. Because holding is hard for some people, a screen reader's activate action and the Enter key on the web run the action straight away. Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add hold-confirmManual
- Copy the code from the component tab.
- Create a file at
components/ui/hold-confirm.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | - | The button's text. |
onComplete | () => void | - | Called once when held long enough or activated. |
duration | number | 1200 | How long to hold, in milliseconds. |
doneLabel | string | "Done" | Text shown after it completes. |
colors | Partial<HoldConfirmColors> | - | Overrides background, fill and text. |
style | StyleProp<ViewStyle> | - | Style for the button. |
Comments