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

blade-ui-kit/blade-icons

Use SVG icons in Laravel Blade with simple components and directives. Convert SVG files into <x-icon-... /> tags or @svg() calls, add classes/attributes easily, and plug in many third‑party icon set packages for quick, consistent icons across your app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Blade Integration: Seamlessly integrates with Laravel’s Blade templating engine, aligning with Laravel’s native view layer. No need for JavaScript-based solutions (e.g., icon fonts or React components), reducing client-side dependencies.
    • SVG-Based: Leverages scalable vector graphics, ensuring crisp rendering at any size and enabling dynamic styling (e.g., color, stroke) via CSS or inline attributes.
    • Component-Driven: Encourages reusable, self-contained icon components (<x-icon-camera />), fitting Laravel’s Blade component ecosystem (e.g., Livewire, Inertia.js).
    • Extensible: Supports third-party icon sets (e.g., Heroicons, Font Awesome) via modular packages, allowing teams to standardize on a single icon system.
    • Zero JavaScript: Eliminates runtime overhead, improving performance for static and dynamic content.
  • Cons:

    • SVG Bloat: Each icon is an individual SVG file, which may increase initial payload size if overused. Mitigated by Laravel’s asset optimization (e.g., @vite, @mix).
    • Namespace Pollution: Custom icon components (e.g., <x-icon-* />) require unique namespacing to avoid conflicts with other Blade components.
    • Static by Default: Icons are pre-defined; dynamic icon generation (e.g., from a database) requires custom logic (e.g., Blade directives or dynamic components).

Integration Feasibility

  • Laravel Ecosystem:
    • Blade Compatibility: Works out-of-the-box with Laravel’s Blade compiler. No middleware or service provider hooks required for basic usage.
    • Livewire/Inertia: Icons can be used in Livewire components or Inertia.js pages without additional configuration.
    • Tailwind CSS: Plays well with Tailwind’s utility classes (e.g., w-6 h-6) for consistent sizing.
  • Non-Laravel PHP:
    • Limited Use Case: Primarily designed for Laravel; integration with vanilla PHP or other frameworks would require manual Blade-like templating logic.
  • Frontend Stack:
    • Vite/Webpack: SVGs can be processed through Laravel Mix/Vite for optimization (e.g., tree-shaking, inline critical SVGs).
    • CSS Preprocessors: Supports SASS/PostCSS for dynamic icon styling (e.g., theming).

Technical Risk

  • Low:
    • Mature Package: Actively maintained (last release 2026), with CI/CD pipelines for tests and coding standards.
    • Minimal Configuration: Default setup requires only SVG files in resources/svg and publishing the config.
    • Backward Compatibility: Upgrade guide exists, and breaking changes are documented.
  • Medium:
    • Icon Set Management: Requires manual setup of third-party icon packages (e.g., blade-heroicons). Dependency sprawl risk if overused.
    • Caching: Blade components are cached by default; dynamic icon generation may require cache busting (e.g., @once directives).
  • High:
    • SVG Security: If icons are user-uploaded or dynamically generated, validate SVG content to prevent XXE or malicious payloads.
    • Build Step Dependency: Icon optimization (e.g., SVGO) may need to be integrated into Laravel Mix/Vite pipelines.

Key Questions

  1. Icon Strategy:
    • Will the team use the base package or third-party icon sets (e.g., Heroicons)? How will icon consistency be enforced across projects?
  2. Performance:
    • Are there plans to lazy-load or code-split icon SVGs (e.g., via dynamic imports in Vite)?
  3. Dynamic Icons:
    • Are there use cases for runtime-generated icons (e.g., from a database)? If so, how will this be implemented (e.g., Blade directives, custom components)?
  4. Theming:
    • How will icon colors/strokes be themed (e.g., dark mode)? Will CSS variables or inline styles be used?
  5. CI/CD:
    • Will icon files be version-controlled, or will they be generated dynamically (e.g., via a script)?
  6. Accessibility:
    • Are ARIA attributes (e.g., aria-hidden) needed for icons? How will screen readers handle SVG icons?
  7. Fallbacks:
    • What fallback will be used if an SVG fails to load (e.g., CSS mask-image or a backup font)?

