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

@baobab-web/ui

v1.7.0

Published

Baobab Commerce design system — a Tailwind v4 React component library and theming preset.

Readme

@baobab-web/ui

A small, reusable React + Tailwind CSS v4 design system for building ecommerce product screens — buyer marketplaces, seller dashboards, admin panels, and delivery-agent apps. It was built as the shared UI foundation for the Baobab Commerce platform and is published so any app in the ecosystem (or outside it) can install it, apply its own brand tokens, and assemble screens without recreating common UI from scratch.

It is presentational only: components accept values, state, errors, and callbacks. They do not fetch data, call APIs, enforce authorization, or encode business rules — that stays in your app's domain, ViewModel, and service layers.

Why this exists

Rebuilding buttons, forms, dialogs, and data tables for every new storefront or dashboard is wasted effort once you already have an accessible, mobile-first set that works. This package lets you retheme via CSS custom properties and a Tailwind preset instead of forking components, so multiple apps can share one design foundation while looking distinct.

Design principles carried over from the original product requirements:

  • Mobile first — every component works at 320px before wider layouts are added.
  • Accessible by default — WCAG AA contrast, keyboard operation, visible focus, semantic HTML, and screen-reader labeling are mandatory, not retrofits.
  • Touch friendly — interactive targets are at least 44×44px; body text is at least 16px.
  • Composition over duplication — variants and slots instead of near-duplicate components.
  • Predictable feedback — async actions expose loading, success, and error states; data regions distinguish loading, empty, and failed states.
  • Confirm consequences — destructive or high-stakes actions (payment, refund, approval, suspension) are expected to be gated behind ConfirmDialog.
  • Data-light — CSS over runtime styling, minimal animation, tree-shakable per-component exports.

Installation

npm install @baobab-web/ui

react (^18 or ^19) and react-dom are peer dependencies. Your app also needs its own Tailwind setup.

Quick start

Tailwind v4 (CSS-first)

Import the complete library theme once in your app stylesheet, after Tailwind:

@import "tailwindcss";
@import "@baobab-web/ui/theme.css";

:root {
  --ui-primary: #17633a;
  --ui-primary-foreground: #ffffff;
}

The import includes token defaults, focus/hit-target utilities, the semantic @theme inline mappings, and an @source pointing at the published JavaScript. No JavaScript preset or manual mappings are needed.

Tailwind v3

Keep importing tokens.css and utilities.css, and register the existing preset:

import type { Config } from "tailwindcss";
import { uiPreset } from "@baobab-web/ui/preset";

export default {
  presets: [uiPreset],
  content: ["./src/**/*.{ts,tsx}", "./node_modules/@baobab-web/ui/dist/**/*.js"],
} satisfies Config;

Import components from their subpaths (@baobab-web/ui/button, @baobab-web/ui/card, etc.) or the root barrel.

Theming

All visual decisions route through CSS custom properties defined in tokens.css — color, typography, spacing, radius, shadow, motion, focus ring, and z-index layers. To retheme for a new brand, override the variables you care about after importing tokens.css:

@import "@baobab-web/ui/tokens.css";

:root {
  --ui-primary: #17633a;
  --ui-primary-foreground: #ffffff;
  --ui-radius-md: 0.375rem;
}

Dark mode is opt-in: set data-theme="dark" (or a .dark class) on a root element. There is no automatic prefers-color-scheme switch. prefers-reduced-motion is respected for all transition/animation tokens.

Brand themes

Ready-made brand themes set the whole --ui-* contract in one import. Tailwind v4 apps load the theme.css bridge first, then the brand theme:

@import "tailwindcss";
@import "@baobab-web/ui/theme.css";
@import "@baobab-web/ui/themes/emerald.css";

| Theme | Used by | Palette | | -------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | | themes/emerald.css | StockLink, ShopFlow, Baobab ecommerce apps | Deep emerald primary, mint washes, slate neutrals; light and dark | | themes/signal.css | Baobab Boards (ads platform) | Paper and ink, signal-yellow accent for the one main action; light, dark and a .tone-signal scope for blocks on yellow |

Themes may also define --brand-* extras (hover and accent shades, washes, display font) that components ignore. Map the ones your app needs into its own @theme, for example --color-primary-hover: var(--brand-primary-hover);. Themes do not load fonts: import themes/emerald-fonts.css (self-hosted Inter and Plus Jakarta Sans) or themes/signal-fonts.css (self-hosted Mona Sans), or load them in the app.

