FUNSTACK UI

HomeWhyGetting startedConceptsComponentsRoadmap
GitHub

FUNSTACK UI is in beta. Part of the FUNSTACK family with FUNSTACK Router and FUNSTACK Static, which build this site.

FUNSTACK UI

Headless React components, and the first UI library that is Async React-native.

FUNSTACK UI
Why FUNSTACK UIGet started

Beta

The API is believed complete, but nobody uses it in production yet. Breaking changes can still ship, each with a migration note in the release notes (see Stability). Feedback is welcome on GitHub.

Try it

The star flips at once, the button shows a spinner while the fake save runs, and a second click while it is pending wins. The code is one Toggle with an async action.

Show code
ToggleFavorite.tsx
"use client";
import { Toggle } from "@funstack/ui/toggle";
import { fakeSave } from "./fake-api.js";

// Uncontrolled Toggle with an async action. The star flips at once (optimistic), the button
// carries data-pending for the 800 ms the save takes, and a second click while pending wins.
export function ToggleFavorite() {
  return (
    <Toggle className="demo-toggle" pressedChangeAction={(next) => fakeSave(`favorite=${next}`)}>
      {({ pressed, pending }) => (
        <>
          {pending ? (
            <span className="demo-spinner" aria-hidden />
          ) : (
            <span aria-hidden>{pressed ? "★" : "☆"}</span>
          )}
          Favorite
        </>
      )}
    </Toggle>
  );
}
toggle.css
/* Toggle: data attributes carry library state; :hover / :focus-visible come from the platform. */
.demo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.4em 0.9em;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  /* The optimistic flip is a sync commit, so it animates with a plain CSS transition. */
  transition:
    background-color 120ms,
    color 120ms,
    border-color 120ms;
}

.demo-toggle[data-pressed] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}

.demo-toggle[data-pending] {
  cursor: progress;
}

.demo-toggle[data-disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.demo-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .demo-toggle {
    transition: none;
  }
}

The components are headless: accessible HTML with data attributes, no styles. You bring the CSS. Why FUNSTACK UI shows what this saves you.

Principles

  • Suspense-native

    Content that suspends is the normal case. The old content stays on screen while the new content loads.

  • Transition by default

    Every state change the library makes is a React transition. You do not opt in.

  • Action props, not event handlers

    Pass an async function (pressedChangeAction, valueChangeAction); the component shows the new value at once and data-pending until it is done.

  • <ViewTransition> built in

    Give a part a transition prop and its changes animate with React's <ViewTransition>.

  • Greedy about the platform

    Popover API, <dialog>, CSS Anchor Positioning, <details>, native form controls. Where HTML can do the job, it does.

  • Accessibility is not optional

    Components follow the WAI-ARIA Authoring Practices and are tested for keyboard and assistive-technology behaviour.

Install

npm install @funstack/ui

React 19.3 or later. Supported browsers: the latest stable Blink, WebKit and Gecko. No fallbacks. Platform features not yet in all three are opt-in experimental props.

Components: Button, Toggle, ToggleGroup, Toolbar, Tabs, Accordion, Collapsible, NavigationMenu, Tooltip, HoverCard, Popover, Dialog, AlertDialog, Drawer, Menu, Context menu (Menu), Menubar (Menu), Toast, Field and Form, Checkbox, CheckboxGroup, RadioGroup, Switch, Select, Combobox, MultiSelect, Slider, NumberField, OTPField, TextField, Progress, Meter, Avatar, Separator and Scroll areas (recipe). More are coming; see the roadmap.

The FUNSTACK family

FUNSTACK UI is part of the FUNSTACK family, which aims to be the most modern React stack:

  • FUNSTACK Router: a React router built on the Navigation API.
  • FUNSTACK Static: a React Server Components static site framework. This site is built with it.