PHPackages                             nativephp/mobile-dialog - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. nativephp/mobile-dialog

ActiveNativephp-plugin[Utility &amp; Helpers](/categories/utility)

nativephp/mobile-dialog
=======================

Native alert dialogs and toast notifications for NativePHP Mobile

1.0.1(1mo ago)21.8k—10%1MITKotlinPHP ^8.2

Since Jan 19Pushed 1mo agoCompare

[ Source](https://github.com/NativePHP/mobile-dialog)[ Packagist](https://packagist.org/packages/nativephp/mobile-dialog)[ RSS](/packages/nativephp-mobile-dialog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Dialog Plugin for NativePHP Mobile
==================================

[](#dialog-plugin-for-nativephp-mobile)

Native alert dialogs and toast notifications for NativePHP Mobile applications.

Overview
--------

[](#overview)

The Dialog API provides cross-platform native alert dialogs and toast/snackbar notifications.

Installation
------------

[](#installation)

```
composer require nativephp/mobile-dialog
```

Usage
-----

[](#usage)

### Alert Dialogs

[](#alert-dialogs)

#### PHP (Livewire/Blade)

[](#php-livewireblade)

```
use Native\Mobile\Facades\Dialog;
use Native\Mobile\Events\Alert\ButtonPressed;

// Simple alert
Dialog::alert('Hello', 'Welcome to our app!');

// Alert with custom buttons
Dialog::alert('Confirm', 'Are you sure?', ['Cancel', 'Delete'])
    ->id('delete-confirm')
    ->show();

// Listen for button press
#[OnNative(ButtonPressed::class)]
public function handleButton($index, $label, $id = null)
{
    if ($id === 'delete-confirm' && $label === 'Delete') {
        $this->deleteItem();
    }
}
```

#### JavaScript (Vue/React/Inertia)

[](#javascript-vuereactinertia)

```
import { Dialog, On, Off, Events } from '#nativephp';

// Simple alert
await Dialog.alert('Hello', 'Welcome to our app!');

// Alert with custom buttons
await Dialog.alert('Confirm', 'Are you sure?', ['Cancel', 'Delete'])
    .id('delete-confirm');

// Listen for button press
const handleButton = (payload) => {
    const { index, label, id } = payload;
    if (id === 'delete-confirm' && label === 'Delete') {
        deleteItem();
    }
};

On(Events.Alert.ButtonPressed, handleButton);
```

### Toast Notifications

[](#toast-notifications)

#### PHP

[](#php)

```
use Native\Mobile\Facades\Dialog;

// Short toast (2 seconds)
Dialog::toast('Item saved!', 'short');

// Long toast (4 seconds) - default
Dialog::toast('Processing complete');
```

#### JavaScript

[](#javascript)

```
import { Dialog } from '#nativephp';

// Short toast
Dialog.toast('Item saved!', 'short');

// Long toast (default)
Dialog.toast('Processing complete');
```

Configuration Methods
---------------------

[](#configuration-methods)

### Alert Methods

[](#alert-methods)

#### `id(string $id)`

[](#idstring-id)

Set a unique identifier for the alert. Useful for identifying which alert triggered a button press.

```
Dialog::alert('Title', 'Message', ['OK', 'Cancel'])
    ->id('my-alert');
```

#### `event(string $eventClass)`

[](#eventstring-eventclass)

Specify a custom event class to dispatch when a button is pressed.

```
Dialog::alert('Title', 'Message')
    ->event(MyCustomEvent::class);
```

#### `remember()`

[](#remember)

Store the alert ID in session for retrieval in event handlers.

```
Dialog::alert('Title', 'Message')
    ->id('confirm-action')
    ->remember();

// Later, in event handler
$alertId = \Native\Mobile\PendingAlert::lastId();
```

#### `show()`

[](#show)

Explicitly display the alert. If not called, the alert shows automatically when the object is destructed.

```
Dialog::alert('Title', 'Message')->show();
```

### Toast Parameters

[](#toast-parameters)

ParameterTypeDefaultDescription`message`stringrequiredThe message to display`duration`string`'long'``'short'` (2s) or `'long'` (4s)Events
------

[](#events)

### `ButtonPressed`

[](#buttonpressed)

Fired when a button in an alert dialog is tapped.

**Properties:**

- `int $index` - The button index (0-based)
- `string $label` - The button label text
- `string|null $id` - The alert ID (if set)

#### PHP

[](#php-1)

```
use Native\Mobile\Attributes\OnNative;
use Native\Mobile\Events\Alert\ButtonPressed;

#[OnNative(ButtonPressed::class)]
public function handleButton($index, $label, $id = null)
{
    match($label) {
        'Delete' => $this->delete(),
        'Cancel' => null,
        default => null,
    };
}
```

#### Vue

[](#vue)

```
import { On, Off, Events } from '#nativephp';
import { onMounted, onUnmounted } from 'vue';

const handleButton = (payload) => {
    const { index, label, id } = payload;
    if (label === 'Delete') {
        deleteItem();
    }
};

onMounted(() => On(Events.Alert.ButtonPressed, handleButton));
onUnmounted(() => Off(Events.Alert.ButtonPressed, handleButton));
```

Platform Behavior
-----------------

[](#platform-behavior)

### Alert Dialogs

[](#alert-dialogs-1)

- **Android:** Native `AlertDialog` via `NativeActionCoordinator`
- **iOS:** Native `UIAlertController` with `.alert` style

### Toast Notifications

[](#toast-notifications-1)

- **Android:** Material Design `Snackbar` (positioned above bottom navigation)
- **iOS:** Custom `ToastManager` overlay

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Total

2

Last Release

59d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ab43d3432a80f0f41fe7015280f6024ff13fe8c2306cf114a1fbc91a4cd6f35?d=identicon)[simonhamp](/maintainers/simonhamp)

![](https://www.gravatar.com/avatar/16cc4d562d3f6f302901f1c65eb3ce819c0fb24ab2616241c605126102812ca4?d=identicon)[shanerbaner82](/maintainers/shanerbaner82)

---

Top Contributors

[![shanerbaner82](https://avatars.githubusercontent.com/u/5580860?v=4)](https://github.com/shanerbaner82 "shanerbaner82 (7 commits)")[![simonhamp](https://avatars.githubusercontent.com/u/31628?v=4)](https://github.com/simonhamp "simonhamp (3 commits)")

---

Tags

nativephpnativephp-mobilenativephp-plugin

### Embed Badge

![Health badge](/badges/nativephp-mobile-dialog/health.svg)

```
[![Health](https://phpackages.com/badges/nativephp-mobile-dialog/health.svg)](https://phpackages.com/packages/nativephp-mobile-dialog)
```

###  Alternatives

[paragonie/stern

Stern lets you built type-safe PHP projects, even if your project's users aren't writing type-safe code

201.5k1](/packages/paragonie-stern)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
