fikfikk/shimmer
Composer 安装命令:
composer require fikfikk/shimmer
包简介
Laravel package for beautiful image shimmer loading effect
README 文档
README
Beautiful, lightweight image shimmer loading effect for any web project.
✨ Features
- 🚀 Zero Dependencies - Pure CSS & vanilla JS
- 🎨 Customizable - Colors, speed, border radius
- 🌙 Dark Mode - Automatic dark mode support
- ♿ Accessible - Respects
prefers-reduced-motion - 📦 Universal - Works with Laravel, Vue, React, Alpine.js, or plain HTML
- ⚡ Lightweight - < 2KB minified + gzipped
📦 Installation
Laravel (Composer)
composer require fikfikk/shimmer
CDN (HTML/JS/Vue/React)
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fikfikk-shimmer@latest/dist/shimmer.min.css" /> <script src="https://cdn.jsdelivr.net/npm/fikfikk-shimmer@latest/dist/shimmer.min.js" defer ></script>
NPM (Coming Soon)
npm install fikfikk-shimmer
🚀 Quick Start
Laravel Blade
{{-- Simple usage - auto size based on image --}} <x-shimmer::image-shimmer src="{{ asset('photo.jpg') }}" alt="Photo" /> {{-- With aspect ratio --}} <x-shimmer::image-shimmer src="{{ $product->image }}" alt="{{ $product->name }}" aspect-ratio="4/3" /> {{-- With fixed dimensions --}} <x-shimmer::image-shimmer src="{{ $user->avatar }}" alt="{{ $user->name }}" width="100" height="100" class="shimmer-rounded" />
Plain HTML
<div class="shimmer-container" style="aspect-ratio: 16/9;"> <div class="shimmer-placeholder"> <div class="shimmer-animation"></div> </div> <img src="photo.jpg" alt="Photo" class="shimmer-image" data-shimmer-image /> </div>
JavaScript API
// Create shimmer programmatically FikfikkShimmer.create({ container: "#my-container", src: "photo.jpg", alt: "My Photo", aspectRatio: "16/9", onLoad: (img) => console.log("Loaded!", img), }); // Refresh after dynamic content FikfikkShimmer.refresh();
Vue 3
<template> <ShimmerImage :src="product.image" :alt="product.name" aspect-ratio="1/1" @load="onImageLoad" /> </template> <script setup> import { ShimmerImage } from "fikfikk-shimmer/vue"; </script>
React
import { ShimmerImage } from "fikfikk-shimmer/react"; function ProductCard({ product }) { return ( <ShimmerImage src={product.image} alt={product.name} aspectRatio="1/1" className="product-image" onLoad={() => console.log("Loaded!")} /> ); }
PHP Helper Function
<?= shimmer_image($product->image, $product->name, 'my-class') ?> // Or with options <?= shimmer_html('photo.jpg', 'Alt text', [ 'aspectRatio' => '16/9', 'class' => 'my-image' ]) ?>
📐 Props / Attributes
| Prop | Type | Default | Description |
|---|---|---|---|
src |
string |
required | Image source URL |
alt |
string |
'' |
Image alt text |
class |
string |
'' |
Additional CSS classes |
width |
string|number |
null |
Container width (e.g., 400, '50%') |
height |
string|number |
null |
Container height |
aspect-ratio |
string |
null |
CSS aspect ratio (e.g., '16/9', '1/1') |
loading |
string |
'lazy' |
'lazy' or 'eager' |
decoding |
string |
'async' |
'async' or 'sync' |
💡 Tip: If no
width,height, oraspect-ratiois provided, the container will size automatically based on the image dimensions.
🎨 Utility Classes
Border Radius
<div class="shimmer-container shimmer-rounded"> <!-- Circle --> <div class="shimmer-container shimmer-rounded-sm"> <!-- 4px --> <div class="shimmer-container shimmer-rounded-lg"> <!-- 16px --> <div class="shimmer-container shimmer-rounded-xl"> <!-- 24px --> <div class="shimmer-container shimmer-rounded-none"><!-- 0 --></div> </div> </div> </div> </div>
Animation Speed
<div class="shimmer-container shimmer-fast"> <!-- 0.8s --> <div class="shimmer-container shimmer-slow"><!-- 2.5s --></div> </div>
Object Fit
<div class="shimmer-container shimmer-cover"> <!-- object-fit: cover --> <div class="shimmer-container shimmer-contain"> <!-- object-fit: contain --> <div class="shimmer-container shimmer-fill"><!-- object-fit: fill --></div> </div> </div>
Dark Mode
<div class="shimmer-container shimmer-dark"><!-- Force dark theme --></div>
⚙️ Configuration (Laravel)
Publish Config
php artisan vendor:publish --tag=shimmer-config
config/shimmer.php
return [ 'animation_duration' => '1.5s', // Shimmer speed 'base_color' => '#e0e0e0', // Background color 'shimmer_color' => '#f0f0f0', // Highlight color 'border_radius' => '8px', // Default radius 'fade_duration' => '0.3s', // Fade-in speed ];
Environment Variables
SHIMMER_ANIMATION_DURATION=1.5s SHIMMER_BASE_COLOR=#e0e0e0 SHIMMER_SHIMMER_COLOR=#f0f0f0 SHIMMER_BORDER_RADIUS=8px SHIMMER_FADE_DURATION=0.3s
🎨 CSS Customization
CSS Variables
:root { --shimmer-base: #e0e0e0; /* Background */ --shimmer-color: #f0f0f0; /* Highlight */ --shimmer-duration: 1.5s; /* Animation speed */ --shimmer-radius: 8px; /* Border radius */ --shimmer-fade: 0.3s; /* Fade duration */ }
Custom Theme
/* Green theme */ .shimmer-green { --shimmer-base: #e8f5e9; --shimmer-color: #c8e6c9; } /* Purple theme */ .shimmer-purple { --shimmer-base: #f3e5f5; --shimmer-color: #e1bee7; }
Per-Element Customization
{{-- Inline style override --}} <x-shimmer::image-shimmer src="photo.jpg" style="--shimmer-base: #fce4ec; --shimmer-color: #f8bbd9;" />
Dark Mode
/* Automatic */ @media (prefers-color-scheme: dark) { :root { --shimmer-base: #2a2a2a; --shimmer-color: #3a3a3a; } } /* Manual with class */ .dark .shimmer-container { --shimmer-base: #2a2a2a; --shimmer-color: #3a3a3a; }
🔧 JavaScript API
FikfikkShimmer.init([selector])
Initialize shimmer on elements. Called automatically on page load.
// Initialize all FikfikkShimmer.init(); // Initialize within container FikfikkShimmer.init("#gallery");
FikfikkShimmer.create(options)
Create shimmer element programmatically.
const element = FikfikkShimmer.create({ container: "#target", // Required: selector or element src: "image.jpg", // Required: image URL alt: "Description", // Optional class: "my-class", // Optional width: 400, // Optional height: 300, // Optional aspectRatio: "16/9", // Optional (ignored if height set) loading: "lazy", // Optional: 'lazy' | 'eager' decoding: "async", // Optional: 'async' | 'sync' onLoad: (img) => {}, // Optional: callback onError: (img) => {}, // Optional: callback });
FikfikkShimmer.refresh([selector])
Reinitialize after dynamic content changes.
// After AJAX/fetch fetch("/api/images").then(() => { // ... add images to DOM FikfikkShimmer.refresh(); }); // After Vue/React update FikfikkShimmer.refresh("#gallery");
FikfikkShimmer.destroy([selector])
Remove shimmer and restore plain images.
FikfikkShimmer.destroy("#gallery");
🔌 Framework Integration
Alpine.js
<div x-data="{ loaded: false }"> <div class="shimmer-container" style="aspect-ratio: 16/9;"> <div class="shimmer-placeholder" :class="{ loaded }"> <div class="shimmer-animation"></div> </div> <img src="photo.jpg" class="shimmer-image" :class="{ loaded }" @load="loaded = true" /> </div> </div>
Livewire
{{-- Works out of the box --}} <x-shimmer::image-shimmer src="{{ $image }}" wire:key="image-{{ $id }}" /> {{-- Refresh after Livewire update --}} <script> Livewire.hook('message.processed', () => { if (window.FikfikkShimmer) { FikfikkShimmer.refresh(); } }); </script>
Inertia.js
// In your Vue/React component import { onMounted, onUpdated } from "vue"; onMounted(() => FikfikkShimmer?.init()); onUpdated(() => FikfikkShimmer?.refresh());
📚 Examples
Product Grid
<div class="grid grid-cols-4 gap-4"> @foreach($products as $product) <x-shimmer::image-shimmer src="{{ $product->image }}" alt="{{ $product->name }}" aspect-ratio="1/1" class="shimmer-rounded-lg" /> @endforeach </div>
User Avatar
<x-shimmer::image-shimmer src="{{ $user->avatar }}" alt="{{ $user->name }}" width="48" height="48" class="shimmer-rounded" />
Hero Banner
<x-shimmer::image-shimmer src="{{ $banner->image }}" alt="{{ $banner->title }}" aspect-ratio="21/9" loading="eager" class="shimmer-rounded-none" />
Gallery with Lightbox
@foreach($gallery as $image) <a href="{{ $image->full }}" data-lightbox="gallery"> <x-shimmer::image-shimmer src="{{ $image->thumbnail }}" alt="{{ $image->caption }}" aspect-ratio="4/3" /> </a> @endforeach
❓ FAQ
Does it work without Laravel?
Yes! Use the CDN or copy the CSS/JS files. The shimmer works with any HTML page.
Why isn't the shimmer showing?
- Make sure CSS is loaded before the image
- Check that
data-shimmer-imageattribute is on the<img> - Call
FikfikkShimmer.init()after adding dynamic content
How do I change colors for a specific element?
Use inline CSS variables:
<x-shimmer::image-shimmer src="photo.jpg" style="--shimmer-base: #fce4ec; --shimmer-color: #f8bbd9;" />
Does it support srcset/responsive images?
Yes!
<div class="shimmer-container" data-shimmer> <div class="shimmer-placeholder"><div class="shimmer-animation"></div></div> <img src="small.jpg" srcset="small.jpg 400w, medium.jpg 800w, large.jpg 1200w" sizes="(max-width: 600px) 400px, 800px" class="shimmer-image" data-shimmer-image /> </div>
Can I disable shimmer animation?
For users who prefer reduced motion, it's automatic. To disable manually:
.shimmer-animation { animation: none !important; }
📄 License
MIT License - see LICENSE.md
🙏 Credits
Created by FikFikk
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
fikfikk/shimmer 适用场景与选型建议
fikfikk/shimmer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「laravel」 「Skeleton」 「loading」 「shimmer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fikfikk/shimmer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fikfikk/shimmer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fikfikk/shimmer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
Yii2 prettyPhoto image galary widget uses Lightbox view control jquery.prettyphoto.js
Slim starter / Slim skeleton package to boost your development with Slim framework
Base Skeleton for Laravel Application
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-16