@duskmoon-dev/el-button

中文文档
1.10.3发布于 2026/11/11TypeScriptESM + CJS构建来源已验证近 30 天下载 2583

A customizable button component for DuskMoon Elements. ok,

原始使用文档
文档目录17 节
  1. Installation
  2. Usage
  3. Auto-Register (Recommended)
  4. Manual Registration
  5. Variants
  6. Sizes
  7. Shapes
  8. Attributes
  9. Slots
  10. CSS Parts
  11. CSS Custom Properties
  12. Examples
  13. With Icons
  14. Loading State
  15. Accessible Icon Buttons
  16. Form Submit
  17. License

@duskmoon-dev/el-button

A customizable button component for DuskMoon Elements. ok,

Installation

bun add @duskmoon-dev/el-button

Usage

The simplest way to use the component - just import and it's ready:

<!-- Via CDN -->
<script type="module" src="https://esm.sh/@duskmoon-dev/el-button/register"></script>

<!-- Now use the element -->
<el-dm-button>Click me</el-dm-button>
<el-dm-button variant="secondary">Secondary</el-dm-button>
<el-dm-button variant="outline" size="lg">Large Outline</el-dm-button>

Or with a bundler:

import '@duskmoon-dev/el-button/register';

Manual Registration

<script type="module">
  import { register } from '@duskmoon-dev/el-button';
  register();
</script>

<el-dm-button>Click me</el-dm-button>

Variants

VariantDescription
primaryPrimary action button (default)
secondarySecondary action button
tertiaryTertiary/subtle button
ghostTransparent background button
outlineBorder-only button

Sizes

SizeDescription
xsExtra small
smSmall
mdMedium (default)
lgLarge
xlExtra large

Shapes

Use shape="circle" or shape="square" for icon buttons. Omit shape for the default rectangular button.

<el-dm-button variant="outline" size="xs" shape="circle" aria-label="Add">
  <svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16">
    <path d="M8 2v12M2 8h12" stroke="currentColor" />
  </svg>
</el-dm-button>
<el-dm-button shape="square" aria-label="Add">
  <svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16">
    <path d="M8 2v12M2 8h12" stroke="currentColor" />
  </svg>
</el-dm-button>

Attributes

AttributeTypeDefaultDescription
variantstringprimaryButton variant
sizestringmdButton size
shapestring—Optional shape: circle or square
disabledbooleanfalseDisable the button
typestringbuttonButton type (button, submit, reset)
loadingbooleanfalseShow loading spinner
aria-labelstring—Accessible name for an icon-only button
aria-labelledbystring—IDs of label elements in the host's DOM tree

Slots

SlotDescription
(default)Button content
prefixContent before main text
suffixContent after main text

CSS Parts

PartDescription
buttonThe native button element
contentContent wrapper
prefixPrefix slot wrapper
suffixSuffix slot wrapper
spinnerLoading spinner

CSS Custom Properties

PropertyDescription
--dm-button-padding-xHorizontal padding
--dm-button-padding-yVertical padding
--dm-button-font-sizeFont size
--dm-button-border-radiusBorder radius

Examples

With Icons

<el-dm-button>
  <span slot="prefix">🚀</span>
  Launch
</el-dm-button>

Loading State

<el-dm-button loading>Submitting...</el-dm-button>

Accessible Icon Buttons

Set aria-label on an icon-only button. The label is synchronized with the native button, including changes made after rendering.

<el-dm-button aria-label="Remove email">
  <svg aria-hidden="true" viewBox="0 0 24 24">
    <path d="M5 5L19 19M19 5L5 19" />
  </svg>
</el-dm-button>

<span id="remove-email-label">Remove email</span>
<el-dm-button aria-labelledby="remove-email-label">×</el-dm-button>

aria-labelledby resolves IDs in the host's document or containing shadow root and takes precedence over aria-label when a target exists. Browsers supporting ARIA element references use the referenced elements directly; older browsers use their text content or aria-label. Label text changes and replacement label elements are synchronized. Without either attribute, the slotted content provides the accessible name.

Form Submit

<form>
  <el-dm-button type="submit">Submit Form</el-dm-button>
</form>

License

MIT

版本与发布记录

@duskmoon-dev/el-button 共发布 54 个版本,首次发布于 2026/01/04;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.10.3latest2026/11/112 天前
1.10.22026/10/2222 天前
1.10.12026/10/1627 天前
1.10.02026/10/1628 天前
1.9.32026/10/131 个月前
1.9.22026/10/131 个月前

关于 @duskmoon-dev/el-button 的常见问题

@duskmoon-dev/el-button 是什么?

A customizable button component for DuskMoon Elements. ok,

如何安装 @duskmoon-dev/el-button?

在项目目录运行 npm install @duskmoon-dev/el-button,或使用 pnpm add / yarn add / bun add。

@duskmoon-dev/el-button 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@duskmoon-dev/el-button 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@duskmoon-dev/el-button 可以商用吗?

@duskmoon-dev/el-button 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@duskmoon-dev/el-button 的下载量有多少?

根据 npm 官方下载统计,@duskmoon-dev/el-button 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,583 次,日均约 86 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@duskmoon-dev/el-button 还在维护吗?

最新版本 1.10.3 发布于 2026/11/11(2 天前);至今共发布 54 个版本,其中过去 12 个月发布了 54 个;首次发布于 2026/01/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。