Forces a NativePHP Mobile app into light or dark mode independent of the OS setting, or releases it back to following the system automatically.
bg-theme-*/text-theme-* classes already resolve their dark companion
natively based on the OS color scheme — there is no PHP-facing API to override
that, only to read it (Native\Mobile\Facades\System::appearance()). This
plugin adds the missing write side.
nativephp/mobile^3.0 or ^4.0- iOS 15.0+ — fully supported via
UIWindow.overrideUserInterfaceStyle. - Android — requires API 31+ (
UiModeManager.setApplicationNightMode, the only per-app override Android exposes outside ofAppCompatActivity). Below API 31,setMode()silently no-ops rather than partially applying.
composer require smronju/nativephp-appearance
php artisan vendor:publish --tag=nativephp-plugins-provider
php artisan native:plugin:register smronju/nativephp-appearanceThen rebuild: php artisan native:run.
use Smronju\NativephpAppearance\Facades\NativephpAppearance;
NativephpAppearance::setMode('dark'); // force dark
NativephpAppearance::setMode('light'); // force light
NativephpAppearance::setMode('system'); // follow the OS againFire-and-forget: there's no event to listen for, and no result to branch on — either the override applies (iOS always; Android on API 31+) or the call is a safe no-op (Android below API 31).
MIT