Created
December 5, 2017 21:30
-
-
Save colebemis/21659e4db4e8cbdba401cea68f155377 to your computer and use it in GitHub Desktop.
Using Feather with Angular
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DomSanitizer } from '@angular/platform-browser'; | |
import { Pipe, PipeTransform } from '@angular/core'; | |
import { icons } from 'feather-icons'; // v4+ | |
@Pipe({ name: 'feather' }) | |
export class FeatherIconsPipe implements PipeTransform { | |
constructor(private sanitizer: DomSanitizer) {} | |
transform(icon: string, size: number = 24, color: string = 'inherit') { | |
return this.sanitizer.bypassSecurityTrustHtml(icons[icon].toSvg({ | |
width: size, | |
height: size, | |
color: color | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the update @colebemis. My solution was based on Feather icons 3.3. Just upgraded to v4 and it is awesome. You did a great job.
I'll update the blog post soon.