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

@formosaic/headless

v1.2.0

Published

Headless (unstyled) semantic HTML field components for @formosaic/core

Readme

@formosaic/headless

Headless (unstyled) semantic HTML field components for @formosaic/core.

This package renders all 27 field types using only native HTML elements -- no UI framework required. Every field outputs semantic HTML with data-field-type and data-field-state attributes for CSS targeting, ARIA attributes for accessibility, and CSS class names for styling.

Installation

npm install @formosaic/headless @formosaic/core react react-dom react-hook-form

Quick Start

import { Formosaic, RulesEngineProvider, InjectedFieldProvider } from "@formosaic/core";
import { createHeadlessFieldRegistry } from "@formosaic/headless";

// Optional: import the minimal default styles
import "@formosaic/headless/styles.css";

const fields = createHeadlessFieldRegistry();

function App() {
  return (
    <RulesEngineProvider>
      <InjectedFieldProvider fields={fields}>
        <Formosaic
          formConfig={myFormConfig}
          onSave={handleSave}
        />
      </InjectedFieldProvider>
    </RulesEngineProvider>
  );
}

Field Components

Editable Fields (22)

| Component | HTML Elements | Type Key | |---|---|---| | HookTextbox | <input type="text"> | Textbox | | HookNumber | <input type="number"> | Number | | HookToggle | <input type="checkbox" role="switch"> | Toggle | | HookDropdown | <select> + <option> | Dropdown | | HookMultiSelect | <select multiple> | Multiselect | | HookDateControl | <input type="date"> + clear button | DateControl | | HookSlider | <input type="range"> + <output> | Slider | | HookMultiSelectSearch | <input type="search"> + checkbox list | MultiSelectSearch | | HookTextarea | <textarea> + expand <dialog> | Textarea | | HookDocumentLinks | URL list with add/remove | DocumentLinks | | HookStatusDropdown | <select> with status indicator | StatusDropdown | | HookDynamicFragment | <input type="hidden"> | DynamicFragment | | HookRadioGroup | <fieldset> + <input type="radio"> list | RadioGroup | | HookCheckboxGroup | <fieldset> + <input type="checkbox"> list | CheckboxGroup | | HookRating | <fieldset> + radio inputs styled as stars | Rating | | HookColorPicker | <input type="color"> | ColorPicker | | HookAutocomplete | <input> + <datalist> | Autocomplete | | HookFileUpload | <input type="file"> + drag-drop zone | FileUpload | | HookDateRange | Two <input type="date"> (From / To) | DateRange | | HookDateTime | <input type="datetime-local"> | DateTime | | HookPhoneInput | <input type="tel"> with mask | PhoneInput |

Read-Only Fields (6)

| Component | HTML Elements | Type Key | |---|---|---| | HookReadOnly | <span> | ReadOnly | | HookReadOnlyArray | <ul> / <li> | ReadOnlyArray | | HookReadOnlyDateTime | <time> | ReadOnlyDateTime | | HookReadOnlyCumulativeNumber | <span> | ReadOnlyCumulativeNumber | | HookReadOnlyRichText | <div dangerouslySetInnerHTML> | ReadOnlyRichText | | HookReadOnlyWithButton | <span> + <button> | ReadOnlyWithButton |

Data Attributes

Every field renders data-field-type and data-field-state attributes for CSS targeting:

/* Target all textboxes */
[data-field-type="Textbox"] { /* ... */ }

/* Target fields in error state */
[data-field-state="error"] { /* ... */ }

/* Target required fields */
[data-field-state="required"] { /* ... */ }

/* Target read-only fields */
[data-field-state="readonly"] { /* ... */ }

Styling with Tailwind CSS

Since all fields render native HTML elements, integrating with Tailwind CSS is straightforward. Override the CSS custom properties or apply utility classes:

Option 1: Override CSS custom properties

/* globals.css */
:root {
  --df-font-family: theme("fontFamily.sans");
  --df-color-primary: theme("colors.blue.600");
  --df-color-error: theme("colors.red.600");
  --df-color-border: theme("colors.gray.300");
  --df-color-border-focus: theme("colors.blue.500");
  --df-border-radius: theme("borderRadius.md");
  --df-spacing-sm: theme("spacing.2");
  --df-spacing-md: theme("spacing.3");
}

Option 2: Use Tailwind's @apply with data attributes

[data-field-type="Textbox"],
[data-field-type="Number"] {
  @apply w-full rounded-md border border-gray-300 px-3 py-2 text-sm
         focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200;
}

[data-field-state="error"] input,
[data-field-state="error"] select,
[data-field-state="error"] textarea {
  @apply border-red-500;
}

Option 3: Skip the default CSS entirely

The components are fully functional without any CSS. Import nothing, then style entirely with your own classes using the data attributes as selectors.

Custom Fields

You can extend or replace any field in the registry:

import { createHeadlessFieldRegistry } from "@formosaic/headless";

const fields = createHeadlessFieldRegistry();

// Replace the textbox with your own component
fields["Textbox"] = <MyCustomTextbox />;

// Add a brand new field type
fields["PhoneNumber"] = <MyPhoneInput />;

Compared to Other Adapters

| Feature | headless | fluent | mui | |---|---|---|---| | UI framework | None | Fluent UI v9 | Material UI v5/v6 | | Bundle size | Minimal | Includes Fluent | Includes MUI | | Styling | Your choice | Fluent tokens | MUI theme | | Accessibility | Native ARIA | Fluent ARIA | MUI ARIA |

License

MIT