🤹
TALL Stack Tips
  • What is TALL Stack
  • Tailwind
    • Tailwind Resources
    • Swinging Bell Notification Icon
    • Styled Unordered Lists
  • Alpine
  • Alpine Resources
  • Tabbed Content Using Alpine JS
  • Checkbox component with SVG tick
  • Dropdown animation
  • Create a Sliding Puzzle Captcha
  • Laravel
    • Tabler Icons Component
    • Password-less Login with Laravel 8+
    • Password-less Login with Magic Link in Laravel 8
    • Laravel Resources
    • Laravel Breeze Login Conditional Redirect
    • Jetstream Login Conditional Redirect
    • Simplify Laravel CRUD Controllers
    • CSRF and expired login forms
    • CSRF and expired logout forms
    • Add your own logo to Laravel Mail
    • Specify a different mail theme for Notifications
    • Show custom page when email verification link expired
    • Using a mutator to save currency
    • Using Spatie Valuestore to hold frequently accessed settings
    • Using the old() helper
    • Alternatives to using Eloquent Accessor
    • UpdateOrCreate may not update timestamp
    • Use of lockForUpdate()
    • Using S3
    • Super Simple User Based Feature Flags
    • Installing a Specific Version of Laravel
    • Versioning your Laravel Project
    • CSS Cache Busting with your Git Commit SHA
    • Adding column to Database Notifications table
    • Find nearby locations using the Haversine formula in Eloquent query
    • Using Queues on Shared Hosting with Laravel
    • Create Guaranteed Unique Invoice Number in Laravel
    • Send Notification to all team members
    • Protect Staging site with Basic Auth
    • Working with Enums
    • PHP DateTime formatting cribsheet
  • Livewire
    • Livewire Resources
    • Naming Livewire Components
    • Dynamic Cascading Dropdown with Livewire
    • Hiding a button after click
    • Working with Javascript Components
    • SweetAlert2 with Livewire
    • Select Multiple or Checkboxes
    • Clearing checkboxes in Livewire
    • Livewire File Uploads Using S3
    • Simple Log File Viewer
  • Related Resources
    • Testing resources
    • When Composer runs out of memory
    • Deployment
    • Security
    • Scheduler & Cron tips
    • LastPass tips
    • Using Git
    • VSCode Tips
    • Markdown
    • Cpanel resources
Powered by GitBook
On this page
  • The Component
  • Install the icons
  • Usage

Was this helpful?

  1. Laravel

Tabler Icons Component

Simple Laravel 7+ component to display one of the Tabler icon set

PreviousCreate a Sliding Puzzle CaptchaNextPassword-less Login with Laravel 8+

Last updated 4 years ago

Was this helpful?

The Component

resources/views/components/tabler.blade.php
<!-- tabler icon, pulls from public/tabler folder. Accepts:
    strokeWidth   defaults to "1"
    class         defaults to "inline-block relative h-2"
-->

<svg viewBox="0 0 24 24" stroke="currentColor" 
    stroke-width="{{ $strokeWidth ?? 1 }}" 
    class="inline-block relative h-2 {{ $class ?? '' }}" 
    {{ $attributes->except(['class','icon']) }} 
>
    
    <use xlink:href="/tabler/tabler-sprite-nostroke.svg#tabler-{{$icon}}" />

</svg>

Copy the component script into tabler.blade.php in the resources/views/components folder

Install the icons

Copy the icon svg sprite file from Github tabler/tabler-icons

Locate the file tabler-sprite-nostroke.svg and copy it into the folder public/tabler/

Usage

Example usage:

Twitch icon with height 6 in the same colour as the parent element.

<x-tabler icon="brand-twitch" class="h-6" />

Bucket icon in blue-500 and pushed up to align with the bottom of the text. Default stoke width of 1 is increased to 2.

<x-tabler wire:click="hello" 
    icon="bucket" 
    class="bottom-1 h-6 text-blue-500" 
    strokeWidth="2" />

Notes:

Always remember to close the component with the />

If new icons are added just download a fresh copy of the svg file from Github. The project is under active development and new icons are being added regularly.

The approach uses the sprite map file for the icon set which is rather large at 300K+ . You may prefer to download the individual icon files and use the example above to find the correct file. At the time of writing, only individual icon files with 2px stroke weight are provided.

Search for the icon name required at

https://tablericons.com/
GitHub - tabler/tabler-icons: A set of over 1450 free MIT-licensed high-quality SVG icons for you to use in your web projects.GitHub
Logo