@dapplelight/signet-ui
v0.5.9
Published
Signet component kit — token-driven React primitives.
Maintainers
Readme
@dapplelight/signet-ui
63 React components (57 in components/ui, 6 in domain/) on Tailwind v4, in the shadcn style, styled only through
Signet theme tokens.
Swap the theme file and every component changes; no component is edited.
Part of Signet. Docs: https://signet.dapplelight.in/
Install
bun add @dapplelight/signet-ui @dapplelight/signet-tokenssrc/app.css:
@import "tailwindcss";
@import "@dapplelight/signet-tokens/editorial.css";
@import "@dapplelight/signet-tokens/base.css";
/* Tailwind does not scan node_modules; the kit's class names must be seen. */
@source "../node_modules/@dapplelight/signet-ui/dist";The @source path is relative to the CSS file: ../node_modules is right for
src/app.css at the project root; adjust the ../ count if your CSS lives
elsewhere (in a monorepo, point it at wherever node_modules is hoisted).
src/components/example.tsx:
import { Button, DataTable, EmptyState } from "@dapplelight/signet-ui"
// or one component at a time, to keep the module graph small:
import { Button } from "@dapplelight/signet-ui/components/button"Peer dependencies
Installed by you, not by Signet. With bun, bun add <package>; with npm,
npm i <package>; with pnpm, pnpm add <package>. Versions are the
peerDependencies ranges in package.json.
Required:
| Package | Range |
|---|---|
| react, react-dom | >=19.0.0 |
| @dapplelight/signet-tokens | ^0.3.0 \|\| ^0.4.0 |
| @base-ui/react | >=1.3.0 |
| @radix-ui/react-checkbox, -dropdown-menu, -popover, -tooltip | >=1.0.0 (>=2.0.0 for dropdown-menu) |
| @tanstack/react-table | >=9.0.0 |
| class-variance-authority | >=0.0.0 |
| clsx | >=2.0.0 |
| tailwind-merge | >=3.0.0 |
| lucide-react | >=1.0.0 |
| input-otp | >=1.4.0 |
| react-day-picker | >=10.0.0 |
Optional (peerDependenciesMeta), needed only for the component named:
| Package | Range | Needed by |
|---|---|---|
| recharts | >=3.8.0 <4 | chart, screens/cost-dashboard, screens/subscription-charts |
| @tanstack/react-hotkeys | >=0.12.0 <0.13.0 | shortcuts |
| react-markdown, remark-gfm, remark-parse, unified, github-slugger | >=10.0.0, >=4.0.0, >=11.0.0, >=11.0.0, >=2.0.0 | markdown, fold |
| @tiptap/react, @tiptap/pm, @tiptap/starter-kit, @tiptap/extension-mention, @tiptap/extension-link | >=3.34.0 <4 | rich-text-editor |
| @autoform/react, @autoform/zod, @tanstack/react-form, zod | ^5.0.0, ^6.0.0, ^1.0.0, ^4.0.0 | schema-form |
What is in it
- The shadcn set: button, input, dialog, drawer, popover, select, tabs, table
and the rest. There is no
sheetcomponent: usedrawerorresponsive-sheetfor sheets. - Extras: a virtualised
data-table,combobox,stat-strip,responsive-sheet,markdown(safe by default),fold(long text behind a Show more link),emoji-picker. - Basics on UI SDK behaviours (see below):
toast,alert-dialog,field,avatar,radio-group,command(with a ⌘KCommandDialog),timeline,stepper,sidebar,breadcrumb,spinner.toasthas sonner's API (toast(),toast.success(),<Toaster position closeButton />), so thecreate-signet-apptemplate's sonner Toaster can be swapped for it by changing two imports. domain/components that carry product vocabulary, such astrend-chip, kept out of the main barrel.domain/job-runsis a table of background-job runs (status, attempts, error, retry and cancel) ondata-table; it takes plain rows such as signet-server'sjobs.status(id)and callbacks.domain/uploadis a drag-and-drop uploader with per-file progress (XHR to a presigned URL), retry, and size/type hints;getTargetandonUploadedtalk to your server.domain/amountformats money: the locale's grouping (₹12,50,000 in en-IN), the currency's own decimals, minor units and bigints exactly, compact lakh/crore ("₹12.5L", "₹1.2Cr"), a sign, andtonecolours from the theme's--money-*slots (falling back to the status accents), with a class per part (currency,integer,fraction…).domain/kanbanis a board whose cards move between columns by pointer drag or keyboard (Space picks up, arrows move, Space drops, Escape cancels), announced in a live region; the board is a plain{ column: ids[] }object.- Hooks, one subpath each:
hooks/use-media-query,hooks/use-debounce,hooks/use-local-storage(JSON, SSR-safe, synced across tabs),hooks/use-copy(clipboard with acopiedflag) andhooks/use-intersection(on screen or not, for lazy loading). screens/ready screens, out of the barrel:auth-screens(sign in / up by email or phone code, OAuth, verify, session expired),account-screens(profile, devices, API keys),notification-screens(inbox, preferences) andprivacy-screens(DPDP consents, export and erasure requests). Plain data in, callbacks out, shaped like signet-server and signet-db; wire them throughcreateRpcClient. Strings come fromDEFAULT_*_LABELSand thelabelsprop; parts takeclassName, compositesclassNames. Demo:screens-user.htmlin the showcase (linked from its header).screens/admin-screens:AdminScreen, an admin panel generated from signet-db'sdefineAdminmetadata over signet-server'sadminRoutes(createAdminApi({ baseUrl: "/admin" })): table list, server sort, filters, search and cursor pages, deleted rows, a record form built from the column types, create, bulk delete, row actions and the audit trail. Every part is exported (AdminPanel,AdminTable,AdminRecordSheet…) withuseAdmin()for your own.screens/billing-screens:BillingScreenandPaywallon signet-db entitlements and signet-payments: plan picker (web and store plans, monthly / yearly), current plan withcurrentPeriodEndand source, restore purchases, usage meters, GST invoice links and a wallet balance.plansFromEntitlements(definePlans(...), display)builds the plan list.screens/monetisation-screens:RemotePaywallrenders the server's offering (signet-dbcreateOfferings: copy, plans shown, highlighted plan and badge, trial text, button text, prices per store) on thePaywallparts and hands the matching product to your checkout;plansFromOffering(offering, source, display)is the plan list it uses.CustomerCenteris the self-serve page on signet-dbcreateCustomers: plan and renewal date, cancel with the retention offer first, a store manage link instead for App Store and Google Play, refund request and contact support.CustomerTimelineis the admin view of one customer's purchases, renewals, refunds, cancellations, billing issues and grace periods across stores and web, with ledger totals.screens/experiment-screens:ExperimentListandExperimentResults, the admin readout of a signet-db experiment (exposures, conversions, rate, lift and p-value per variant against the control) with start, stop and roll out a winner, over signet-server'sexperimentAdminRoutes.ExperimentFormcreates and edits one (key, variants with weights, a JSON value or, withofferings, an offering and version per variant, goal event, audience, start and stop).PricingExperimentResultsis a pricing experiment's readout fromGET /pricing/:experiment: per variant the offering, conversion with lift and p-value, trial conversion, revenue per exposed user and an LTV marked as an estimate, with one-click rollout.screens/status-screens:StatusPage, the public status page from signet-db'sstatus.summary(): overall status, a maintenance notice, components and recent incidents with their updates.StatusAdminis the admin screen overstatusAdminRoutes: the maintenance switch with message and until, component statuses, and incidents opened, updated and resolved (updates are append-only); its parts (MaintenanceForm,ComponentStatusList,IncidentForm,IncidentUpdateForm) are exported. periods across stores and web, with ledger totals.RemotePaywallshows the customer's best offer (free trial, intro or win-back, fromcustomers.withOffers), passes it toonPurchase, and callsonImpressiononce per offering version for paywall conversion;PromotionalGrantFormgrants a plan for some days from admin.screens/funnel-screens:WebFunnelwalks a web-to-app funnel from signet-server's funnel routes (questions, thenRemotePaywallwith the URL discount priced in, then email and code) and hands the checkout to you;ExpressCheckoutmounts Stripe's Express Checkout Element (Apple Pay, Google Pay) and Payment Element with Stripe.js loaded at runtime (nothing bundled);FunnelRedemptionwaits for the webhook, then offers "Open the app" and the code to paste. FetchGET /sessions/:idfrom the same site withcredentials: "include": only the checkout's browser (HttpOnly cookie) gets the link; anyone else sees "paid, we emailed you the link".screens/subscription-charts:SubscriptionChartson signet-dbcreateCharts: MRR per currency (and a converted total), active subscribers and trials, new versus renewal revenue and refunds, churn and trial conversions, paywall views against conversions, with filters by store, plan, country and offering, saved audiences and a CSV link. Needs recharts (optional peer), so it is its own export path.screens/cost-dashboard:CostDashboardon signet-server'sobservabilityAdminRoutes: spend over time with cache savings, spend by model, top spenders (hashes as given) and global cap bars; give itdataor afetcher(days). Needs recharts (optional peer), so it is its own export path.screens/growth-screens:WaitlistJoin(with the place in line),InviteAccept,ReferralCard,OnboardingChecklist,FeedbackWidget/FeedbackFormandWhatsNew, shaped like signet-db's growth results.screens/workflow-screens:WorkflowRunTimeline(run status, who or what it is waiting on, every step with retries and decisions, cancel) andApprovalInboxCard(approve / reject with a reason), shaped like signet-db'swf.get(id)andwf.pendingApprovals(user). Demo for these four:screens-ops.htmlin the showcase (?screen=,?theme=,?dark=1).screens/org-screens:OrgSwitcher,MembersList(roles, remove, leave, pending invites),InviteDialog(one-time link with Copy),AcceptInvitePage(a page aroundInviteAccept) andOrgSettings(name, theme, brand colour with abuildThemepreview), shaped like signet-server'sorgRoutesresponses. Demo:screens-orgs.html.screens/collab-screens:CommentThreads(threads, replies, edit with an "edited" marker, delete, a composer),MentionTextarea(type@for a member picker; the body stores@[Name](user:<id>), so a rename never breaks a mention),ActivityFeed("Asha changed status to Done", comments, Load more) andVersionHistory(versions, a field diff, Restore, Undo with the server's conflict message), shaped like signet-db'screateCollaband signet-server'scollabRoutes. Demo:screens-collab.html.screens/abuse-screens:CaptchaWidget(loads Cloudflare Turnstile or hCaptcha and reports the token for signet-server'srequireCaptcha;provider="test"reports the test token with no script) andAiSpendAdmin(spend against caps today and this month, top users and orgs, set and remove caps), shaped like signet-server'saiSpendAdminRoutes.- Real-time:
hooks/use-channelandscreens/realtime-screens, see Real-time. Demo:screens-realtime.html. - Data editing:
domain/csv-import,components/data-gridandcomponents/rich-text-editor, see Data editing.
Real-time
On signet-server's realtime hub (@dapplelight/signet-server/realtime).
hooks/use-channel has createRealtimeClient (reconnects with backoff,
rejoins resuming from the last event, pings on the hub's heartbeat, drops
duplicate events, applies shared state by version), useChannel(client,
channel, { onEvent }) (presence, shared state, set, setTyping,
setEditing, and stale / conflict flags with acknowledge),
usePresence and useRecordChanges. screens/realtime-screens has
AvatarStack, EditingBadge, TypingIndicator (a polite live region) and
RecordChangedBanner ("this record changed, reload?"); strings come from
DEFAULT_REALTIME_LABELS and the labels prop.
const live = createRealtimeClient({ url: `/realtime?org=${orgId}` })
function Doc({ id, me }) {
const ch = useChannel(live, `record:docs:${id}`)
const { changed, change, dismiss } = useRecordChanges(live, `record:docs:${id}`, { selfId: me })
return (<>
<RecordChangedBanner changed={changed} by={change?.data?.name} onReload={() => { refetch(); dismiss() }} />
<AvatarStack members={ch.members} selfId={me} />
<EditingBadge members={ch.members} selfId={me} field="title" />
<input onFocus={() => ch.setEditing("title")} onBlur={() => ch.setEditing(null)} onInput={() => ch.setTyping(true)} />
<TypingIndicator members={ch.members} selfId={me} />
</>)
}A user removed from the org or whose session expired is not reconnected (close codes 4003 and 4001); anything else reconnects with backoff.
Data editing
Three pieces for editing data in a product, all on theme tokens, with
DEFAULT_*_LABELS + labels for every string, className plus
classNames per part, data-slot and state attributes on every part, and
copy-in with signet add data-grid, signet add rich-text-editor or
signet add csv-import.
domain/csv-import:CsvImporttakes a file or pasted text, parses it (RFC 4180: quoted fields,"", line breaks inside quotes, CRLF, a BOM; the separator is detected), matches columns tofieldsby name, key or alias, validates every row with your zod schema (or anything withsafeParse), shows errors per cell with a "rows with errors" filter and a download of them, and passes the valid rows toonImport. Return signet-db'sbulkInsertreport and its errors land on the right line and field.parseCsv,toCsv,autoMatchandvalidateRowsare exported for your own flow.components/data-grid:DataGridis an editable grid on the same react-table core and Table parts asDataTable: text, number, select, date and checkbox cells; one tab stop with arrows, Home/End, PageUp/PageDown, Ctrl+arrows, Enter or F2 or typing to edit, Enter/Tab to save and move, Escape to cancel; Shift+arrows select a range, Ctrl+C copies it as TSV, Ctrl+V pastes a TSV block (or fills the range with one value), Delete clears it; Shift+Space or the checkbox column selects rows; header sort and keyboard column resize; rows are virtualised (10k+).onChangegets every edit, paste and clear as a batch; the grid shows the new values at once, and a throw (or returned failures) puts them back with the error on each cell (aria-invalid,data-error) and in a live region. It is arole="grid"witharia-rowcount,aria-rowindex,aria-colindex,aria-selectedandaria-sort.components/rich-text-editor:RichTextEditoris built on Tiptap v3 (optional peers:bun add @tiptap/react @tiptap/pm @tiptap/starter-kit @tiptap/extension-mention @tiptap/extension-link; likechart, it is not in the barrel, so apps without Tiptap are unaffected). Bold, italic, inline code, links, two heading levels, bulleted and numbered lists (Mod+B/I/E/K), a WAI-ARIA toolbar, and@mentions through Tiptap's suggestion API withonMentionSearch, the same people searchMentionTextareauses. The value is markdown written by walking the editor's HTML through an allowlist, and pasted HTML goes through the same allowlist, so pasted scripts, handlers, styles andjavascript:links never reach it; mentions are stored as@[Name](user:<id>), so signet-db'screateCollabparses and notifies them as it does for comments.RichTextContentandrichTextToHtmlrender stored markdown as HTML that is safe by construction. On the server, pass bodies through signet-server'ssanitizeMarkdown.
const schema = z.object({ name: z.string().min(1), email: z.email(), plan: z.enum(["free", "pro"]) })
<CsvImport
fields={[{ key: "name", required: true }, { key: "email", aliases: ["E-mail"] }, { key: "plan" }]}
schema={schema}
onImport={(rows) => api.post("/customers/import", { rows })} // returns bulkInsert's report
/>
<DataGrid
aria-label="Customers"
rows={rows}
getRowId={(r) => r.id}
selectable
columns={[
{ id: "name", header: "Name" },
{ id: "seats", header: "Seats", type: "number" },
{ id: "plan", header: "Plan", type: "select", options: [{ value: "free", label: "Free" }, { value: "pro", label: "Pro" }] },
{ id: "renews", header: "Renews", type: "date" },
{ id: "active", header: "Active", type: "checkbox" },
]}
onChange={async (changes) => {
await api.patch("/customers", { changes }) // a throw reverts and marks the cells
setRows((all) => applyChanges(all, changes))
}}
/>
<RichTextEditor aria-label="Note" value={body} onValueChange={setBody} onMentionSearch={(q) => api.get(`/mentions?q=${q}`)} />
<RichTextContent value={body} />Demo: data-edit.html in the showcase.
Behaviours and recipes
The basics are built from behaviours: keyboard, focus, selection, dismissal
and the ARIA they need. UI SDK (@ui-sdk/core and
@ui-sdk/react, pinned to an exact beta) implements them inside this package;
nothing from it appears in signet-ui's exports, so it can be replaced here
without an app changing. Each component's source starts with its recipe:
| Component | Recipe |
|---|---|
| toast | live-region + timers + swipe + dismiss + shortcut (F6) |
| alert-dialog | popup + focus-trap + dismiss |
| field | field-wiring (label names, description and error describe, aria-invalid) |
| avatar | image-loading |
| radio-group | selection + roving-focus |
| command | selection + typeahead + filter; CommandDialog adds popup + focus-trap + dismiss + shortcut + controllable-state |
| timeline | roving-focus |
| stepper | roving-focus + status |
| sidebar | disclosure + controllable-state + shortcut; on phones the Drawer's popup + focus-trap + dismiss + swipe |
| breadcrumb | landmark |
| spinner | live-region |
| screens/billing-screens | selection + roving-focus + controllable-state + live-region |
| screens/monetisation-screens | selection + roving-focus + controllable-state + live-region |
| screens/experiment-screens | selection + live-region + field-wiring |
| screens/status-screens | live-region + field-wiring + roving-focus (timeline) |
| screens/funnel-screens | selection + controllable-state + live-region |
| screens/subscription-charts | field-wiring (labelled filters) + controllable-state (filters) |
| screens/cost-dashboard | controllable-state (range) + live-region (loading, error) |
| screens/growth-screens | selection + roving-focus + controllable-state + popup + dismiss + live-region + field-wiring |
| screens/workflow-screens | roving-focus (timeline) + live-region + field-wiring |
| screens/org-screens | popup + dismiss + live-region + field-wiring + controllable-state |
| screens/collab-screens | combobox (mention picker: aria-activedescendant, arrows, Enter/Tab, Escape) + live-region |
| domain/amount | money-format + tone (colour from the --money-* slots) |
| domain/kanban | controllable-state + live-region + drag + keyboard-move |
| screens/admin-screens | selection + controllable-state + popup + focus-trap + dismiss + roving-focus (tabs) + field-wiring |
@dapplelight/signet-ui/behaviors exports the behaviours a new component
needs directly, with Signet's own types: useShortcut(keys, handler) and
useShortcutLabel(keys) ("mod+k" is ⌘ on Apple platforms, Ctrl elsewhere),
useControllableState({ value, defaultValue, onChange }), and
matchScore(text, query), the fuzzy score Command ranks by.
Field takes a TanStack Form field's state.meta.errors as errors, the same
shape @dapplelight/signet-lib/form reads. Command takes filter={false}
with your own results, so a @dapplelight/signet-lib/search result list can
drive it.
Customising
Every basic follows the same contract, and a new component should too:
- Tokens only. Colours, radii and type come from theme utilities
(
bg-popover,text-text-muted,border-border,rounded-lg); never a hex value or a stock palette colour. classNameon every part, merged over the defaults withcn(tailwind-merge), so a later class wins. Composite components takeclassNamesper part (Toaster,Stepper) or a named class prop (backdropClassName,wrapperClassName,contentClassName).- State as
data-*. Style any state from CSS:data-open,data-highlighted,data-checked,data-disabled,data-invalid,data-complete/data-current/data-upcoming,data-state. - All text overridable for translation:
label,closeLabel,title,description,aria-labelhave English defaults and are props. - Parts are exported one by one (
SidebarHeader,CommandItem…), andrenderswaps a part's element (render={<Button variant="destructive" />},render={<Link to="/" />}). - Controlled or not. Stateful parts take
open/valuewithonOpenChange/onValueChange, ordefaultOpen/defaultValue.
Build a new component
When signet-ui has no component for a need, build it in this package from
signet-ui/behaviors and theme tokens, the way sidebar and stepper are:
- Write its recipe first: which behaviours it needs (popup, dismiss,
focus-trap, selection, roving-focus, typeahead, filter, shortcut,
controllable-state, live-region). Put it as the
// Recipe:line at the top of the file; signet-mcp'scompose_componentreads it. - Reuse a signet-ui part that already has the behaviour (Drawer and Dialog
for popups, Timeline for roving focus over a list, Command for filtering)
before reaching for a new one. Take state and shortcuts from
signet-ui/behaviors. Import@ui-sdk/*only inside this package, never in its exported types. - Style with token utilities and the customising contract above.
- Add keyboard, focus and ARIA tests to
test/basics.tsx; the tokens package test compiles every theme against the new classes. Export it inpackage.jsonand add a demo toapps/showcase. The MCP index and API.md regenerate on their own (see CONTRIBUTING.md).
The full export list is in API.md.
License
MIT
