1. Go to this page and download the library: Download nativephp/mobile-ui library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nativephp / mobile-ui example snippets
use Native\Mobile\UI\Facades\NativeUI;
// Execute functionality
$result = NativeUI::execute(['option1' => 'value']);
// Get status
$status = NativeUI::getStatus();
use Livewire\Attributes\On;
#[On('native:Native\Mobile\UI\Events\NativeUICompleted')]
public function handleNativeUICompleted($result, $id = null)
{
// Handle the event
}
use Native\Mobile\UI\Elements\Button;
Button::make()
->icon('plus')
->a11yLabel('Add item')
->a11yHint('Adds a new item to the list')
->onPress('addItem');
public function onCaretMove(string $text, int $selectionStart, int $selectionEnd)
{
// $selectionStart === $selectionEnd when the caret is a plain cursor;
// they differ when a range of text is selected.
}
use Native\Mobile\UI\Elements\OutlinedTextInput;
OutlinedTextInput::make()
->label('Message')
->onSelectionChange('onCaretMove')
->selectionDebounceMs(100);
public function onCaretMove(string $text, int $start, int $end)
{
// Look backwards from the caret for an "@mention" trigger.
$before = mb_substr($text, 0, $start, 'UTF-8');
if (preg_match('/@(\w*)$/u', $before, $m)) {
$this->showMentionSuggestions($m[1]);
} else {
$this->hideMentionSuggestions();
}
}
use Native\Mobile\UI\Elements\DatePicker;
DatePicker::make()
->label('Appointment')
->mode('datetime')
->value($this->appointmentAt) // string or any DateTimeInterface
->min('2026-01-01')
->timezone('Europe/Berlin')
->locale('de-DE')
->onChange('appointmentChanged');
->mode('date')->value('2026-07-25T14:30:59Z') // serializes as 2026-07-25
use Illuminate\Config\Repository;
use Illuminate\Container\Container;
use Native\Mobile\UI\Theme;
it('normalizes tokens and mirrors them into config', function () {
Container::getInstance()->instance('config', new Repository);
try {
Theme::load([
'light' => ['primary' => 'red-300', 'accent' => '#8B5CF680'],
'dark' => ['primary' => 'red-800'],
]);
// Normalized tokens are readable via Theme::get('mode.token'):
expect(Theme::get('light.primary'))->toBe('#FCA5A5'); // palette name
expect(Theme::get('light.accent'))->toBe('#808B5CF6'); // CSS alpha → wire ARGB
// …and mirrored back so core's theme() helper reads wire-format hex:
expect(config('native-ui.theme.light.primary'))->toBe('#FCA5A5');
expect(config('native-ui.theme.dark.primary'))->toBe('#991B1B');
} finally {
Container::setInstance(null);
}
});
use Native\Mobile\Edge\CallbackRegistry;
use Native\Mobile\UI\Elements\Button;
it('serializes typography props on an element', function () {
$props = Button::make('Save')->font('Inter-Bold')->toArray(new CallbackRegistry)['props'];
expect($props['font_name'])->toBe('Inter-Bold');
});
use Native\Mobile\JumpBridge;
use Native\Mobile\UI\Theme;
beforeEach(function () {
JumpBridge::instance()->mute();
Theme::reset();
});
afterEach(fn () => Theme::reset());