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

@mosaic-home/ha-widgets

v0.1.1

Published

Home Assistant widgets written once: what each widget fetches, shows and does, for React cards and Android home-screen widgets alike.

Readme

@mosaic-home/ha-widgets

Home Assistant widgets written once: for each widget type, which entities and options it takes, what it needs fetched, and what it shows. What it shows is a View, plain data that any renderer can draw. This package has a React renderer; @mosaic-home/capacitor-ha-widgets draws the same views on the Android home screen.

Part of the Mosaic Home Assistant kit.

Widget types

Light, Switch, Thermostat, Sensor, Graph, Weather, Media player, Button, Blinds and doors, Lock, Fan, Camera, Several entities, People, To-do list, Calendar, Ask the assistant, Lights on, Doors and windows, Batteries, Number, Choice, Timer, Vacuum and mower, Alarm, and Entity (any entity). WIDGET_TYPES lists them in gallery order; typesForEntity gives the types that fit an entity, best first.

Install

npm install @mosaic-home/ha-widgets
npm install react      # only for the React renderer

Use

import { buildView, needsFor, newConfig, type WidgetContext, type WidgetData } from '@mosaic-home/ha-widgets';
import { iconPath } from '@mosaic-home/ha-widgets/icons';
import { WidgetView } from '@mosaic-home/ha-widgets/react';
import '@mosaic-home/ha-widgets/react.css';

const config = newConfig('light', ['light.kitchen']);
const context: WidgetContext = { now: Date.now(), locale: 'en-GB', temperatureUnit: '°C' };

// What to fetch: here one state. Others are a whole domain, history, a service's response or the assistant's answer.
console.log(needsFor(config, context)); // [{ kind: 'state', entityId: 'light.kitchen' }]

const data: WidgetData = {
  states: {
    'light.kitchen': { entity_id: 'light.kitchen', state: 'on', attributes: { friendly_name: 'Kitchen', brightness: 153 } },
  },
};
const view = buildView(config, data, context);

export function KitchenLight() {
  return <WidgetView view={view} size={{ width: 2, height: 1 }} icon={iconPath} onAction={(action) => console.log(action)} />;
}

onAction receives what a tap asks for: call a service, ask the assistant, refresh, or open the app. The app runs it against Home Assistant (for example with @mosaic-home/ha-client) and builds the view again. buildView never throws: missing entities and unknown types become a view that says so.

Entry points

| Import | What it is | |---|---| | @mosaic-home/ha-widgets | The catalogue, needsFor, buildView, entity and formatting helpers, and the types | | @mosaic-home/ha-widgets/react | WidgetView, the React renderer | | @mosaic-home/ha-widgets/react.css | Its styles | | @mosaic-home/ha-widgets/icons | iconPath: an SVG path for a Material Design Icons name. Brings in the whole icon set | | @mosaic-home/ha-widgets/engine.js | Everything in one classic script for engines without modules or a DOM; it sets globalThis.MosaicWidgets with needs, build and types, each taking and returning JSON |

What it needs

Nothing but @mdi/js (installed with it). React 18 or newer only if you use the React renderer.

Licence

Apache-2.0. Icons are Material Design Icons from @mdi/js (Apache-2.0).