nativeblade/ui-mobile 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nativeblade/ui-mobile

Composer 安装命令:

composer require nativeblade/ui-mobile

包简介

Mobile UI components for NativeBlade. Konsta-style iOS and Material 3 Blade components that auto-switch theme based on the running platform.

README 文档

README

Konsta-style iOS and Material 3 components for NativeBlade apps. Pure Blade, pure Tailwind, no JS framework dependency. Components auto-detect the host platform via NativeBlade::isIos() / NativeBlade::isAndroid() and render the matching look.

Install

composer require nativeblade/ui-mobile

The service provider auto-registers via Laravel package discovery.

Required: tell Tailwind to scan the package

This is the most important setup step. Tailwind 4 only generates classes it sees in scanned source files. Open your project's resources/css/app.css and add this line near the other @source entries:

@source '../../vendor/nativeblade/ui-mobile/resources/views/**/*.blade.php';

Without this line, components render but most utility classes (colors, dynamic widths, etc.) come out unstyled or transparent because Tailwind never sees them.

Recommended: extend the safelist for opacity modifiers

NativeBlade's stub tailwind-safelist.css already covers solid colors and spacing. The ui-mobile components additionally use opacity modifiers (bg-black/50, bg-{color}/15) and a few arbitrary font sizes. If you started a new NativeBlade project recently the stub already includes these. If your app.css predates the update, add this section:

@source inline("bg-black/{5,10,15,20,25,30,40,50,60,70,80,90}");
@source inline("bg-white/{5,10,15,20,25,30,40,50,60,70,75,80,85,90,95}");
@source inline("{bg,text,border}-{slate,gray,zinc,neutral,stone,red,orange,amber,yellow,lime,green,emerald,teal,cyan,sky,blue,indigo,violet,purple,fuchsia,pink,rose}-{500,600}/{5,10,15,20,30,40,50}");
@source inline("text-[10px]");
@source inline("text-[11px]");
@source inline("text-[13px]");
@source inline("text-[15px]");
@source inline("text-[17px]");
@source inline("{backdrop-blur-none,backdrop-blur-sm,backdrop-blur,backdrop-blur-md,backdrop-blur-lg,backdrop-blur-xl}");

Configure (optional)

Publish the config to override defaults:

php artisan vendor:publish --tag=nb-ui-mobile-config
return [
    'theme' => 'ios',
    'force' => false,
    'colors' => [
        'ios'      => ['primary' => 'blue-500',   'primary_text' => 'white'],
        'material' => ['primary' => 'indigo-600', 'primary_text' => 'white'],
    ],
];

Usage

<x-nb-mobile::page>
    <x-nb-mobile::navbar title="Profile" />

    <x-nb-mobile::list inset title="Account">
        <x-nb-mobile::list-item title="Email" subtitle="you@example.com" />
        <x-nb-mobile::list-item title="Plan" after="Free" href="/upgrade" />
    </x-nb-mobile::list>

    <div class="px-4 mt-4">
        <x-nb-mobile::button block>Continue</x-nb-mobile::button>
    </div>
</x-nb-mobile::page>

On iOS, the button is rounded with iOS sizing. On Android, Material 3 pill with shadow. Same Blade markup.

Per-component theme override

<x-nb-mobile::button theme="material">Always Material</x-nb-mobile::button>
<x-nb-mobile::card theme="ios">Always iOS</x-nb-mobile::card>

Triggering modals

Place the modal anywhere in the page (drawer, sheet, popup, action-sheet, toast, popover). To open or close, call the global nb.* helper from any element:

<button onclick="nb.open('drawer','main-menu')">Menu</button>
<button onclick="nb.close('drawer','main-menu')">Close</button>
<button onclick="nb.toast('saved','File saved!')">Save</button>
<button onclick="nb.popover('more', this)">More</button>

API:

  • nb.open(kind, id, extra?) opens a drawer / sheet / popup / action-sheet
  • nb.close(kind, id?) closes (id optional, closes any of that kind)
  • nb.toast(id, message, opts?) triggers a toast with a message
  • nb.popover(id, anchor) opens a popover anchored to an element

Components

Each component has its own doc page in docs/. Quick reference:

Layout: page, navbar, tabbar, drawer, toolbar, fab

Containers: card, block, list, menu-item, sheet, popup, action-sheet, popover, tabs

Inputs: input, searchbar, checkbox, radio, toggle, stepper, range, segmented, file-upload

Display: button, chip, badge, avatar, link, icon, preloader, progressbar, skeleton, toast, tooltip, empty-state

Behaviour: pull-to-refresh

Customization

Class merge (most common):

<x-nb-mobile::button class="bg-purple-500 hover:bg-purple-700 shadow-2xl">Custom</x-nb-mobile::button>

Color, variant, size, etc. as props:

<x-nb-mobile::button color="emerald-500" variant="tonal" size="large" rounded block>
    Big rounded green tonal
</x-nb-mobile::button>

Force theme globally: edit config/nb-ui-mobile.php with 'force' => true, 'theme' => 'material'.

Fork a component (full control of markup):

php artisan vendor:publish --tag=nb-ui-mobile-views

Files land at resources/views/vendor/nb-ui-mobile/components/. Laravel uses these instead of the package versions.

License

MIT

nativeblade/ui-mobile 适用场景与选型建议

nativeblade/ui-mobile 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 44 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 05 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ui」 「mobile」 「laravel」 「ios」 「blade」 「material」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nativeblade/ui-mobile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nativeblade/ui-mobile 我们能提供哪些服务?
定制开发 / 二次开发

基于 nativeblade/ui-mobile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 46
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: Blade

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-05