定制 edulazaro/wiretoast 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

edulazaro/wiretoast

Composer 安装命令:

composer require edulazaro/wiretoast

包简介

Framework-agnostic toast notification system for Laravel, Livewire and Alpine. Pure CSS themes, custom-theme via variables, drop-in API.

README 文档

README

Framework-agnostic toast notification system for Laravel, Livewire and Alpine. Pure CSS themes (no Tailwind, no Bootstrap), drop-in API, zero JS dependencies.

Live preview → Try the 11 themes, 5 types, 7 positions and dark mode in the interactive demo.

Requirements

  • PHP >=8.2
  • Laravel >=11.0 (any future version included)
  • Livewire >=3.0 (optional, only needed for the $this->notify() helper)

Features

  • 5 semantic types: success, error, warning, info, neutral
  • 7 stacked positions: top-left, top-center, top-right, bottom-left, bottom-center, bottom-right, center
  • 11 visual themes bundled: flat, soft, glass, gradient, neon, minimal, claude, chatgpt, synthwave, megaflow, brutalist
  • Custom themes via CSS variables (no Blade override needed)
  • Dark mode automatic (prefers-color-scheme) and opt-in (.dark / [data-wt-theme-mode="dark"])
  • Optional auto-dismiss progress bar with pause-on-hover
  • Optional title + message
  • Group mode: collapse multiple messages of the same type into one

Install

composer require edulazaro/wiretoast

Then load the assets. Pick the path that matches your project.

Without a bundler: vendor:publish

For projects that don't use Vite or another bundler, copy the assets to public/vendor/wiretoast/ and tell the component to inject the <link> and <script> tags by passing :assets="true".

php artisan vendor:publish --tag=wiretoast-assets
<x-wiretoast :assets="true" />

Recommended: bundle with Vite

Import wiretoast from your existing app.css and app.js. Vite minifies, hashes, and concatenates everything into your main bundle, so there's no extra HTTP request and you reuse your cache-busting setup.

// resources/js/app.js
import '../../vendor/edulazaro/wiretoast/resources/js/wiretoast.js';
/* resources/css/app.css */
@import '../../vendor/edulazaro/wiretoast/resources/css/wiretoast.css';

Add the component to your layout:

<x-wiretoast />

By default the component does not inject any <link> or <script> tags, so it won't conflict with your Vite bundle.

Optionally, add a Vite alias for cleaner imports:

// vite.config.js
import path from 'path';

export default defineConfig({
    resolve: {
        alias: {
            '@wiretoast': path.resolve(__dirname, 'vendor/edulazaro/wiretoast/resources'),
        },
    },
});
// resources/js/app.js
import '@wiretoast/js/wiretoast.js';
import '@wiretoast/css/wiretoast.css';

Optional props (both paths)

<x-wiretoast theme="soft" mode="dark" default-position="bottom-right" />

Usage

The API is the same in all three environments and always called notify.

Livewire (PHP)

// Plain message
$this->notify('Saved successfully');

// With type
$this->notify('Could not connect', 'error');

// Title + message
$this->notify(['title' => 'Saved', 'message' => 'All changes applied'], 'success');

// Options (third arg as array)
$this->notify('Heads up', 'warning', [
    'position' => 'bottom-center',
    'timeout'  => 3000,
    'progress' => true,
]);

// Legacy: third arg as boolean = group
$this->notify('Item added', 'success', true);

Alpine.js

<button @click="$dispatch('notify', { message: 'Saved', type: 'success' })">
    Save
</button>

<button @click="$dispatch('notify', {
    title: 'Saved',
    message: 'All changes applied',
    type: 'success',
    position: 'bottom-right',
    progress: true
})">Save with progress</button>

JavaScript

window.notify('Saved successfully', 'success');
window.notify({ title: 'Saved', message: 'All changes applied' }, 'success');
window.notify('Heads up', 'warning', { position: 'bottom-center', timeout: 3000, progress: true });

Themes

Set the theme on the component (or any ancestor element):

<x-wiretoast theme="glass" />

Or dynamically:

document.body.dataset.wtTheme = 'neon';

Custom theme

Themes are pure CSS variable sets. Create your own without touching the package:

:root {
    --wt-radius: 6px;
    --wt-bg: #fafafa;
    --wt-text: #222;
    --wt-shadow: 0 2px 8px rgba(0,0,0,.06);

    --wt-success: #10b981;
    --wt-error:   #ef4444;
    --wt-warning: #f59e0b;
    --wt-info:    #3b82f6;
    --wt-neutral: #6b7280;
}

Or scope it under an attribute so users can switch:

[data-wt-theme="brand"] .wt-toast {
    background: linear-gradient(to right, #ff6b6b, #feca57);
    color: white;
    border: none;
    border-radius: 999px;
}
<x-wiretoast theme="brand" />

Dark mode

Out of the box, dark mode is applied automatically based on the user's OS via prefers-color-scheme: dark. To override:

<x-wiretoast mode="dark" />   {{-- force dark --}}
<x-wiretoast mode="light" />  {{-- force light --}}

The package also responds to a .dark class on any ancestor (compatible with Tailwind dark mode setups) and to the [data-wt-theme-mode] attribute.

Reference

notify(input, type, options) (JS) / $this->notify(...) (Livewire)

Argument Type Description
input string | { title, message } Message text or object with title and message
type 'success' | 'error' | 'warning' | 'info' | 'neutral' Semantic type, default 'info' (JS) / 'success' (Livewire)
options boolean | object Options object, or true for legacy group mode

Options object

Key Type Default Description
position string 'top-right' One of the 7 positions
timeout number 5000 Auto-dismiss in ms (0 = persist)
progress boolean false Show countdown bar (pauses on hover)
group boolean false Append to existing same-type toast

CSS variables

Structural: --wt-radius, --wt-padding, --wt-gap, --wt-width, --wt-font, --wt-font-size, --wt-line-height

Color: --wt-bg, --wt-text, --wt-text-muted, --wt-border, --wt-shadow

Semantic: --wt-success, --wt-error, --wt-warning, --wt-info, --wt-neutral (each also has a *-tint for soft theme)

Motion: --wt-duration, --wt-easing

Per-toast: --wt-progress-duration (set automatically when progress: true)

Credits

Developed by Edu Lázaro.

License

MIT

edulazaro/wiretoast 适用场景与选型建议

edulazaro/wiretoast 是一款 基于 HTML 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 edulazaro/wiretoast 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: HTML

其他信息

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