Skip to content

Icon 图标

PixelUI 组件库的图标集合来自 pixel-icon-library. 提供 400+ 独特的像素化矢量图标, 且各自拥有 4 种变体

使用图标

  • 如果你想像用例一样直接使用, 你需要全局引入第三方图标库, 才能在项目里直接使用。

安装

TIP

方便使用, 已将 pixel-icon-library 集成到 PixelUI 组件库里, 你可以不用引入第三方图标库及其样式。

使用包管理器

选择一个你喜欢的包管理器

shell
$ npm install @hackernoon/pixel-icon-library
shell
$ yarn add @hackernoon/pixel-icon-library
shell
$ pnpm install @hackernoon/pixel-icon-library
shell
$ bun add @hackernoon/pixel-icon-library
shell
$ 别用 deno, 会变得不幸

引入图标库样式

ts
import '@hackernoon/pixel-icon-library/fonts/iconfont.css'

基础用法

查阅 图标库 icon 名称, 通过 icon 属性传入即可, 使用 typecolorsize 修改图标样式

<template>
  <p>
    <px-icon icon="gaming" class="mr-10" />
    <px-icon icon="github" type="primary" class="mr-10" />
    <px-icon icon="management" type="success" class="mr-10" />
    <px-icon icon="plane" type="warning" class="mr-10" />
    <px-icon icon="translate" type="danger" class="mr-10" />
  </p>
  <p>
    <px-icon icon="gaming" size="35" class="mr-10" />
    <px-icon icon="github" type="primary" size="35" class="mr-10" />
    <px-icon icon="management" type="success" size="35" class="mr-10" />
    <px-icon icon="plane" type="warning" size="35" class="mr-10" />
    <px-icon icon="translate" type="danger" size="35" class="mr-10" />
  </p>
  <p>
    <px-icon icon="gaming" size="20" color="red" class="mr-10" />
    <px-icon icon="github" size="20" color="#ff4785" class="mr-10" />
    <px-icon icon="management" size="20" color="rgb(0,212,255)" class="mr-10" />
    <px-icon icon="plane" size="20" color="hsl(265, 100%, 50%)" class="mr-10" />
    <px-icon icon="translate" size="20" color="hwb(38 0% 0%)" class="mr-10" />
  </p>
</template>

图标翻转

通过 fliprotation 属性控制图标翻转

<template>
  <px-icon
    icon="face-thinking"
    flip="horizontal"
    color="orange"
    size="35"
    class="mr-10"
  />
  <px-icon
    icon="face-thinking"
    flip="vertical"
    color="orange"
    size="35"
    class="mr-10"
  />
  <px-icon
    icon="face-thinking"
    flip="both"
    color="orange"
    size="35"
    class="mr-10"
  />
  <px-icon
    icon="face-thinking"
    rotation="270"
    color="orange"
    size="35"
    class="mr-10"
  />
</template>

图标动画

通过 spinbounceshakebeat 属性控制图标动画

<template>
  <px-icon icon="startups" spin color="green" size="35" class="mr-10" />
  <px-icon icon="startups" bounce color="green" size="35" class="mr-10" />
  <px-icon icon="startups" shake color="green" size="35" class="mr-10" />
  <px-icon icon="startups" beat color="green" size="35" class="mr-10" />
</template>

Icon API

Props

NameDescriptionTypeDefault
icon图标名称string-
size图标大小number/string14
type图标类型enum - primary | success | warning | danger | basebase
color图标颜色string#212529
flip图标翻转enum - horizontal | vertical | both-
rotation图标旋转角度number/string-
spin图标旋转动画booleanfalse
bounce图标上下弹动动画booleanfalse
shake图标左右摇晃动画booleanfalse
beat图标心跳动画booleanfalse
本站访客数 人次 本站总访问量