Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Blade Icons Laravel Package

driesvints/blade-icons

Blade Icons lets you use SVG icons in Laravel Blade with simple components and directives. Convert files like camera.svg into or @svg('camera') with easy class/attribute control, and plug in community icon set packages.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Component-Based UI Alignment: Blade Icons seamlessly integrates with Laravel’s Blade templating system, enabling a component-driven iconography approach that aligns with modern Laravel UI architectures (e.g., Livewire, Inertia.js, or Blade-based SPAs). The package abstracts SVG complexity into reusable components, reducing view clutter and improving maintainability.
  • SVG Optimization: Leverages inline SVGs (via Blade directives or components), eliminating external HTTP requests for icons—critical for performance-sensitive applications (e.g., dashboards, admin panels).
  • Tailwind CSS Synergy: Explicitly designed for Tailwind users (via class="w-6 h-6"), but flexible enough to work with other CSS frameworks or raw utilities. This reduces friction in projects already using Tailwind.

Integration Feasibility

  • Low-Coupling Design: The package is self-contained—no database migrations, queue workers, or complex dependencies required. Installation is a single Composer command (blade-icons:install), followed by minimal Blade configuration.
  • Blade Directive Flexibility: Supports both component syntax (<x-icon-camera />) and directive syntax (@svg('camera')), accommodating teams with varying Blade maturity.
  • Icon Set Agnostic: While the package ships with a default set, it’s extensible—users can add custom SVG files to resources/svg and register them via config. This avoids vendor lock-in.

Technical Risk

  • SVG Bloat Risk: Inline SVGs can increase template size if overused. Mitigation: Use the package’s --only flag during installation to include only necessary icons.
  • Caching Implications: Blade components are cached by default. If icons are dynamically styled (e.g., via @apply or dynamic classes), ensure the cache is invalidated appropriately (e.g., php artisan view:clear).
  • Legacy Blade Compatibility: While Laravel 8+ is assumed, older versions (pre-8.0) may require manual Blade directive registration. Test in staging first.
  • Custom Icon Paths: Misconfigured svg_path in config/blade-icons.php could break icon resolution. Validate paths post-installation.

Key Questions

  1. Icon Volume: How many custom icons will be added? If >50, consider a custom icon registry or asset pipeline (e.g., Vite) to avoid bloating Blade templates.
  2. Dynamic Styling Needs: Will icons require runtime styling (e.g., color changes via props)? If so, test Blade component props or directive attributes.
  3. CI/CD Impact: Does the team use GitHub Actions/GitLab CI? The package’s workflows (Tests, Coding Standards) can be mirrored in CI pipelines for consistency.
  4. Design System Alignment: How does this fit with existing icon systems (e.g., Heroicons, Font Awesome)? Audit for redundancy or gaps.
  5. Performance Budget: Measure baseline Blade template size before/after adoption to ensure no regressions.

Integration Approach

Stack Fit

  • Primary Fit: Laravel 8+ applications using Blade templating, especially those leveraging:
    • Tailwind CSS (native class support).
    • Livewire/Inertia.js (component-based UIs).
    • Custom Blade components (for reusable UI elements).
  • Secondary Fit: PHP-based projects using Blade outside Laravel (e.g., October CMS, Forge) with minimal adjustments.
  • Non-Fit: Projects using React/Vue SPAs (unless Blade is used for server-side rendering) or static site generators (e.g., Laravel Mix/Vite without Blade).

Migration Path

  1. Assessment Phase:
    • Audit existing icon usage (e.g., Font Awesome, inline SVGs, or raw <img> tags).
    • Identify high-frequency icons (e.g., navigation, buttons) for priority conversion.
  2. Installation:
    composer require blade-ui-kit/blade-icons
    php artisan blade-icons:install
    
    • Choose installation mode:
      • --all (all icons, ~1.2MB).
      • --only (custom subset, e.g., --only=heroicons,tabler).
  3. Blade Migration:
    • Replace <img src="/icons/camera.svg" /> with <x-icon-camera />.
    • For dynamic icons, use directives:
      @svg('camera', ['class' => $isActive ? 'text-red-500' : 'text-gray-500'])
      
  4. Testing:
    • Validate all icon replacements in a staging environment.
    • Test edge cases: dynamic classes, nested components, and custom icons.
  5. Optimization:
    • Run php artisan optimize:clear to repopulate Blade cache.
    • For large icon sets, consider lazy-loading via JavaScript (e.g., Intersection Observer).

Compatibility

  • Blade Version: Requires Laravel 8+ (Blade 8+). For older versions, manually register the svg directive in AppServiceProvider.
  • CSS Frameworks: Tailwind-optimized, but works with:
    • Bootstrap: Use utility classes (e.g., w-4 h-4).
    • Raw CSS: Inline styles via directive attributes.
  • Icon Sets: Pre-bundled with Heroicons, Tabler, Feather, and custom SVGs. Additional sets can be added via:
    // config/blade-icons.php
    'sets' => [
        'custom' => resource_path('svg/custom'),
    ];
    
  • Tooling:
    • Laravel Mix/Vite: No conflicts; SVGs are embedded in Blade.
    • PurgeCSS: Ensure Tailwind’s safelist includes icon classes (e.g., w-6 h-6).

Sequencing

  1. Phase 1 (Low Risk):
    • Replace static icons (e.g., <img> tags) in non-critical views (e.g., footer, documentation).
    • Test Blade component caching.
  2. Phase 2 (Moderate Risk):
    • Migrate dynamic icons (e.g., navigation bars, buttons) with directive attributes.
    • Validate performance impact.
  3. Phase 3 (High Risk):
    • Replace third-party icon libraries (e.g., Font Awesome) in core components.
    • Audit custom icon paths and registry.

Operational Impact

Maintenance

  • Proactive:
    • Icon Updates: New icon sets require composer update and Blade cache clearance. Monitor the changelog for breaking changes.
    • Custom Icons: Maintain resources/svg directory and config/blade-icons.php for additions/deletions.
  • Reactive:
    • Blade Cache: Clear cache after icon set updates:
      php artisan view:clear
      
    • SVG Validation: Use tools like SVGO to optimize custom SVGs pre-commit.

Support

  • Troubleshooting:
    • Icon Not Found: Verify svg_path in config and file permissions.
    • Styling Issues: Check Tailwind’s safelist or use inline styles.
    • Performance: Profile Blade templates with Laravel Debugbar or Chrome DevTools.
  • Community:
    • GitHub Discussions: Active issue tracker for package-specific queries.
    • Laravel Forums: Broader Blade/Laravel support.

Scaling

  • Performance:
    • Template Size: Monitor Blade template bloat. For >100 icons, consider icon fonts or spritesheets as an alternative.
    • HTTP Overhead: Inline SVGs eliminate external requests but increase template size. Benchmark against CDN-hosted icons (e.g., Font Awesome).
  • Team Scaling:
    • Onboarding: Document icon usage in a component library (e.g., Storybook) for new developers.
    • Accessibility: Ensure icons include ARIA labels (e.g., <x-icon-camera aria-label="Camera" />).

Failure Modes

Failure Scenario Impact Mitigation
Misconfigured svg_path Icons fail to render Validate paths post-install; use --dry-run.
Blade cache corruption Stale icon components Clear cache (php artisan view:clear).
Overuse of inline SVGs Increased template size Use --only flag; lazy-load non-critical icons.
Custom icon path errors Broken custom icons Test custom icon registration in staging.
Laravel version incompatibility Package fails to load Pin version in composer.json (e.g., ^4.0).

Ramp-Up

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui