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

@molecule/app-inline-style-dom

v1.2.0

Published

React-compatible inline style serialization and DOM updates

Readme

@molecule/app-inline-style-dom

React-compatible inline style serialization and DOM updates for web UI kits.

Serialize React-shaped style objects for HTML attributes with reactStyleText. Use toStyleProps when a renderer takes CSS property names and string values. Use bindInlineStyle to update an element's styles without replacing its entire style attribute.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { bindInlineStyle, reactStyleText } from '@molecule/app-inline-style-dom'

const style = { marginTop: 8, opacity: 0.5, '--accentHue': 280 }
const attribute = reactStyleText(style)
const element = document.querySelector<HTMLElement>('[data-mol-id="preview"]')
if (element) {
  const binding = bindInlineStyle(element, style)
  binding.update({ marginTop: 0, opacity: 1 })
}

Type

utility

Installation

npm install @molecule/app-inline-style-dom

API

Interfaces

InlineStyleBinding

Inline styles applied to one element.

interface InlineStyleBinding {
  /** Apply the next style object and clear declarations that dropped out. */
  update: (style: unknown) => void
  /** Clear the binding's declarations from the element. */
  destroy: () => void
}

CoverImageStyle

The background declarations an element paints for its style.coverImage.

interface CoverImageStyle {
  /** The image, as a CSS `url()`; undefined for an empty URI, which paints no image. */
  backgroundImage: string | undefined
  /** The image covers the whole box. */
  backgroundSize: 'cover'
  /** The image is centred in the box. */
  backgroundPosition: 'center'
}

Types

CSSStyle

A React-shaped inline style object. Custom property names retain their spelling.

type CSSStyle = Record<string, string | number | boolean | null | undefined>

Functions

toCssPropertyName(name)

Converts a React property name to its CSS spelling.

function toCssPropertyName(name: string): string
  • name — A camelCase, vendor-prefixed or custom property name.

Returns: The CSS property name.

coverImageStyle(url)

The declarations an element's style.coverImage (BoxProps['style'] in @molecule/app-ui) paints on the web: the image behind the contents, centred and sized to cover the box.

function coverImageStyle(url: string | undefined): CoverImageStyle
  • url — The image URI, or undefined for none.

Returns: The background declarations, in the order the React kit writes them.

reactStyleText(style, space)

Serializes a React-shaped style object as React DOM's style attribute value. The renderer escapes the value when it writes HTML.

function reactStyleText(style: unknown, space?: '' | ' '): string | undefined
  • style — The style object, or an absent value.
  • space — An optional space after separators for existing bindings that use spaced CSS.

Returns: The CSS declaration text, or undefined when there are no declarations.

toStyleProps(style)

Normalizes a React-shaped style object for renderers that accept a CSS property map.

function toStyleProps(style: unknown): Record<string, string> | undefined
  • style — The style object, or an absent value.

Returns: CSS property names and string values, or undefined for an absent object.

bindInlineStyle(node, style)

Binds a React-shaped style object to an element. Changes reach the CSSOM in object key order. The binding clears declarations it applied and preserves styles from other writers.

function bindInlineStyle(node: ElementCSSInlineStyle, style: unknown): InlineStyleBinding
  • node — An HTML or SVG element with inline styles.
  • style — The initial style object, or an absent value.

Returns: The binding's update and cleanup hooks.