@cityssm/bulma-js

中文文档
1.0.0-rc.4发布于 2026/02/27MITES Module零依赖近 30 天下载 1957

The unofficial missing JavaScript library for Bulma websites

原始使用文档
文档目录14 节
  1. Getting Started
  2. Options
  3. Toggle Functionality
  4. Set Unique Element Id Prefix
  5. Set the "Initialized" Attribute Name
  6. Initialize Functionality on Entire Page
  7. Initialize Functionality on the Children of an Element
  8. Features So Far
  9. Delete Buttons (Messages, Notifications, and Tags)
  10. Navbar
  11. Dropdown
  12. Tabs
  13. Modal Alerts and Confirms
  14. Alternative Bulma JavaScript Project

bulma-js

Codacy grade

Made with Bulma

The unofficial missing JavaScript library for Bulma websites.

Getting Started

Download bulma-js.js here, use the jsDelivr CDN, or install from npm.

npm install @cityssm/bulma-js

Add the following to your HTML.

<script src="dist/bulma-js.js"></script>
<script>
  bulmaJS.init()
</script>

Options

Toggle Functionality

bulmaJS.setConfig('bulma.burger', true)
bulmaJS.setConfig('bulma.dropdown', true)
bulmaJS.setConfig('dropdown', true)
bulmaJS.setConfig('tabs', true)
bulmaJS.setConfig('window.collapse', true) // close dropdowns when clicked outside

Set Unique Element Id Prefix

bulmaJS.setConfig('bulmaJS.elementIdPrefix', 'bulma-js-')

Set the "Initialized" Attribute Name

bulmaJS.setConfig('bulmaJS.initAttribute', 'data-bulma-js-init')

Initialize Functionality on Entire Page

Can be called multiple times after page contents have changed.

bulmaJS.init()

Initialize Functionality on the Children of an Element

Helpful after populating an area with an AJAX call.

bulmaJS.init(document.getElementById('container-element'))

Features So Far

  • Toggles appropriate Bulma classes and ARIA attributes.
  • Close dropdown and navbar-dropdown elements when other parts of the webpage are clicked.

Delete Buttons (Messages, Notifications, and Tags)

https://bulma.io/documentation/elements/notification/, https://bulma.io/documentation/components/message/, https://bulma.io/documentation/elements/tag/

  • Support for delete buttons within notification, message, and tag elements. (Thanks thibaultmeyer for the feature.)

Navbar

https://bulma.io/documentation/components/navbar/

  • Support for the navbar-burger element.
  • Support for the navbar-dropdown elements.

Dropdown

https://bulma.io/documentation/components/dropdown/

  • Support for the dropdown elements.

Tabs

https://bulma.io/documentation/components/tabs/

  • Support for the tabs elements.
  • Use the href attribute on each tab anchor element to link to the corresponding tab panel.
  • All tab panels should be siblings. Hide the inactive tab panels with the is-hidden class.

Modal Alerts and Confirms

Methods for creating accessible alerts and confirms.

bulmaJS.alert('This is a basic alert!')

bulmaJS.alert({
  title: 'Alert',
  message: 'This is a <strong>more complex</strong> alert.',
  messageIsHtml: true,
  contextualColorName: 'success',
  okButton: {
    text: 'Yes, But Not Too Complex',
    callbackFunction: () => {
      console.log('OK Button Pressed')
    }
  }
})

bulmaJS.confirm({
  title: 'Question',
  message: 'Have you ever been to Sault Ste. Marie, Ontario?',
  contextualColorName: 'primary',
  okButton: {
    text: 'Yes, I Have',
    callbackFunction: () => {
      console.log('OK Button Pressed')
    }
  },
  cancelButton: {
    text: "No, But I'd Like To",
    callbackFunction: () => {
      console.log('Cancel Button Pressed')
    }
  }
})

Alternative Bulma JavaScript Project

The BulmaJS project also provides JavaScript functionality for Bulma, and is far more complete than this project. I recommend you take a look if you need more functionality than is offered here.

This project goes in a different direction in a few ways.

  • Prioritizes simple usage in an HTML script tag. No import or require necessary.
  • TypeScript types available.
  • Goes beyond just toggling the is-active Bulma classes, and manages ARIA attributes as well to increase accessibility.
  • Attempts to correct common issues (i.e. missing roles, missing ids) that may affect accessibility.

版本与发布记录

@cityssm/bulma-js 共发布 13 个版本,首次发布于 2021/11/23;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.0.0-rc.4latest2026/02/278 个月前
1.0.0-rc.32025/08/141.2 年前
1.0.0-rc.22025/08/141.2 年前
1.0.0-rc.12025/06/061.4 年前
1.0.0-rc2024/12/111.9 年前
0.5.02024/04/232 年前

关于 @cityssm/bulma-js 的常见问题

@cityssm/bulma-js 是什么?

The unofficial missing JavaScript library for Bulma websites

如何安装 @cityssm/bulma-js?

在项目目录运行 npm install @cityssm/bulma-js,或使用 pnpm add / yarn add / bun add。

@cityssm/bulma-js 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/cityssm__bulma-js 是否存在。

@cityssm/bulma-js 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cityssm/bulma-js 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@cityssm/bulma-js 可以商用吗?

@cityssm/bulma-js 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cityssm/bulma-js 的下载量有多少?

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

@cityssm/bulma-js 还在维护吗?

最新版本 1.0.0-rc.4 发布于 2026/02/27(8 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 1 个;首次发布于 2021/11/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。