Giter VIP home page Giter VIP logo

vue-tabler-icons's Introduction

Tabler Icons as Vue 3 components

NPM GitHub Workflow Status GitHub NPM - Downloads

Preview

Live preview tool

Preview icons

Tabler Icons

</p>

Features

  • Over 1250 pixel-perfect icons
  • TypeScript definitions
  • Vue 3 support
  • Vue 2 support (see v1.x)
  • All icons are compiled to JS, no preprocessing required

Installation

Installation for Vue 3

yarn add vue-tabler-icons

# or

npm i vue-tabler-icons

Installation for Vue 2

Version 2.x is Vue 3 only, if you use Vue 2 then install any 1.x version

yarn add vue-tabler-icons@^1.0

v1.x is no longer a priority so updates may be delayed or discontinued.

Usage

<script>
    // MyComponent.vue
    import { BoldIcon } from "vue-tabler-icons";

    export default {
        components: { BoldIcon },
    };
</script>

<template>
    <bold-icon />
</template>

Using Vue plugin

You may install a Vue plugin that automatically adds all components to the Vue instance.

Note: this usage is not recommended as it cannot be tree-shaken.

import Vue from "vue";
import VueTablerIcons from "vue-tabler-icons";

Vue.use(VueTablerIcons);

Now you can use icons without importing them:

<template>
    <trash-icon />
</template>

Using CDN

If you prefer CDN, then use this URL https://unpkg.com/vue-tabler-icons/dist/vue-tabler-icons.umd.js
The library doesn't automatically registers itself so you need to do it manually:

<script>
    Vue.use(VueTablerIcons);
</script>

Naming pattern

Component names use the same names as defined in the original library with some rules applied:

  • they are in PascalCase
  • underscores before numbers are removed
  • Icon added to the end of the name

For example:

arrows-diagonal-2 will become ArrowsDiagonal2Icon.

Replacements

Following icon names are replaced to match JavaScript variable name pattern:

Original New
2fa.svg TwoFactorAuthIcon
3d-cube-sphere.svg ThreedCubeSphereIcon
3d-cube-sphere-off.svg ThreedCubeSphereIconOff
3d-rotate.svg ThreedRotateIcon
123.svg OneTwoThreeRotateIcon
360-view.svg Deg360ViewIcon
360.svg Deg360Icon

Icon size

All components define size property that you can use to control the icon's size:

<bold-icon size="48" />

Will render 48x48 icon.

All other attributes are directly bound to the underlying SVG image.

Attributes height and width have higher precedence over size property.

Icon color

All icons use currentColor as their color. You can colorize your icons as you do that for text.

<bold-icon style="color: red" /> <bold-icon class="text-red" />

Stroke width and other SVG attributes

Any custom attribute that set on the component will be applied directly to the SVG asset. For example, if you want to set stroke-width attribute just set it as usually:

<bold-icon stroke-width="1" />

Building locally

Clone repo:

git clone https://github.com/alex-oleshkevich/vue-feather-icons.git

Install deps:

yarn install

Run build

yarn build

Icon component will be in icons directory.

Credits

vue-tabler-icons's People

Contributors

alex-oleshkevich avatar amiranagram avatar codecalm avatar mreduar avatar nerijunior avatar tibianmod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-tabler-icons's Issues

Using Tabler Component dynamically?

Not really an issue, but more if a question. I've used the Vue import to bring in all icons, but is there anyway to generically instantiate the icon without the custom component? I'm trying something like this, but it seems... inefficient:

        <template v-if="iconName=='OneTwoThreeIcon'"><OneTwoThreeIcon :size="size" :stroke-width="strokewidth" /></template>
        <template v-else-if="iconName=='TwentyFourHoursIcon'"><TwentyFourHoursIcon :size="size" :stroke-width="strokewidth" /></template>
        <template v-else-if="iconName=='TwoFactorAuthIcon'"><TwoFactorAuthIcon :size="size" :stroke-width="strokewidth" /></template>
        <template v-else-if="iconName=='Deg360Icon'"><Deg360Icon :size="size" :stroke-width="strokewidth" /></template>
        <template v-else-if="iconName=='Deg360ViewIcon'"><Deg360ViewIcon :size="size" :stroke-width="strokewidth" /></template>

What I'm trying to do is something more like:
<TablerIcon :iconName="sMyObject.icon" :size="28" />

Cheers!

Set stroke-width globally

Hi!

First of all, thank you for your work!

I think it will be the good option to set stroke-width globally for all icons.
What do you think about this?

[v1] Missing dev-dependency

Hey,

After I npm i vue-tabler-icons@^1.0 I get the error below.
I'm stuck with Vue2 for the moment and I realise this is not a priority of this project any more, but it is either this or a different library, so yeah ๐Ÿคท๐Ÿผโ€โ™‚๏ธ

โœ– Mix
  Compiled with some errors in 10.97s

ERROR in ./node_modules/vue-tabler-icons/dist/vue-tabler-icons.es.js 1:0-67
Module not found: Error: Can't resolve '@vue/babel-helper-vue-jsx-merge-props' in '/Users/ronaldt/Sites/crm.test/node_modules/vue-tabler-icons/dist'

webpack compiled with 1 error

I temp fixed this by adding the module manually via npm i -D @vue/babel-helper-vue-jsx-merge-props, which is stated it should never be done;

