🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@ophiuchus/icon

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ophiuchus/icon

### 介绍

latest
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

Icon 图标

介绍

基于字体的图标集,可以通过 Icon 组件使用,也可以在其他组件中通过 icon 属性引用。

引入

import Vue from 'vue';
import Icon from "@ophiuchus/icon";

Vue.use(Icon);

代码演示

基础用法

Iconname 属性支持传入图标名称或图片链接,所有可用的图标名称见右侧示例。

<sf-icon name="like-o" />
<sf-icon name="https://img3.tuhu.org/3rq0A7JtvChtaD5QMO3HgA_w98_h78.png" />

徽标提示

设置 dot 属性后,会在图标右上角展示一个小红点;设置 badge 属性后,会在图标右上角展示相应的徽标。

<sf-icon name="like-o" dot />
<sf-icon name="like-o" badge="9" />
<sf-icon name="like-o" badge="99+" />

图标颜色

Iconcolor 属性用来设置图标的颜色。

<sf-icon name="star-o" color="#1989fa" />
<sf-icon name="like-o" color="#ee0a24" />

图标大小

Iconsize 属性用来设置图标的尺寸大小,默认单位为 px

<sf-icon name="like-o" size="40" /> <sf-icon name="like-o" size="3rem" />

自定义图标

如果需要在现有 Icon 的基础上使用更多图标,可以引入第三方 iconfont 对应的字体文件和 CSS 文件,之后就可以在 Icon 组件中直接使用。

/* 引入第三方或自定义的字体图标样式 */
@font-face {
  font-family: 'my-icon';
  src: url('./my-icon.ttf') format('truetype');
}

.my-icon {
  font-family: 'my-icon';
}

.my-icon-extra::before {
  content: '\e626';
}
<!-- 通过 class-prefix 指定类名为 my-icon -->
<sf-icon class-prefix="my-icon" name="extra" />

API

Props

参数说明类型默认值
name图标名称或图片链接string-
dot是否显示图标右上角小红点booleanfalse
badge图标右上角徽标的内容number | string-
color图标颜色stringinherit
size图标大小,如 20px 2em,默认单位为pxnumber | stringinherit
class-prefix类名前缀,用于使用自定义图标stringsf-icon
tagHTML 标签stringi

Events

事件名说明回调参数
click点击图标时触发event: Event

Keywords

ui

FAQs

Package last updated on 26 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts