in10/styleguide
Adds a basic styleguide to Laravel projects. Install via Composer, place Blade templates in resources/views/styleguide, then view them in the browser at /styleguide to browse and document UI components and patterns.
Installation
Run composer require in10/styleguide in your Laravel project root.
Publish the package assets (if needed) with:
php artisan vendor:publish --provider="IN10\Styleguide\StyleguideServiceProvider"
First Use Case
Place your Blade template files (e.g., _variables.scss, _buttons.blade.php) in:
/resources/views/styleguide/
Access the styleguide via /styleguide in your browser.
Where to Look First
/resources/views/styleguide/ directory for template organization.routes/web.php (auto-loaded) for the /styleguide route.styleguide.blade.php in the package’s views for structure.Component-Based Development
components/buttons.blade.php)./resources/views/styleguide/
├── _variables.scss # SCSS variables
├── components/
│ ├── buttons.blade.php # Button variants
│ └── cards.blade.php # Card layouts
└── pages/
└── forms.blade.php # Form examples
Live Reloading
webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.sass('resources/scss/app.scss', 'public/css')
.options({ processCssUrls: false }); // Critical for styleguide assets
Versioned Styleguides
/styleguide/v1/, /styleguide/v2/) for major updates.routes/web.php:
Route::get('/styleguide/{version?}', [StyleguideController::class, 'show'])
->where('version', 'v[0-9]+');
API Documentation
@include('styleguide.api.example').public function show($version = null) {
return view('styleguide.index', [
'apiExamples' => ApiService::fetchExamples($version),
]);
}
Asset Loading Conflicts
.styleguide-*) or isolate assets:
// In StyleguideServiceProvider.php
public function boot() {
$this->loadViewsFrom(__DIR__.'/views', 'styleguide');
}
Route Caching
php artisan route:clear
Blade Component Isolation
@once or @stack directives to isolate dependencies:
@once
@push('styleguide-scripts')
<script src="/js/styleguide-utils.js"></script>
@endpush
@endonce
Check the View Path
/resources/views/styleguide/ (case-sensitive on some systems).dd(view()->exists('styleguide.index')); // Should return true
Asset Debugging
mix.version() to debug asset paths:
mix.setPublicPath('public/styleguide-assets');
Route Debugging
php artisan route:list | grep styleguide
Custom Controllers
AppServiceProvider:
$this->app->bind(
StyleguideController::class,
CustomStyleguideController::class
);
Dynamic Content
public function handle($request, Closure $next) {
if ($request->is('styleguide*')) {
$request->merge(['styleguide_data' => collect(['key' => 'value'])]);
}
return $next($request);
}
Theming Support
@stack to inject theme-specific assets:
@stack('styleguide-themes::css')
@stack('styleguide-themes::js')
How can I help you explore Laravel packages today?