Themes may also set the optional --ui-accent and --ui-accent-foreground pair, used by Button variant="accent" and the accent color utilities. Without it, accent falls back to primary. Signal uses it to keep yellow as a fill for the screen's main action while ink stays primary, because yellow fails contrast as text or as a border on paper.

The optional --ui-border-control sets the edge of form controls (inputs, selects, checkboxes, radios, switches) through the border-control utility. Without it, controls use --ui-border. Signal sets it so inputs keep a 3:1 edge while panels and table rows keep a faint hairline. border-control is defined in utilities.css, not theme.css, so apps with their own @theme get it too; use it on controls your app builds itself so they match.

Signal

@import "tailwindcss";
@import "@baobab-web/ui/theme.css";
@import "@baobab-web/ui/themes/signal.css";
@import "@baobab-web/ui/themes/signal-fonts.css"; /* or next/font exposed as --font-mona-sans */
  • Ink is primary: default buttons, selected tabs, chips, links and checked controls. Use <Button variant="accent"> (yellow) once per screen, for its main action.
  • Never put yellow text or yellow borders on paper; it fails contrast. Yellow is a fill with ink on top.
  • Put .tone-signal on a block that sits on yellow (a call-to-action band). Roles inside it are re-pointed so text, inputs, status colours and focus stay AA, and the accent button turns ink.
  • Panels use hairline borders instead of shadows; only overlays cast one.
  • Brand extras for app code: --brand-signal, --brand-surface-sunken, --brand-scrim, --brand-chart-1 to --brand-chart-5, --brand-font-display, --brand-stretch-display and --brand-stretch-title.

Adding a brand theme

  1. Add src/tokens/themes/<name>.css (and <name>-fonts.css if it self-hosts fonts) setting the --ui-* contract for :root and [data-theme="dark"], .dark.
  2. List the files in cssFiles in tsup.config.ts and under exports in package.json.
  3. Add the theme and its scopes to THEMES in src/tokens/themes/themes-contrast.test.ts; every text pair must reach 4.5:1 and focus and control edges 3:1.
  4. Add it to brandStyles and the Brand toolbar in .storybook/preview.tsx, then check it in Storybook in light and dark.
  5. Add a row to the table above and a changeset.

Semantic roles: background is the main canvas (white by default); surface is a tinted secondary region (grey by default), not a white-card token. foreground is primary text; muted-foreground is secondary text. Apps that call white cards “surface” should map their brand variables to these roles explicitly.

Server Components and class merging

Only interactive modules declare "use client"; the root barrel, preset, display-only primitives, and pure helpers are server-safe. Import button styling from button-styles (or the root), since the button component entry is a client boundary:

import { buttonVariants } from "@baobab-web/ui/button-styles";
import { cn } from "@baobab-web/ui/cn";

export function ServerLink() {
  return (
    <a href="/search" className={cn(buttonVariants({ size: "lg" }))}>
      Browse
    </a>
  );
}

BUTTON_VARIANT_CLASS, buttonVariants, cn, uiMergeConfig, baobabBrand, formatGhanaPhone, and clampDuration are usable from the root in an RSC. Phone formatting and toast duration also have pure phone-format and toast-duration subpaths. Hooks and ToastContext remain client APIs. The old helper re-exports from client component subpaths remain available for client consumers.

cn recognizes text-caption, text-label, text-body, text-heading, and text-numeric as font sizes independently of text colors. Consumers can extend uiMergeConfig for extra size names:

import { extendTailwindMerge } from "tailwind-merge";
import { uiMergeConfig } from "@baobab-web/ui/cn";

const merge = extendTailwindMerge(uiMergeConfig, {
  extend: { classGroups: { "font-size": [{ text: ["ui"] }] } },
});

Theming form controls without !important

Input, Select, and Textarea resolve every border, background, and text color through the same --ui-* custom properties as the rest of the library — none of them hardcode a Tailwind palette class. Retheming these should only ever require overriding CSS variables, the same way as any other component:

:root {
  --ui-border: #d4d4d8;
  --ui-background: #ffffff;
}