This tool is used internally and there is no reason for you to ever use it.

It now compiles normally;

โœ” Compiled Successfully in 10420ms

I can now continue migrating the icons over, but still hoping you can correct this somehow?

how can i set dynamic icons?

What is the best way to set the icon name dynamically based on a variable? I tried this way and it works, but I don't know if there's a better way to do it.

<component :is="status ? chevron-right-icon':'chevron-left-icon'" />

<script>
export default {
  data () {
    return {
      status: true
    }
  }
}
</script>

If this way is correct, you may update the readme with this info

Missing icon shopping-bag

First of all thank you for your amazing work.
I was looking for shopping-bag icon but i can't found it in Vue2 library

Vue3 installation instructions incorrect

When using npm install vue-tabler-icons, it's installing version ^1.13.0 rather than the latest version of Tabler needed for Vue3, this in turn introduces a whole range of errors when trying to compile. Even when using @latest the same experience is provided, to overcome this npm install vue-tabler-icons@^2.5.0 needed to be used and this is working in my project now and without any errors.

Version 2.1

Hello, first I wanted to thank you for creating the package I have been using it for about a year now, thank you very much for this.

On the other hand, I see that a few weeks ago new 2.0+ versions have been released and I would like to use these new icons. Is there any chance to get an update soon?

Typescript Linting Error

When using your library, the following linting error has started to appear in VSCode for me:

Argument of type '{ size: number; strokeWidth: number; "stroke-width": number; }' is not assignable to parameter of type 'SVGProps'.
  Object literal may only specify known properties, but 'strokeWidth' does not exist in type 'SVGProps'. Did you mean to write 'stroke-width'?ts(2345)

I use it as follows:

<template>
<icon-plus :size="20" :stroke-width="1.5" />
</template>
<script setup lang="ts">
import { IconPlus } from '@tabler/icons-vue'
</script>

Announcement: Remove pre-built (dist) files from the package

Currently, the library ships with pre-built bundles that are ready to be used without any bundles. Just attach a script link and it works.
Since now, this behavior is unwanted and deprecated. These files take up to 5mb and no none should want it.

Alternatives

  1. use bundler with tree shaking and include only icons you want in your app
  2. use simple SVG from https://tabler-icons.io in your apps.

Update to Tabler-Icons 1.76

There are quite a few new icons added in 1.66 and 1.67 as well as a handful in the releases since.
It would be much appreciated if this package could be synced with the latest!

Thanks in advanced and thanks for this plugin! <3

use as a plugin but compile only the icons that are used

actually i use the package as a plugin in NuxtJs like the doc says but this compiles all the icons even those that i'm not using

import Vue from 'vue';
import VueTablerIcons from 'vue-tabler-icons';

Vue.use(VueTablerIcons);

i know that the other aproach is import the icon that im going to use like this

<script>
    // MyComponent.vue
    import { BoldIcon } from 'vue-tabler-icons';

    export default {
        components: { BoldIcon },
    };
</script>

<template>
    <bold-icon />
</template>

but I would like to import only the icons I need into a single file and then that file add it to the vue instance, like fontAwesome does ... is that possible?

[Bug Report] Library doesn't work on IE11 and break application

Environment

Lib version: 1.9.0
Vue version: 2.6.11
Browsers: IE11
OS: Windows 10
App created with Vue CLI, integrating all babel plugin, have a browserslistrc etc...

Steps to reproduce

  1. Create app with Vue CLI,
  2. Add and install vue-tabler-icons
  3. Import and display an icon in a template
  4. Go to check application on IE11

Expected Behavior

Application should worked correctly and icon should be displayed

Actual Behavior

Application doesn't work at all, there is an error in Console ':' expected in chunk-vendor.js (I can see the problem is located at the level of icon imports)

Other comment

I think a good configuration of babel should be enough to fix issue

Missing module

When importing this module via: import VueTablerIcons from 'vue-tabler-icons';
it will throw an error when compiling for every individual icon:

Module not found: Error: Can't resolve 'babel-helper-vue-jsx-merge-props' in '<snip>\node_modules\vue-tabler-icons\icons'
 @ ./node_modules/vue-tabler-icons/icons/AntennaBars2Icon.js 1:0-62 17:20-34
 @ ./node_modules/vue-tabler-icons/icons.js
 @ ./node_modules/vue-tabler-icons/index.js
 @ ./resources/js/app.js
 @ multi ./resources/js/app.js ./resources/sass/app.scss

Configuration Request file

Hi, is any plans for future configuration of the default options? For example, set stroke-width on all icons in one config file?

Now it is in const variable

image

bug: inject all $data into html may cause errors

In https://github.com/alex-oleshkevich/vue-tabler-icons/blob/master/build.js#L24

const allAttrs = {
    ...this.$data,
    width: attrs.width || size,
    height: attrs.height || size,
}

...this.$data will inject all the available data inside the element and it will cause errors when using libraries/plugins that adds data to Vue components like @vue/apollo-option.

Vue Apollo will allow all components in the application to have an $apolloData object inside this.$data and the Icon will try to put $apolloData inside the <svg {...allAttrs} ... tag.

It will cause:

 Failed to execute 'setAttribute' on 'Element': '$apolloData' is not a valid attribute name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.