Web Component Universal Kit
Universal mounting hardware: Native Web Component—works on any DOM wall, with or without a frontend framework.
The Web Component has zero dependency on React or Vue, making it ideal for plain websites, CMS templates, and cross-framework embeds.
For bundled projects we recommend the npm package; blog templates can also drop in the version-pinned script snippet.
npm (Recommended)
npm install @yunlefun-home/air-conditioner-widgetESM, CommonJS, and TypeScript declarations are all included. Register and mount only on the client after the DOM is ready; you may import the module during SSR, but do not call mount helpers on the server.
import { cdnAssets, defineAirConditionerElement } from '@yunlefun-home/air-conditioner-widget'
defineAirConditionerElement({ ...cdnAssets, enableAudio: false })<air-conditioner-widget storage-key="ac:state"></air-conditioner-widget>mount API
import { cdnAssets, mountAirConditioner } from '@yunlefun-home/air-conditioner-widget'
mountAirConditioner('#ac', {
storageKey: 'ac:state',
...cdnAssets,
enableAudio: false,
})The appearance matches the Vue and React components (energy label, seven-segment display, logo, louver, and round remote buttons). Shadow DOM styles are synced from Vue's style.css; after editing styles, run pnpm -C packages/widget run sync:style.
| Option | Default | Description |
|---|---|---|
logoUrl | /yun-logo.svg | Center logo image URL; pass '' to hide |
assetsBaseUrl | /assets | Base path for fonts/digital-7-mono.ttf and audio/ |
audioExt | m4a | Audio file extension |
enableAudio | true | Enable button beep and fan sound effects |
showEnergyLabel | true | Show the energy efficiency sticker |
title | — | Alt text / link title for the center logo |
placement | inline | inline, or top-left / top-right corner mount |
locale | zh | UI language: zh / en (remote toggle, LCD, and screen-reader text). Also settable via the locale HTML attribute; labels overrides individual strings |
Because
@font-faceinside Shadow DOM is ignored by browsers, the component injects the digital font rule once intodocument.head.When
status/mode/temperature/sound/swing/fanattributes are omitted, persisted local state is used.fanacceptsauto,low,medium,high(see Fan Speed);soundacceptsnormal,sleep,mute(see Audio and Sound Modes);swing="false"disables oscillation while any other value enables it (see Airflow and Swing).
Corner Floating Install
Open the interactive Floating Widget demo to try left/right wall mounting and folding the remote.
To let visitors cool off while reading blog posts without reserving iframe space (#31), mount the widget to a screen corner:
import { cdnAssets, mountAirConditioner } from '@yunlefun-home/air-conditioner-widget'
// Mount to document.body on the client so ancestor transform/filter does not break fixed positioning.
const widget = mountAirConditioner(document.body, {
placement: 'top-right',
storageKey: 'blog:ac',
...cdnAssets,
enableAudio: false,
})
// Move walls anytime, or set 'inline' to restore normal flow.
widget.setAttribute('placement', 'top-left')
// Clean up audio and listeners when leaving the page.
// widget.remove()Once registered, plain HTML markup works too:
<air-conditioner-widget placement="top-right" storage-key="blog:ac"></air-conditioner-widget>Click or press Enter / Space on the toggle button to expand the remote, and press Esc to fold it while keeping the AC running. Unknown placement values fall back to inline.
The body scales down smoothly on narrow screens, and the area between the AC unit and the remote remains clickable and scrollable. Customize z-index (default 1000) via --acw-floating-z-index. cdnAssets uses version-pinned jsDelivr URLs, or you can self-host the assets.
Events
const widget = document.querySelector('air-conditioner-widget')
widget?.addEventListener('ac-change', (event) => {
console.log(event.detail.state)
})
widget?.addEventListener('ac-notify', (event) => {
console.log(event.detail.notification)
})