Reach for !important and you're almost certainly fighting the wrong layer. The usual cause is a consumer override rule that's itself compiled by Tailwind (an @apply rule, or a class Tailwind's content scanner picked up) — that rule lands in the same generated stylesheet as this library's own utility classes, so a tie between two same-specificity selectors goes to source order, not to whichever rule "should" win. Two ways out, in order of preference:

  1. Override the --ui-* variables (shown above) instead of re-targeting input/select/textarea element selectors — variables don't have this ordering problem.
  2. If you must override a compiled utility class directly, make sure your override's stylesheet is imported after @baobab-web/ui's, so it wins on source order without needing !important.

Growth Rings brand illustration

import { GrowthRings } from "@baobab-web/ui/growth-rings";

<GrowthRings seed="the-baobab" rings={7} wobble={0.75} accent="outer" detail animate style={{ maxWidth: "20rem" }} />;

Ported from baobab-agency's seeded tree-trunk cross-section. The same seed/options produce identical paths on server and client, with no client boundary, animation library or random runtime state. Import the normal theme/utilities stylesheet for its appearance and animation.

  • seed is required. Geometry defaults: rings={14}, radius={46}, wobble={0.5}, cx={50}, cy={50}, accent="middle", inside a 0 0 100 100 viewBox. Ring count is floored and bounded to 0–128; non-finite counts fall back to 14. Use finite geometry values, a non-negative radius, and wobble between 0 and 1. SVG overflow is visible for custom placement.
  • detail adds the pith and three radial cracks. animate opts into the original staggered draw-on effect; both default to false. Reduced-motion users see complete static rings, including normal non-scaling stroke widths, without waiting for the animation.
  • Decorative by default (aria-hidden, unfocusable). Supply label="Baobab trunk cross-section" when the image conveys meaning; surrounding copy should explain any business significance.
  • Standard SVG sizing, className and style are supported. Colors inherit --ui-muted-foreground and --ui-primary. Override --ui-growth-rings-stroke, --ui-growth-rings-accent, --ui-growth-rings-opacity (default 0.32), and --ui-growth-rings-duration (default 1.8s) through the typed GrowthRingsStyle or a scoped ancestor. These replace the agency's --rings-stroke, --rings-accent, and --rings-opacity; application layout stays with the caller.

Stories cover the detailed/animated trunk, footer signature, alternate seeds and custom colors. The original source geometry is checked against captured hashes and the component is included in the Next.js server-rendering fixture. Validation passed 158 package tests and 12 Chromium cases across three widths, both themes and both motion preferences. GrowthRingsProps and GrowthRingsOptions are exported from the same subpath. This ports the primitive; adopting it in the agency is a separate change.

Business application adoption

The AgriSense migration guide maps local controls to existing and extended Baobab APIs, with examples and validation. It covers clearable rich-option Combobox, click/touch InfoTooltip, rich FormField/reserved validation space, consistent control density, Dialog body styling, compact desktop Pagination, quiet dot badges, statistics/metrics, bounded Meter, Distribution, and composable table primitives. The existing column/data Table and original public props remain available. Domain logic, units, thresholds, requests and copy remain with consumers.

The utilities-only consumer theme fixture is built with pnpm --filter @baobab-web/ui run test:consumer-theme; default theme.css imports remain valid. See the guide before removing the consumer's old font-size merge overrides.

Components

Every export below is tree-shakable and importable from its own subpath (e.g. @baobab-web/ui/dialog).

Layout & accessibility — Container, Stack, Grid, AppShell, PageHeader, ScrollRail (+ ScrollRailControls), Divider, ScreenReaderOnly, BrandLogo, GrowthRings, Code

Actions & form controls — Button, IconButton, Input, PhoneInput, Textarea, Select, Combobox, DatePicker, Checkbox, RadioGroup, Switch, FormField, FormErrorSummary, OTPInput, QuantityInput, FileUpload, AddressInput

Navigation — Tabs, Pagination, Breadcrumb, Chip

Feedback & status — Badge, BadgeGroup, StatusBadge, Progress, Alert, Toast (+ ToastProvider, useToast), Skeleton, Spinner, EmptyState, ErrorState

Overlays — Dialog, ConfirmDialog, DrawerSheet, InfoTooltip, Tooltip (+ TooltipTrigger, TooltipContent), Popover (+ PopoverTrigger, PopoverAnchor, PopoverContent, PopoverClose), DropdownMenu (+ DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuItem)

Data display & selection — Card (+ Card.Header, Card.Title, Card.Description, Card.Content, Card.Media, Card.Footer), SelectableCard, Table, DataList, TimelineStatusStepper, StatCard, StatGroup, Metric, MetricStrip, Meter, Distribution, TableRoot (+ table primitives), MediaFrame, Avatar, Rating (read-only display)

The original PRD's P0/P1/P2 component catalog is now implemented, including promotion of BadgeGroup. P1/P2 describe original scheduling, not the maturity of these shipped APIs. See catalog completion and API guide for the current status mapping, examples, accessibility contracts, verification evidence and remaining manual checks. Product-screen adoption is a separate workstream.

Tooltip is reusable supplementary help; IconButton uses it internally, including in Dialog and DrawerSheet close controls. Popover is anchored interactive content. DatePicker retains its specialized internal calendar popover. Both public overlay families support asChild triggers, controlled/uncontrolled state and viewport collision avoidance.

Combobox is a single-select searchable listbox: value/defaultValue/onChange selects an option; searchValue/defaultSearchValue/onSearchChange controls search separately. Local filtering is on by default; use filterOptions={false} for caller-filtered results and pass loading, error, loadingText or emptyText. The library does not fetch or cancel requests. Use FormField or an accessible input name. Multi-select and virtualization are outside this API.

Switch uses native checkbox form behavior with switch semantics. Progress requires label, aria-label or aria-labelledby; omit value for indeterminate progress. StatCard accepts preformatted values and independent trend/tone. BadgeGroup is a labeled wrapping list of existing Badge/Chip children. Divider defaults to a semantic horizontal separator; use decorative for a visual-only line. Divider, Progress, StatCard and BadgeGroup are server-safe.

Dialog supports presentation="fullScreen" for long task flows (multi-step forms, editors, previews) that need the full viewport at every breakpoint, not just the default responsive bottom-sheet/centered-modal shape below 640px.

Dialog and DrawerSheet both accept closeButtonClassName (a style hook for the close control, e.g. to change its corner radius) and closeButtonTooltipSide (defaults to "bottom", since the control sits at the top of the viewport).

DrawerSheet side="bottom" stays a bottom sheet at every breakpoint. Left/right placement still becomes a bottom sheet on phones. Its optional footer stays outside the scrolling body and includes the mobile bottom safe-area inset.

Alert, EmptyState, Badge, Dialog, and DrawerSheet accept React nodes for their text content, including links. Dialog and drawer titles/descriptions retain their accessible name/description wiring. EmptyState headingLevel={1} can supply a page's heading; omitting the level preserves the existing paragraph presentation.

Input passes native types such as email, password, url, number, and date through. numeric and currency remain text-input modes; currency still requires an explicit currencySymbol.

ErrorState requires one retry strategy: the existing onRetry, a server-renderable retryHref, or an action node.

URL-driven navigation

Panel tabs retain Tabs.Panel and Radix keyboard navigation. For route navigation, use linkAs="a" or pass a framework Link adapter that forwards anchor props:

<Tabs linkAs="a" activeTab="cars" tabs={[
  { id: "cars", label: "Cars", href: "/cars" },
  { id: "parts", label: "Parts", href: "/parts" },
]} />
<Pagination linkAs="a" currentPage={2} totalPages={12}
  hrefFor={(page) => `/cars?page=${page}`} />

Link mode renders a navigation landmark with aria-current="page", rather than in-page tab roles. Disabled navigation items render without a link. Both modes render their URLs in server HTML and work before hydration. Pagination's responsive layout uses CSS; numbered pages appear from 640px, with a page indicator on phones. Callback pagination still uses onPageChange. A custom linkAs may need an adapter if its router-specific props are narrower than standard anchor props.

DropdownMenuContent forwards side, avoidCollisions, and collisionPadding to Radix's own collision detection, and caps its height to the available viewport space (scrolling instead of clipping) via max-height: var(--radix-dropdown-menu-content-available-height).

DatePicker takes and returns a single ISO YYYY-MM-DD string — never a Date object — so timezone handling stays app-owned. Below 640px it renders a native <input type="date"> (the platform's own picker, no extra JS); at wider viewports it renders a text trigger with a Radix-powered calendar popover, the same responsive split Select uses for its native <select> fallback. min, max, and disabledDate constrain which dates can be selected without hiding them from the grid; no calendar-system or holiday logic ships in the component itself.

Month and weekday names are locale-aware via Intl.DateTimeFormat — pass a BCP 47 tag through locale (e.g. locale="fr-FR") and, if the target locale's convention differs, firstDayOfWeek (0–6, Sunday-based; most non-US locales expect 1). Omitting locale uses the runtime's default, which is fine for CSR-only apps but can cause a hydration mismatch in SSR apps if the server and browser resolve different default locales — pass an explicit locale there. The native <input type="date"> fallback below 640px is always locale-aware via the browser itself; locale additionally sets its lang attribute so both modes render consistently. Static a11y strings inside the popover ("Previous month", "Next month", "Choose date") are English-only today — this mirrors every other overlay in the library (e.g. Dialog's "Close" label), none of which expose an override prop yet; that's a library-wide gap, not specific to this component.

Conventions

  • Framework-neutral and SSR-safe — no router, Next.js, data-fetching, or app-specific imports inside the package.
  • Every component accepts className; interactive elements accept refs for form registration and focus management.
  • Async state is driven by props (loading, error, disabled, ...) — components never issue requests themselves.
  • Status/semantic colors are typed finite unions ("neutral" | "info" | "success" | "warning" | "danger", etc.), not arbitrary strings — your app owns the mapping from domain enums (order status, KYC status, ...) to these tones.
  • Destructive or consequential actions are expected to be wrapped in ConfirmDialog rather than firing directly from a click handler.
  • variant="destructive" (Button, IconButton, DropdownMenuItem) and tone="danger" (Badge, Alert, Toast) are deliberately distinct, not two names for the same idea: destructive marks an action whose effect is irreversible/destructive; danger marks a status that is currently in an error/critical state. An action can be destructive without the surrounding context being danger (a "Delete draft" button), and a status can be danger with no action present (a read-only "Payment failed" badge). Don't build a local map between them — if a component needs both at once (e.g. ConfirmDialog's destructive prop rendering a Button variant="destructive"), that's the expected composition.
  • Button and IconButton sizes are sm | default | lg (plus icon on Button). Both compact controls stay visually 36px tall and gain an invisible 44px hit area via .ui-hit-slop-44; leave room around them so neighboring targets do not overlap.

Row actions in Table / DataList

Table stays semantic and horizontally scrollable — it does not auto-transform into cards at narrow widths; use DataList when a product needs a stacked label/value layout instead. For row actions, the recommended pattern is one labelled overflow trigger per row using DropdownMenu, not a growing row of icon buttons:

<DropdownMenu>
  <DropdownMenuTrigger asChild>
    <IconButton icon={<MoreIcon />} aria-label={`Actions for ${row.id}`} size="sm" />
  </DropdownMenuTrigger>
  <DropdownMenuContent align="end">
    <DropdownMenuGroup>
      <DropdownMenuItem>View details</DropdownMenuItem>
      <DropdownMenuItem>Print receipt</DropdownMenuItem>
    </DropdownMenuGroup>
    <DropdownMenuItem destructive>Cancel order</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Primary information stays visible in table columns; secondary actions move into menu groups. The product owns action labels, permissions, confirmation dialogs, and mutations — the library only provides the trigger and menu. See the RowActionsWithDropdownMenu story on Data Display/Table for a full example.

Composition pitfalls

Don't render a Dialog/DrawerSheet as a descendant of DropdownMenuContent — for example, as the child of a DropdownMenuItem meant to open it. Radix unmounts DropdownMenuContent's subtree the instant the menu closes, and it closes as part of the same interaction that would open the dialog, so the dialog unmounts before it can take over rendering:

// Don't: Dialog is a descendant of the menu it's triggered from.
<DropdownMenuContent>
  <DropdownMenuItem onSelect={() => setEditOpen(true)}>
    Edit
    <Dialog open={editOpen} onOpenChange={setEditOpen} title="Edit">
      {/* unmounts with the menu before this can render */}
    </Dialog>
  </DropdownMenuItem>
</DropdownMenuContent>

// Do: lift the open state, render Dialog as a sibling of the menu.
<>
  <DropdownMenu>
    <DropdownMenuTrigger asChild>
      <IconButton icon={<MoreIcon />} aria-label="Actions" size="sm" />
    </DropdownMenuTrigger>
    <DropdownMenuContent>
      <DropdownMenuItem onSelect={() => setEditOpen(true)}>Edit</DropdownMenuItem>
    </DropdownMenuContent>
  </DropdownMenu>
  <Dialog open={editOpen} onOpenChange={setEditOpen} title="Edit">
    {/* survives the menu closing */}
  </Dialog>
</>

This isn't specific to Dialog — the same applies to any overlay you'd otherwise nest inside a menu item.

Local development (inside this monorepo)

pnpm --filter @baobab-web/ui run dev      # tsup --watch, rebuilds dist on change
pnpm --filter @baobab-web/ui run build    # one-off build
pnpm --filter @baobab-web/ui run storybook # Brand toolbar switches between base, emerald and signal
pnpm --filter @baobab-web/ui run test
pnpm --filter @baobab-web/ui run test:rsc # after build; Next server/client and Tailwind v4 fixture

License

MIT — see LICENSE. This differs from the rest of the ecommerce-platform monorepo, which is licensed under BUSL-1.1; only this package is published under separate, permissive terms.