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

laws-of-form-react

v1.0.4

Published

A Laws of Form (1969) React library. Easily generate dynamical LoF Graphics. Moreover, LoF syntax highlighting, parsing and input fields are available.

Readme

Ⓞ Laws of Form React

This lightweight and fast react library allows you to convert expressions – including the reentry – from Spencer-Brown's Laws of Form (1969) into interactive and pure HTML/CSS graphics. Moreover, LoF syntax highlighting, parsing and input fields are available.

Github

NPM

Author Portfolio

🚀 Features

  1. Easily transform LoF bracket expressions into interactive and customizable graphics.
  2. Works with re-entries
  3. Custom LoF input field with syntax highlighting
  4. TS Support

👷 How to install

npm install laws-of-form-react

🔧 How to use

Full tutorial available on the LoF react website

Ⓞ Drawing distinctions

First import the library

import LoF from "laws-of-form-react"
  1. A cross is marked with ()
<LoF>
  ()
</LoF>
  1. Any text in space is interpreted as the content of the space
<LoF>
  ((Observer) Society)
</LoF>
  1. You can nest crosses
<LoF>
  ((())())
</LoF>
  1. A Re-Entry is made out of two identifiers. $id and [id]. $id denotes the space that enters into [id]. id must be a number. There can be multiple $ids in a space, but only the rightmost counts.
<LoF>
  (([0]a)$0b)
</LoF>

<LoF>
  (([42]$42) Autopoiesis)
</LoF>
  1. A space can also re-enter into two locations (see limitations).
<LoF>
  (([0]c)([0]a)$0b)
</LoF>
  1. Multiple Re-Entries are also possible
<LoF>
  ([3]([0]$0)([1]$1)$3)
</LoF>
  1. This is how you could implement the modulator function (see the first image above)
<LoF style={{fontSize: '20px'}}>
  (((((((([0]a$1)$6[2])[1]$3)[0]$4)a$5)$2[6])[5]) [4]$0)
</LoF>

🌈 Syntax Highlighting

This library provides customizable syntax highlighting for Laws of Form expressions.

import {SyntaxHighlighting} from "laws-of-form-react";
...
<SyntaxHighlighting>
  $3(Syntax (highlighting) [3])
</SyntaxHighlighting>
...

⌨️ LoF Input field

Furthermore, the library offers an input field with LoF syntax highlighting.

import {LoFInput} from "laws-of-form-react";
...
const [input, setInput] = useState("");
...
<LoFInput
    value={input}
    onChange={(e) => setInput(e.currentTarget.value)}
    className="foo"
/>
...

⛓️ LoF Parser

In this library, there is also a Laws of Form parser available that can generate a Laws of Form expression tree from the expressions listed above. This tree can be used for prerendering (LoF takes expressionTree as a prop), to make modifications after the parsing process has finished or for calculations. As an example, the data fields can be filled with React components to provide custom content apart from text.

import {parser} from "laws-of-form-react";
// Do stuff ...
const expression = "((a)(b))"
const expressionTree = parser.parse(expression);
expressionTree.data = <SomeReactComponent1/>
expressionTree.expressions[0].data = <SomeReactComponent2/>
// Do some things with the expressionTree ...
<LoF expressionTree={expressionTree}/>

⚠ Limitations

The entire drawing of the Crosses and Re-Entries is done using divs. Each cross is a div. This allows many degrees of freedom, for example dynamic updating, better debugging, embedding HTML/CSS content such as buttons, images, fonts, etc. But this also comes with limitations, especially for the Re-Entry. HTML/CSS permits to use at most one :before and :after peusdo element (which is used for the Re-Entry) per div. Thus for each Re-Entry we can have at most two spaces where it can re-enter. For the majority of cases, two re-enters per re-entry are perfectly sufficient. Sometimes using complicated nested Re-Entries it is necessary to rearrange expressions in case of display errors.

🥨 Other (LoF) projects

Portfolio