electrik/slate 问题修复 & 功能扩展

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

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

electrik/slate

Composer 安装命令:

composer require electrik/slate

包简介

Slate - a Laravel Blade UI Kit is a set of anonymous blade components built using TailwindCSS v4 with built-in dark mode support for your next Laravel project

README 文档

README

Latest Version Total Downloads License PHP Version Laravel Version Tests Code Coverage Code Quality WCAG 2.1 AA ARIA Support GitHub Stars GitHub Forks GitHub Issues GitHub PRs Last Commit Maintained

Slate - a Laravel Blade UI Kit is a set of anonymous blade components built using TailwindCSS v4 with built-in dark mode support for your next Laravel project. Perfect for Laravel UI development with beautiful, accessible components.

Slate UI Auth Login Screen Screenshot

Demo | Documentation

✨ Features

  • 🎨 57 Components - Complete component library
  • 🎯 Zero PHP Color Logic - All colors controlled via CSS variables
  • 🌙 Dark Mode - Built-in dark mode support with automatic variable switching
  • Accessible - WCAG 2.1 AA compliant with proper ARIA attributes
  • 🚀 Tailwind CSS v4 - Using latest Tailwind with CSS variables
  • 📦 Anonymous Components - Pure Blade templates, no PHP classes
  • 🎨 Self-Contained - Everything in the package, minimal client configuration
  • Alpine.js - Interactive components using Alpine.js (standard in Laravel)
  • 🎨 Semantic Colors - success, warning, info, error, danger color system

📋 Requirements

  • PHP 8.1+
  • Laravel 10.0+ or 11.0+ or 12.0+
  • Tailwind CSS v4
  • Alpine.js (for interactive components - usually included in Laravel apps)

🚀 Installation

Step 1: Install via Composer

composer require electrik/slate

Step 2: Run Installation Command

php artisan slate:install

This command will:

  • Copy slate.css to resources/css/slate.css
  • Add @import './slate.css'; to your app.css (after @import 'tailwindcss';)
  • Add @source directive to scan Slate components

Note: The installation command automatically configures your app.css file. No manual Tailwind config changes needed when using Tailwind CSS v4!

Step 3: Build Assets

npm run build

That's it! Slate uses CSS variables and Tailwind v4's @theme system, so no tailwind.config.js changes are required.

📖 Usage

Basic Example

<x-slate::button>Click me</x-slate::button>

With Variants

<x-slate::button variant="success">Save</x-slate::button>
<x-slate::button variant="warning">Warning</x-slate::button>
<x-slate::button variant="error">Error</x-slate::button>
<x-slate::button variant="danger">Delete</x-slate::button>
<x-slate::button variant="outline">Cancel</x-slate::button>
<x-slate::button variant="ghost">Ghost Button</x-slate::button>

Form Example

<x-slate::label for="email">Email</x-slate::label>
<x-slate::input type="email" id="email" name="email" placeholder="Enter your email" />

🎨 Components

Slate includes 57 components:

Core Components

  • Button, Input, Card, Label, Badge

Form Components

  • Textarea, Select, Checkbox, Radio Group, Switch, Slider, Input Group, Input OTP, Field

Feedback & Overlay

  • Alert, Dialog, Alert Dialog, Drawer, Sheet, Popover, Tooltip, Hover Card, Sonner (Toast)

Navigation

  • Dropdown Menu, Context Menu, Navigation Menu, Menubar, Breadcrumb, Tabs, Sidebar, Pagination

Data Display

  • Table, Avatar, Separator, Skeleton, Empty, Aspect Ratio

Advanced

  • Accordion, Collapsible, Command, Combobox, Calendar, Progress, Scroll Area, Resizable, Carousel, Chart

Utility

  • Toggle, Toggle Group, Button Group, Item, Kbd, Spinner

🎨 Theming

Color System

Slate uses semantic color naming with foreground/background pairs:

Base Colors:

  • background / foreground - Page background and text
  • border, input, ring - UI element colors

Semantic Colors:

  • primary / primary-foreground - Main brand color
  • secondary / secondary-foreground - Secondary actions
  • success / success-foreground - Success states
  • warning / warning-foreground - Warning states
  • info / info-foreground - Informational states
  • error / error-foreground - Error states
  • danger / danger-foreground - Destructive actions
  • muted / muted-foreground - Subtle backgrounds/text
  • accent / accent-foreground - Hover states, highlights
  • card / card-foreground - Card backgrounds
  • popover / popover-foreground - Popover backgrounds

Customize Colors

Override CSS variables in resources/css/slate.css:

:root {
  --color-primary: 142 76% 36%; /* Custom green */
  --color-primary-foreground: 355 100% 97%;
  --color-success: 142 71% 45%; /* Custom success color */
  --color-success-foreground: 0 0% 98%;
}

.dark {
  --color-primary: 142 70% 45%; /* Dark mode variant */
  --color-primary-foreground: 0 0% 9%;
}

Dark Mode

Dark mode is automatically handled via the .dark class:

<html class="dark">
  <!-- Dark mode enabled -->
</html>

Toggle dark mode with Alpine.js:

<div x-data="{ dark: false }">
  <button @click="dark = !dark; document.documentElement.classList.toggle('dark', dark)">
    Toggle Dark Mode
  </button>
</div>

🧪 Testing

Slate components are tested using:

  • Unit Tests - Blade component rendering with different props/variants
  • Integration Tests - Components in real Laravel views and forms
  • Visual Regression Tests
  • Accessibility Tests - WCAG 2.1 AA compliance using axe-core/Pa11y

📚 Documentation

Full documentation is available at: https://slate.electrik.dev

Note: Documentation is in a separate repository (slate-docs) and uses Jigsaw for static site generation.

🔧 Customization

Self-Contained Package

Slate is designed to be self-contained. All styles and components live in the package, and the slate:install command handles configuration automatically.

Customize CSS Variables

Edit resources/css/slate.css (copied during installation) to customize colors, spacing, and other design tokens.

Publish Views (Optional)

To customize component markup:

php artisan vendor:publish --tag=slate-views

Views will be published to resources/views/vendor/slate/components/

Note: Published views won't receive automatic updates. Use this only if you need to modify component structure.

🤝 Contributing

Contributions are welcome! Please see our Contributing Guide for details.

📄 License

This package is open-sourced software licensed under the MIT license.

🙏 Credits

Made with ❤️ by Electrik

electrik/slate 适用场景与选型建议

electrik/slate 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2022 年 11 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 2.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 27
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2022-11-15