A small, unambitious React component library, styled with UnoCSS and focused on accessibility.
Browse every component in the Storybook (latest release), or the next Storybook built from main.
pnpm add @minimalstuff/ui react react-domRequires React 19.
import { Button } from '@minimalstuff/ui';
import '@minimalstuff/ui/style.css';
export function App() {
return <Button color="primary">Click me</Button>;
}The @minimalstuff/ui/style.css import is required for styles and icons to render. It can load before your app's own utilities (UnoCSS or Tailwind): component sizing does not depend on load order.
Modal and ConfirmModal are opened with Modal.call(...) and ConfirmModal.call(...), and render where <ModalProvider /> is mounted. UIProvider overrides the default English labels (close, confirm, no results…) for every component below it; mount ModalProvider inside it so modals receive the labels too.
import { ModalProvider, UIProvider } from '@minimalstuff/ui';
export function Root() {
return (
<UIProvider labels={{ close: 'Fermer' }}>
<App />
<ModalProvider />
</UIProvider>
);
}For French, pass the bundled preset: <UIProvider labels={FRENCH_UI_LABELS}> (import FRENCH_UI_LABELS from @minimalstuff/ui).
Mount <Toaster /> once at the app root, then call toast() from anywhere (event handlers, services, outside React).
import { Toaster, toast } from '@minimalstuff/ui';
export function Root() {
return (
<>
<App />
<Toaster position="bottom-right" />
</>
);
}
toast.success('Saved');
toast.error('Could not save', { description: 'Check your connection.' });Only the first mounted Toaster renders. Toasts sit above Modal and Drawer. Warning and error toasts, and toasts with an action, stay until dismissed, because a Modal's focus trap keeps toasts out of keyboard reach. Press F8 to jump to the toasts and F8 again to return to where you were; Escape closes the focused toast. F8 does nothing while a Modal or Drawer is open. Move the stack with the --ms-toast-offset-bottom and --ms-toast-offset-top CSS custom properties (default: 1rem plus the safe-area inset).
ToastProvider and useToast() still work but are deprecated: mount <Toaster /> and call toast() instead.
Dark styles apply when <html> has the dark class. useThemeStore (and the ThemeToggle built on it) sets that class from the light, dark or system preference and keeps it in localStorage.
To avoid a light flash before your bundle runs, inline THEME_INIT_SCRIPT in <head>, before the stylesheet. It reads the same localStorage key as the store and sets the dark class the same way.
import { THEME_INIT_SCRIPT } from '@minimalstuff/ui';
<head>
<script dangerouslySetInnerHTML={{ __html: THEME_INIT_SCRIPT }} />
<link rel="stylesheet" href="/style.css" />
</head>;To make the browser or installed PWA status bar follow the theme, add a theme-color meta with a data-light and a data-dark color. THEME_INIT_SCRIPT and useThemeStore copy the matching one into content every time the theme is applied (init, setTheme, OS change while on system, another tab). A meta without both attributes is left alone, and without such a meta nothing changes.
<head>
<meta
name="theme-color"
content="#ffffff"
data-light="#ffffff"
data-dark="#0b0b0b"
/>
<script>
/* THEME_INIT_SCRIPT */
</script>
</head>- Put the meta before the script in
<head>. - Remove any other
theme-colormeta, notably ones with amediaattribute: the first matching one wins. - Keep the meta in the static HTML. A meta recreated by a
<head>manager (Inertia<Head>, react-helmet) is not resynced.
With a strict Content-Security-Policy, either add the script's SHA-256 hash to script-src ('sha256-<hash>'), or write THEME_INIT_SCRIPT to a file at build time and load it with <script src>. Compute the hash with:
node --input-type=module -e "import { THEME_INIT_SCRIPT } from '@minimalstuff/ui'; import { createHash } from 'node:crypto'; console.log(createHash('sha256').update(THEME_INIT_SCRIPT).digest('base64'))"The hash changes if a release changes the script: recompute it when you upgrade.
BottomSheet is a modal sheet attached to the bottom edge at every viewport width. Set its height per sheet with the --ms-sheet-height custom property (default 85svh): height="auto" fits the content up to that height, height="fixed" uses exactly that height.
<BottomSheet
isOpen={isOpen}
onClose={close}
title="Comments"
height="fixed"
panelClassName="[--ms-sheet-height:76svh]"
footer={<CommentComposer />}
expandable
>
…
</BottomSheet>Drag the handle (mouse, pen) or the header and body (touch, once the body is scrolled to the top) down to close it; the close button, Escape and the backdrop stay available. With expandable, dragging the handle or the header up expands the sheet to full screen like the header button; an upward move in the body stays a scroll. Put data-sheet-no-drag on an element, such as a custom slider, to keep touches there from dragging the sheet. While a sheet is open it follows the virtual keyboard (window.visualViewport), and bottom toasts move to the top.
While a Modal or Drawer is open, page scroll is locked on <html>. The scrollbar width this frees is compensated with right padding on <html>, so the page does not shift. That padding does not move position: fixed elements: anchor right-aligned ones with right: var(--scrollbar-compensation, 0px). Paint the page background on <html> or <body> rather than only on a wrapper element, or the padding shows the root's background as a strip on the right.
Controls keep their compact size unless you opt in. Set --ms-control-min-height and every styled control grows to at least that height: Button, IconButton (width too, so it stays square), Input, Select, Combobox, MultiCombobox, the tabs of Tabs, and so SplitButton and CopyButton, which are built from them. Components with unstyled do not read it. Textarea, Checkbox, RadioOptions, Switch, Badge and Kbd are left out.
@media (pointer: coarse) {
:root {
--ms-control-min-height: 2.75rem;
}
}The variable inherits, so you can scope it to a container, or reset it to 0px in a dense toolbar. Without it nothing changes. Every control already meets the 24 px minimum of WCAG 2.5.8 (AA); 44 px is WCAG 2.5.5 (AAA), which this variable lets you reach on touch screens.
SidePanel is a non-modal panel docked to one side, for something the user works with beside the page (an assistant, a details column). Use Drawer instead when the panel should block the page: SidePanel has no backdrop, no focus trap and no scroll lock, and the page stays usable. From the overlayBelow breakpoint up (xl, 1280 px, by default) it is a sticky column of the layout, so put it in a flex row next to <main> and the page reflows. Below it, the panel covers part of the page without a backdrop: do not open it by default at that width, since it can hide the focused control (WCAG 2.4.11). It unmounts after its exit, so keep its open state in your own store.
<div className="flex">
<main className="min-w-0 flex-1">…</main>
<SidePanel isOpen={isOpen} onClose={close} title="Details" footer={<NoteComposer />}>
…
</SidePanel>
</div>Focus never moves on its own. Pass focusOnOpen when the user opened the panel (a button press), not when it opens by default or on a route change; focus then goes to initialFocusRef, else the heading. On close, focus moves only if it was inside the panel: to returnFocusRef, else to the element focused when the panel opened, else to <main>. A floating button that unmounts while the panel is open needs returnFocusRef:
const openerRef = useRef<HTMLButtonElement>(null)
{!isOpen && <IconButton ref={openerRef} icon="i-mdi-information-outline" aria-label="Show details" onClick={open} />}
<SidePanel isOpen={isOpen} onClose={close} title="Details" focusOnOpen returnFocusRef={openerRef}>
…
</SidePanel>Escape inside the panel closes it, unless a Modal, Drawer or BottomSheet is open.
TabBar is a bottom navigation for a few top-level destinations on a phone. It is site navigation (a <nav> holding a list of links), not an ARIA tablist. TabBarLink renders an <a> with an icon and a short label; mark the current page with aria-current="page".
<TabBar aria-label="Main" className="fixed inset-x-0 bottom-0">
<TabBarLink href="/" icon="i-mdi-home" aria-current="page">Home</TabBarLink>
<TabBarLink href="/search" icon="i-mdi-magnify">Search</TabBarLink>
<TabBarLink href="/inbox" icon="i-mdi-inbox">Inbox</TabBarLink>
</TabBar>With TanStack Router, wrap the link once. The router sets aria-current="page" on the active link; give the / link activeOptions={{ exact: true }}, or it is current on every route.
const TabBarRouterLink = createLink(TabBarLink)
<TabBarRouterLink to="/" activeOptions={{ exact: true }} icon="i-mdi-home">Home</TabBarRouterLink>The bar is static: you position it. When it is fixed, keep focused controls and bottom toasts clear of it with scroll-padding-bottom on html and --ms-toast-offset-bottom:
html {
scroll-padding-bottom: 5rem;
}
:root {
--ms-toast-offset-bottom: calc(5rem + env(safe-area-inset-bottom));
}pnpm install
pnpm devpnpm dev starts Storybook on port 6006, or on STORYBOOK_PORT when set (devslot sets it per checkout).
Before pushing, run what CI runs (see ci.yml):
pnpm verifypnpm test:stories runs the stories in a real browser and needs Playwright's Chromium once: pnpm exec playwright install chromium.
To change the library from a project that uses it, see docs/developing_from_a_consumer.md.
Releases follow docs/releasing.md. Changes are listed in the CHANGELOG.
Open an issue on GitHub Issues.