β¨ Universal, customizable alerts and prompts for React Native β identical API to the built-in Alert, but works seamlessly across iOS, Android, and Web.
- Cross-platform β iOS, Android, Web with one API
- Drop-in replacement β same API as
Alert - Prompts everywhere β text input prompts supported on all platforms
- Modern Web implementation β built with
<dialog>+ CSS custom properties - Dark/light themes β automatic with manual override
- Accessible β full keyboard navigation + screen reader support
- TypeScript ready β complete type definitions
npm install @blazejkustra/react-native-alertNo extra setup needed on iOS or Android (just rebuild your app). On Web, styles are injected automatically and can be customized with CSS variables.
import Alert from '@blazejkustra/react-native-alert';
Alert.alert('Hello!', 'This is a cross-platform alert.');Alert.alert(
'Confirm',
'Do you want to continue?',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'OK', style: 'default' },
]
);Alert.alert(
'Delete item?',
'This action cannot be undone.',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'Delete', style: 'destructive' },
]
);Alert.prompt(
'Enter your name',
'Please type your name below:',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'OK', onPress: (value) => console.log('Name:', value) },
],
'plain-text',
'John Doe'
);Alert.prompt(
'Password',
'Enter your password:',
[
{ text: 'Cancel', style: 'cancel' },
{ text: 'OK', onPress: () => console.log('Password entered') },
],
'secure-text'
);For more examples, see example/src/App.tsx.
Same as React Native Alert.
- iOS β uses React Native's built-in
Alert.alertandAlert.prompt - Android β uses React Native's built-in
Alert.alertand custom native module with Material styling forAlert.prompt - Web β HTML5
<dialog>, themeable via CSS variables
Override CSS variables to match your design system:
:root {
--rn-alert-accent: #059669; /* Primary button */
--rn-alert-danger: #dc2626; /* Destructive button */
--rn-alert-bg: #fefefe; /* Dialog background */
--rn-alert-fg: #111827; /* Text color */
--rn-alert-radius: 16px; /* Border radius */
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme]) {
...
}
}Available variables:
--rn-alert-bgβ dialog background--rn-alert-fgβ primary text color--rn-alert-mutedβ secondary / muted text--rn-alert-surfaceβ input & surface background--rn-alert-borderβ border color--rn-alert-elevβ box shadow / elevation--rn-alert-accentβ primary button color--rn-alert-accent-hoverβ primary button hover color--rn-alert-dangerβ destructive button color--rn-alert-danger-hoverβ destructive button hover color--rn-alert-radiusβ border radius (dialogs/buttons)--rn-alert-radius-smβ small border radius (inputs/buttons)--rn-alert-spacingβ default padding--rn-alert-spacing-smβ small padding--rn-alert-btn-minβ minimum button height (touch target)--rn-alert-outlineβ focus outline style--rn-alert-outline-weakβ subtle focus outline--rn-alert-fontβ font family--rn-alert-font-sizeβ base font size--rn-alert-title-sizeβ title font size
We welcome contributions! See CONTRIBUTING.md for workflow and CODE_OF_CONDUCT.md.
MIT Β© Blazej Kustra
Built with create-react-native-library π
