npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ophiuchus/button

v1.0.2

Published

### 介绍

Readme

Button 按钮

介绍

按钮用于触发一个操作,如提交表单。

引入

import Vue from 'vue';
import Button from "@ophiuchus/button";

Vue.use(Button);

代码演示

按钮类型

按钮支持 defaultprimaryinfowarningdanger 五种类型,默认为 default

<sf-button type="primary">主要按钮</sf-button>
<sf-button type="info">信息按钮</sf-button>
<sf-button type="default">默认按钮</sf-button>
<sf-button type="warning">警告按钮</sf-button>
<sf-button type="danger">危险按钮</sf-button>

朴素按钮

通过 plain 属性将按钮设置为朴素按钮,朴素按钮的文字为按钮颜色,背景为白色。

<sf-button plain type="primary">朴素按钮</sf-button>
<sf-button plain type="info">朴素按钮</sf-button>

细边框

设置 hairline 属性可以展示 0.5px 的细边框。

<sf-button plain hairline type="primary">细边框按钮</sf-button>
<sf-button plain hairline type="info">细边框按钮</sf-button>

禁用状态

通过 disabled 属性来禁用按钮,禁用状态下按钮不可点击。

<sf-button disabled type="primary">禁用状态</sf-button>
<sf-button disabled type="info">禁用状态</sf-button>

加载状态

通过 loading 属性设置按钮为加载状态,加载状态下默认会隐藏按钮文字,可以通过 loading-text 设置加载状态下的文字。

<sf-button loading type="primary" />
<sf-button loading type="primary" loading-type="spinner" />
<sf-button loading type="info" loading-text="加载中..." />

按钮形状

通过 square 设置方形按钮,通过 round 设置圆形按钮。

<sf-button square type="primary">方形按钮</sf-button>
<sf-button round type="info">圆形按钮</sf-button>

图标按钮

通过 icon 属性设置按钮图标,支持 Icon 组件里的所有图标,也可以传入图标 URL。

<sf-button icon="plus" type="primary" />
<sf-button icon="plus" type="primary">按钮</sf-button>
<sf-button icon="https://img3.tuhu.org/3rq0A7JtvChtaD5QMO3HgA_w98_h78.png" type="info">
  按钮
</sf-button>

按钮尺寸

支持 largenormalsmallmini 四种尺寸,默认为 normal

<sf-button type="primary" size="large">大号按钮</sf-button>
<sf-button type="primary" size="normal">普通按钮</sf-button>
<sf-button type="primary" size="small">小型按钮</sf-button>
<sf-button type="primary" size="mini">迷你按钮</sf-button>

块级元素

按钮在默认情况下为行内块级元素,通过 block 属性可以将按钮的元素类型设置为块级元素。

<sf-button type="primary" block>块级元素</sf-button>

页面导航

可以通过 url 属性进行 URL 跳转,或通过 to 属性进行路由跳转。

<sf-button type="primary" url="/demo.html">URL 跳转</sf-button>
<sf-button type="primary" to="index">路由跳转</sf-button>

自定义颜色

通过 color 属性可以自定义按钮的颜色。

<sf-button color="#7232dd">单色按钮</sf-button>
<sf-button color="#7232dd" plain>单色按钮</sf-button>
<sf-button color="linear-gradient(to right, #ff6034, #ee0a24)">
  渐变色按钮
</sf-button>

API

Props

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | | type | 类型,可选值为 primary info warning danger | string | default | | size | 尺寸,可选值为 large small mini | string | normal | | text | 按钮文字 | string | - | | color | 按钮颜色,支持传入 linear-gradient 渐变色 | string | - | | icon | 左侧图标名称或图片链接 | string | - | | icon-prefix | 图标类名前缀,同 Icon 组件的 class-prefix 属性 | string | sf-icon | | icon-position | 图标展示位置,可选值为 right | string | left | | tag | 按钮根节点的 HTML 标签 | string | button | | native-type | 原生 button 标签的 type 属性 | string | - | | block | 是否为块级元素 | boolean | false | | plain | 是否为朴素按钮 | boolean | false | | square | 是否为方形按钮 | boolean | false | | round | 是否为圆形按钮 | boolean | false | | disabled | 是否禁用按钮 | boolean | false | | hairline | 是否使用 0.5px 边框 | boolean | false | | loading | 是否显示为加载状态 | boolean | false | | loading-text | 加载状态提示文字 | string | - | | loading-type | 加载图标类型,可选值为 spinner | string | circular | | loading-size | 加载图标大小 | string | 20px | | url | 点击后跳转的链接地址 | string | - | | to | 点击后跳转的目标路由对象,同 vue-router 的 to 属性 | string | object | - | | replace | 是否在跳转时替换当前页面历史 | boolean | false |

Events

| 事件名 | 说明 | 回调参数 | | ---------- | ---------------------------------------- | ------------------- | | click | 点击按钮,且按钮状态不为加载或禁用时触发 | event: Event | | touchstart | 开始触摸按钮时触发 | event: TouchEvent |

Slots

| 名称 | 说明 | | ----------------- | -------------- | | default | 按钮内容 | | icon | 自定义图标 | | loading | 自定义加载图标 |

样式变量

组件提供了下列 Less 变量,可用于自定义样式,使用方法请参考主题定制

| 名称 | 默认值 | 描述 | | -------------------------------- | -------------------- | ---- | | @button-mini-height | 24px | - | | @button-mini-font-size | @font-size-xs | - | | @button-small-height | 32px | - | | @button-small-font-size | @font-size-sm | - | | @button-normal-font-size | @font-size-md | - | | @button-large-height | 50px | - | | @button-default-height | 44px | - | | @button-default-line-height | 1.2 | - | | @button-default-font-size | @font-size-lg | - | | @button-default-color | @text-color | - | | @button-default-background-color | @white | - | | @button-default-border-color | @border-color | - | | @button-primary-color | @white | - | | @button-primary-background-color | @green | - | | @button-primary-border-color | @green | - | | @button-info-color | @white | - | | @button-info-background-color | @blue | - | | @button-info-border-color | @blue | - | | @button-danger-color | @white | - | | @button-danger-background-color | @red | - | | @button-danger-border-color | @red | - | | @button-warning-color | @white | - | | @button-warning-background-color | @orange | - | | @button-warning-border-color | @orange | - | | @button-border-width | @border-width-base | - | | @button-border-radius | @border-radius-sm | - | | @button-round-border-radius | @border-radius-max | - | | @button-plain-background-color | @white | - | | @button-disabled-opacity | @disabled-opacity | - |