{"id":13780998,"url":"https://github.com/lekoala/last-icon","last_synced_at":"2025-04-12T02:06:09.003Z","repository":{"id":67519431,"uuid":"368498400","full_name":"lekoala/last-icon","owner":"lekoala","description":"One custom icon element to rule them all","archived":false,"fork":false,"pushed_at":"2024-12-13T13:43:35.000Z","size":166,"stargazers_count":34,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T16:54:24.454Z","etag":null,"topics":["bootstrap","currentcolor","custom-element","font","font-icon","icon-sets","icons","js","material","svg","svg-icons","webcomponent"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lekoala.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"lekoala"}},"created_at":"2021-05-18T11:05:00.000Z","updated_at":"2025-04-03T07:53:26.000Z","dependencies_parsed_at":"2024-01-07T00:08:07.635Z","dependency_job_id":null,"html_url":"https://github.com/lekoala/last-icon","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.016129032258064502","last_synced_commit":"90a5f9d8fc9044ae00e5f8f1be3a2c5322dbe9dd"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lekoala%2Flast-icon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lekoala%2Flast-icon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lekoala%2Flast-icon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lekoala%2Flast-icon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lekoala","download_url":"https://codeload.github.com/lekoala/last-icon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247631658,"owners_count":20970059,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootstrap","currentcolor","custom-element","font","font-icon","icon-sets","icons","js","material","svg","svg-icons","webcomponent"],"created_at":"2024-08-03T18:01:21.942Z","updated_at":"2025-04-12T02:06:08.978Z","avatar_url":"https://github.com/lekoala.png","language":"HTML","readme":"# last-icon\n\n[![NPM](https://nodei.co/npm/last-icon.png?mini=true)](https://nodei.co/npm/last-icon/)\n[![Downloads](https://img.shields.io/npm/dt/last-icon.svg)](https://www.npmjs.com/package/last-icon)\n\nThe last icon library you will ever need.\n\nKey features:\n\n- Load as svg or font icons\n- Mix \u0026 match icon sets if needed\n- Bring your own icons\n- Fix iconsistencies\n- Lazy load your icons\n\n## How to use\n\nSimply include the library\n\n```html\n\u003cscript src=\"last-icon.js\"\u003e\u003c/script\u003e\n```\n\n**NOTE:** It is recommended to define this as early as possible so that all icons are resolved as soon\nas possible. Otherwise, you might see a delay before your icons are being displayed.\nEven when doing this, you might still see a very small delay as opposed as a font icon or an embedded SVG.\n\nIf you are fine with a little more delay, you can use this instead (which will be ignored on browsers\nthat don’t support modules):\n\n```html\n\u003c!-- preload helps displaying things as early as possible, doesn't work in firefox and safari --\u003e\n\u003clink rel=\"modulepreload\" href=\"last-icon.js\" /\u003e\n\u003cscript type=\"module\" src=\"./last-icon.js\"\u003e\u003c/script\u003e\n```\n\nAnd call your icons!\n\n```html\n\u003cl-i name=\"star\"\u003e\u003c/l-i\u003e\n\u003cl-i name=\"star\" set=\"tb\"\u003e\u003c/l-i\u003e\n\u003cl-i name=\"star\" size=\"32\" set=\"tb\"\u003e\u003c/l-i\u003e\n\n\u003cl-i name=\"star\" set=\"bx\" type=\"solid\"\u003e\u003c/l-i\u003e\n\u003cl-i name=\"star\" set=\"bx\" type=\"regular\"\u003e\u003c/l-i\u003e\n\u003cl-i name=\"github\" set=\"bx\" type=\"logos\"\u003e\u003c/l-i\u003e\n```\n\nThe following CSS is recommended:\n\n```css\nl-i {\n  --size: 1em;\n  display: inline-flex;\n  width: var(--size);\n  height: var(--size);\n  vertical-align: middle;\n}\nl-i svg {\n  display: block;\n  width: 100%;\n  height: 100%;\n}\np l-i,\nbutton l-i,\na l-i,\nspan l-i {\n  vertical-align: -0.125em;\n}\n```\n\n## Configuring\n\nYou can set any options using `LastIcon.configure`. The recommended way to call it is this way:\n\n```js\ncustomElements.whenDefined(\"l-i\").then(() =\u003e {\n  // Access through registry\n  customElements.get(\"l-i\").configure({\n    debug: true,\n    // Transform stars to trash\n    // replaceName: {\n    //   star: \"trash\"\n    // },\n    // Use font icon\n    // fonts: [\n    //   \"material\",\n    //   \"phosphor\",\n    // ],\n    // Change default set\n    defaultSet: \"tabler\",\n    // Change default stroke\n    // defaultStroke: 1,\n  });\n});\n```\n\nAll available options:\n\n| Name        | Type                                        | Description                                   |\n|-------------|---------------------------------------------|-----------------------------------------------|\n| debug       | \u003ccode\u003eBoolean\u003c/code\u003e                        | Should we output messages to console          |\n| lazy        | \u003ccode\u003eBoolean\u003c/code\u003e                        | Load icons lazily                             |\n| replaceName | \u003ccode\u003eObject\u003c/code\u003e                         | Transparently replace icons with other values |\n| fonts       | \u003ccode\u003eArray\u003c/code\u003e                          | Icon sets using font icons rather than SVG    |\n| defaultSet  | \u003ccode\u003eString\u003c/code\u003e                         | Default icon set                              |\n| sets        | \u003ccode\u003eObject.\u0026lt;string, IconSet\u0026gt;\u003c/code\u003e | Available iconsets                            |\n\n## Supported icon sets\n\n| Icon Set          | Name        | Alias | Types | Stroke | Count | Website                                                                  |\n|-------------------|-------------|-------|:-----:|:------:|:------|--------------------------------------------------------------------------|\n| Bootstrap Icons   | bootstrap   | bs    |   1   |   x    | 1800+ | [bootstrap](https://icons.getbootstrap.com/)                             |\n| Flags             | flags       | fl    |   1   |   x    | ?     | [flags](https://github.com/lipis/flag-icons/)                   |\n| Fontawesome       | fontawesome | fa    |   5   |   x    | 1600+ | [fontawesome](https://fontawesome.com/cheatsheet)                        |\n| Iconoir           | iconoir     | in    |   1   |   x    | 1600+ | [iconoir](https://iconoir.com/)                                          |\n| IconPark          | iconpark    | ip    |   4   |   v    | 2400+ | [iconpark](https://iconpark.oceanengine.com/official)                    |\n| Lucide            | lucide      | lu    |   1   |   v    | 1800+ | [lucide](https://lucide.dev/)                                            |\n| Materials Icons   | material    | mi    |   5   |   x    | 1100+ | [material icons](https://fonts.google.com/icons?selected=Material+Icons) |\n| Phosphor          | phosphor    | ph    |   6   |   x    | 9000+ | [phosphor](https://phosphoricons.com/)                                   |\n| Super Tiny Icons  | supertiny   | st    |   1   |   x    | 386   | [supertiny](https://github.com/edent/SuperTinyIcons)                     |\n| Materials Symbols | symbols     | ms    |   3   |   v    | 2500+ | [material symbols](https://fonts.google.com/icons)                       |\n| Tabler Icons      | tabler      | ti    |   1   |   v    | 5700+ | [tabler](https://tabler-icons.io/)                                       |\n\n---\n\n## Adding or updating an icon set\n\nYou can update any option for an icon set\n\n| Name            | Type                                       | Description                                         |\n|-----------------|--------------------------------------------|-----------------------------------------------------|\n| alias           | \u003ccode\u003eString\u003c/code\u003e                        | Short two letters alias                             |\n| svgPath         | \u003ccode\u003efunction\u003c/code\u003e                      | The SVG path                                        |\n| [fixFill]       | \u003ccode\u003eBoolean\u003c/code\u003e                       | Does this set needs fixing `fill:currentColor`?     |\n| [useStroke]     | \u003ccode\u003eString\u003c/code\u003e                        | Add stroke to svg                                   |\n| [defaultStroke] | \u003ccode\u003eString\u003c/code\u003e                        | Default stroke to use (if supports stroke)          |\n| [defaultType]   | \u003ccode\u003eString\u003c/code\u003e                        | Default type to use (when there are multiple types) |\n| [prefixes]      | \u003ccode\u003eObject.\u0026lt;string, string\u0026gt;\u003c/code\u003e | Types to prefixes                                   |\n| [fontClass]     | \u003ccode\u003efunction\u003c/code\u003e                      | Font class                                          |\n| [opticalFont]   | \u003ccode\u003eBoolean\u003c/code\u003e                       | Is an optical font?                                 |\n| [name]          | \u003ccode\u003eString\u003c/code\u003e                        | Full name (injected automatically)                  |\n\n## Fill\n\nSome icon sets include a default `fill=\"currentColor\"` and some don't. In order\nto have all icon sets behave consistently, we apply a `fill=\"currentColor\"` to all\nicon sets. This fix apply to: 'material', 'fontawesome'.\n\n## Why a custom element\n\n- External sprite or font is loading all the icons which lead to extra load time\n- Including SVG is leading to really super long HTML and not very developer friendly\n- No need for custom JS inliner, it feels cleaner overall\n\n## Why external CSS\n\nA custom element CSS is not loaded until the component itself is loaded, which\ncan lead to FOUC and things moving around as the icon appear.\nThe solution I've found so far is to apply some global CSS rules than are known\nbefore the component is loaded.\n\nYou can check any extra SCSS that might be useful for you as well.\n\n## Using fonts\n\nSometimes it is easier to use an icon font. Indeed, it is fully cached by the browser and will not have any display glitch.\nObviously, the downside is that you have to load the whole font, but it's cached after the first load.\nThe advantage of using LastIcon over regular icons is that is allows you to switch easily between one way or the other.\n\nFirst of all, load any relevant fonts style\n\n```html\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\" /\u003e\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons+Two+Tone\" rel=\"stylesheet\" /\u003e\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons+Sharp\" rel=\"stylesheet\" /\u003e\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons+Round\" rel=\"stylesheet\" /\u003e\n\u003clink href=\"https://fonts.googleapis.com/icon?family=Material+Icons+Outlined\" rel=\"stylesheet\" /\u003e\n```\n\nAnd after that, use the font config to tell Last Icon to use the font over the SVG icons\n\n```js\ncustomElements.whenDefined(\"l-i\").then(() =\u003e {\n  // Access through registry\n  customElements.get(\"l-i\").configure({\n    debug: true,\n    fonts: [\"material\"],\n    material: {\n      defaultType: \"two-tone\",\n    },\n  });\n});\n```\n\nAnd then, update your styles:\n\n```css\nl-i {\n  --size: 1em;\n  display: inline-flex;\n  width: var(--size);\n  height: var(--size);\n  vertical-align: middle;\n\n  svg {\n    display: block;\n    width: 100%;\n    height: 100%;\n  }\n  i {\n    font-size: var(--size) !important;\n    color: currentColor;\n  }\n}\np,\nbutton,\na,\nspan {\n  l-i {\n    vertical-align: -0.125em;\n  }\n}\n\n.material-icons-two-tone {\n  background-color: currentColor;\n  -webkit-background-clip: text;\n  -webkit-text-fill-color: transparent;\n}\n```\n\n## Demo\n\nSee `demo.html` or the following pen https://codepen.io/lekoalabe/pen/eYvdjqY\n\n## Worth looking at\n\nYou might also be interested in https://icon-sets.iconify.design/\n","funding_links":["https://github.com/sponsors/lekoala"],"categories":["Design Elements"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flekoala%2Flast-icon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flekoala%2Flast-icon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flekoala%2Flast-icon/lists"}