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IuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square) ![](https://img.shields.io/badge/build-passing-success) [![](https://img.shields.io/npm/dm/akar-icons-web-components.svg)](https://www.npmjs.com/package/akar-icons-web-components) ![](http://img.shields.io/badge/license-MIT-lightgrey) [![](https://data.jsdelivr.com/v1/package/npm/akar-icons-web-components/badge)](https://www.jsdelivr.com/package/npm/akar-icons-web-components)


[AkarIcons Web Components](https://github.com/awmleer/akar-icons-web-components) is a non-official [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) wrapper for the amazing [AkarIcons](https://akaricons.com/).

Also a handy icon framework for dynamically customizable icons.

![](https://raw.githubusercontent.com/awmleer/akar-icons-web-components/master/assets/img/banner.gif)

## Features

- Framework **INDEPENDENT**, [AkarIcons Web Components](https://github.com/awmleer/akar-icons-web-components) can be **DIRECTLY** used in **ANY** frameworks: [React](https://reactjs.org/), [Vue.js](https://vuejs.org/), you name it 🤗
- With **lazy loading** icons, the main script weighs **~4KB**, loading each uncached icon costs **~0.5KB** increacement 🤩
- Fully customizable, dynamically color changing is ancient, how about changing **`stroke-width`** and **`line-style`** **ON THE FLY**? 🤯

Read more about the design philosophies in [this article](https://dev.to/johntheo/lazy-loading-svg-icons-using-web-components-3foi)! 📄

## Getting Started

```html
<script src="https://cdn.jsdelivr.net/npm/akar-icons-web-components" type="module"></script>

<body>
  <akar-icon name="bicycle">
</body>
```

And voilà, the icon is ready.

[![](https://raw.githubusercontent.com/awmleer/akar-icons-web-components/master/assets/img/codepen.png)](https://codepen.io/john-theo/pen/LYLddpd)

Play around with [the CodePen](https://codepen.io/john-theo/pen/LYLddpd).

## Advanced Usage

### Appetizer

Note on the top right corner of the CodePen, there is a dropdown menu. Open and have fun with it.

> Value for the `name` field can be copied from [AkarIcons homepage](https://akaricons.com/) without the `ai-` prefix, eg. `arrow-left`

### Main Course

Everything the menu changes, is simply attributes for the `<akar-icon>` tag.

So `<akar-icon name="air" size="50">` will be rendered as a 50px ✕ 50px AkarIcons air icon.

**Attributes**

| Attribute | Type     | Css Var    | Default     |
| --------- | -------- | ---------- | ----------- |
| `name`    | `string` |            | (Required)  |
| `size`    | `number` | `--size`   | `24`        |
| `color`   | `string` | `color`    | `"inherit"` |
| `stroke`  | `number` | `--stroke` | `1`         |
| `cap`     | `enum`   | `--cap`    | `"round"`   |
| `join`    | `enum`   | `--join`   | `"round"`   |

> Valid values for `cap` and `join` can be found [here](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linecap) and [here](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-linejoin).

Try the following examples:

```html
<akar-icon name="bicycle" size="50" cap="butt" join="miter"/> </akar-icon>
```

```html
<akar-icon name="air" stroke="2" style="transform: scaleX(-1)"/> </akar-icon>
```

Or set a universal style for all `<akar-icon>`s:

```html
<style>
  akar-icon {
    --cap: butt;
  }
</style>
```

And yes, it's that simple! 😇

## Features (may be) Coming

- Visual alignment adjustment configs
- Framework(React, etc)-friendly wrappers
- Dichromatic Icons
- SVG ANIMATIONS 🤟
- Use <use> tag to reduce elements inserted into page
- Use localstorage to mimic cache


## Change Log

- **`0.1/0.2`** Sep 19, 2021. First commit!

## Dev Preparations

```bash
git clone git@github.com:awmleer/akar-icons-web-components.git
yarn run start
```

## Authors

- 卡晨 [@awmleer](https://github.com/awmleer)
- John [@John-Theo](https://github.com/John-Theo)

## License
MIT License, Copyright © 2021-present @awmleer and @John-Theo.