Integration Approach

Stack Fit

  • Primary Fit:
    • Laravel 8+: Native Blade integration with minimal overhead.
    • Tailwind CSS: Seamless sizing and styling with utility classes.
    • Livewire/Inertia.js: Icons work in reactive components without additional setup.
    • Vite/Webpack: SVGs can be optimized and inlined for performance.
  • Secondary Fit:
    • PHP Frameworks: Possible with custom Blade-like templating, but not recommended.
    • Static Sites: Works if using Laravel as a static site generator (e.g., Laravel Vapor).
  • Non-Fit:
    • Non-PHP Backends: Requires proxying Blade logic or rewriting components.

Migration Path

  1. Assessment Phase:
    • Audit existing icon usage (e.g., icon fonts, inline SVGs, or external CDNs).
    • Identify high-priority icon sets (e.g., Heroicons for a design system).
  2. Setup:
    • Install the base package:
      composer require blade-ui-kit/blade-icons
      
    • Publish config and create resources/svg directory:
      php artisan vendor:publish --tag=blade-icons
      
    • Add third-party icon packages (e.g., blade-heroicons) as needed.
  3. Incremental Replacement:
    • Replace inline SVGs with <x-icon-* /> components in Blade files.
    • Use @svg('icon-name', 'classes') for direct replacements.
    • Update Tailwind/PostCSS configs to handle SVG-specific styles (e.g., fill-current).
  4. Optimization:
    • Integrate SVGO into Laravel Mix/Vite for optimization.
    • Implement dynamic imports for non-critical icons (e.g., via @vite directives).
  5. Testing:
    • Verify icons render correctly in all contexts (e.g., dark mode, responsive layouts).
    • Test performance impact (e.g., Lighthouse audit).

Compatibility

  • Blade Directives:
    • @svg('name', 'classes') works in all Blade templates.
    • Custom directives (e.g., @icon) can be added for shorthand.
  • Component Namespacing:
    • Avoid conflicts by using a unique namespace (e.g., <x-app-icon-camera />).
  • CSS/JS:
    • Icons support inline styles and CSS classes. Ensure no conflicts with existing styles (e.g., currentColor vs. hardcoded colors).
    • Avoid !important in icon-related styles to maintain overrideability.
  • Dynamic Content:
    • For dynamic icons, use Blade components with dynamic class binding:
      <x-icon-{{ $dynamicIcon }} class="w-6 h-6" />
      

Sequencing

  1. Phase 1: Core Integration (1–2 sprints):
    • Install package and configure default icon set.
    • Replace static SVGs with Blade components in high-impact views (e.g., dashboard, auth).
  2. Phase 2: Icon Set Standardization (1 sprint):
    • Select and integrate third-party icon sets (e.g., Heroicons, Font Awesome).
    • Deprecate legacy icon systems (e.g., icon fonts).
  3. Phase 3: Optimization (Ongoing):
    • Optimize SVGs via SVGO.
    • Implement lazy loading for non-critical icons.
  4. Phase 4: Dynamic Features (Optional):
    • Build custom Blade directives for dynamic icon generation.
    • Integrate with CMS/database-driven icon selection.

Operational Impact

Maintenance

  • Pros:
    • Centralized Management: All icons live in resources/svg, making it easy to update or replace sets.
    • Version Control: SVG files can be committed to Git, ensuring reproducibility.
    • Minimal Dependencies: No JavaScript or external CDNs to monitor.
  • Cons:
    • Icon Set Updates: Third-party icon packages may require manual updates (e.g., composer update + config tweaks).
    • SVG Maintenance: Custom icons must be manually added/updated in the resources/svg directory.
    • Caching: Blade component cache may need invalidation when icons are updated (use php artisan view:clear or @once directives).

Support

  • Troubleshooting:
    • Missing Icons: Verify the SVG file exists in resources/svg and the config is published.
    • Styling Issues: Check for CSS conflicts (e.g., fill vs. currentColor).
    • Performance: Use browser dev tools to audit SVG payload size.
  • Documentation:
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui