Command palette

@yasinsensoy/web
v0.1.090 components

@yasinsensoy/web

Fast, dependency-free React and Next.js component library built on Tailwind CSS v4.

Component library for React and Next.js. Works with Tailwind CSS v4, has no runtime dependencies, and ships mobile behaviors and accessibility built in.

Installation

pnpm add @yasinsensoy/web

The project's main CSS file:

@import "tailwindcss";
@import "@yasinsensoy/web/styles.css";

Root layout (Next.js App Router):

import { ThemeProvider, Toaster } from "@yasinsensoy/web";
import { UIProvider } from "@yasinsensoy/web/next";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body className="bg-background text-foreground">
        <ThemeProvider>
          <UIProvider licenseKey={process.env.NEXT_PUBLIC_UI_LICENSE}>
            {children}
            <Toaster />
          </UIProvider>
        </ThemeProvider>
      </body>
    </html>
  );
}

License

Free in development (next dev, localhost); no key is required. In production, if UIProvider's licenseKey prop is not given a valid license key, the page is locked behind a "License required" screen. The key works only on the domains it is bound to (set them in the license portal). Do not hard-code the key; read it from an environment variable.

Language (i18n)

The app's translations and the library's own texts ("Close", "Cancel"…) live in one dictionary; keys and {name} placeholders are inferred from the type. Setup is three files:

// messages/en.ts — default locale, type source
import { defineMessages } from "@yasinsensoy/web";
export default defineMessages({
  ui: { cancel: "Dismiss" },                 // library text (optional)
  home: { title: "Welcome, {name}" },
  cart: { items: { one: "{count} item", other: "{count} items" } },
});

// messages/tr.ts — a missing key or forgotten {name} is a compile error
import { trMessages, type Translation } from "@yasinsensoy/web";
export default {
  ui: trMessages,                            // the library's ready Turkish set
  home: { title: "Hoş geldin, {name}" },
  cart: { items: { one: "{count} ürün", other: "{count} ürün" } },
} satisfies Translation;

// i18n.ts — not "use client"; shared by server and client
import { createI18n } from "@yasinsensoy/web";
import en from "./messages/en";
export const i18n = createI18n({
  defaultLocale: "en",
  locales: { en, tr: () => import("./messages/tr") },  // tr loads when needed
});
declare module "@yasinsensoy/web" {
  interface Register { messages: typeof en }
}

Usage:

// app/[lang]/layout.tsx (server)
<UIProvider locale={lang} messages={await i18n.load(lang)}>{children}</UIProvider>

// server component, generateMetadata, route handler, server action
const t = await i18n.getT(lang);
<h1>{t("home.title", { name })}</h1>

// client component
const t = useT();
<Button>{t("cart.items", { count })}</Button>

// middleware/proxy: redirect by the browser's language
i18n.match(request.headers.get("accept-language"))
  • Pass translations to props such as label and title with t(...); a key string (label="home.title") is not translated automatically.
  • Numbers and dates are formatted per locale ({count} → 1,234); the plural form is chosen by the locale's rules.
  • Each component bundles only its own texts; an app that passes no dictionary gets the Turkish defaults.

Rules

  • Import everything from the package root: import { Button } from "@yasinsensoy/web". The package is side-effect free (sideEffects is CSS only); bundlers drop unused components, so importing from the root adds no size. The same components are also available from subpaths (@yasinsensoy/web/button, /data-grid, /hooks, /utils, /theme…); this lets the dev server compile only the files it needs. In Next.js, experimental.optimizePackageImports: ["@yasinsensoy/web"] gives the root the same effect.
  • Heavy parts that only appear on interaction (confirm dialog, the gallery's fullscreen viewer, code languages) load in separate chunks via import(); they are not part of the initial page load.
  • Style with Tailwind classes via className. Conflicting classes are merged with cn and yours win.
  • Use theme classes for colors (bg-primary, text-muted-foreground, border-border…); do not hard-code colors. For a new theme, define the --ui-* variables.
  • Components are used through props; no nested parts are written: <Dialog title onConfirm>, <Card title footer>, <Tabs items>, <Menu trigger items>, <Table columns rows>, <TextField label name>, await confirm({...}). Lists are given as an items array.
  • Text props such as title, label and description accept both text and elements. icon is either an element (<TrashIcon />) or a name in the library given to UIProvider via icons (icon="trash"); names are type-checked via the Register interface.
  • The appearance vocabulary is the same on every component: tone is meaning (primary | neutral | danger | success | warning), size is size (sm | md | lg), variant is style. On buttons variant is solid | soft | outline | ghost | link | gradient | elevated | dashed and shape is rounded | pill | sharp. On form fields variant is outline | filled | underline | ghost.
  • Effects (effect) are the same on every component and combine as an array: on press scale | ripple | pulse | bounce; on hover lift | border | beam | glow | tilt | shine; none turns them off. Buttons, cards, badges, all form fields (Input, Select, NumberInput, DatePicker… and the *Fields), choice controls, Tabs, Accordion, Collapsible, Stepper, OtpInput, Timeline, TableOfContents, Countdown, Rating, Menu/ContextMenu, Sidebar, NavigationMenu, Breadcrumb, TreeView, Kanban, NotificationCenter, FileUpload, Image, Gallery, ColorSwatch, Dialog, Sheet, Popover, HoverCard, Toaster, Fab accept it. For effects on your own element use getEffects(["tilt", "glow"]).
  • App-wide appearance is set in one place; do not repeat it on every component: define it with defineAppearance({ defaults, effects, variants }) and pass it to UIProvider appearance={...}. defaults are per-component default variant, effect, tone, size, shape (the component name starting lowercase: button, card, field (all form fields), menu, dialog, tableOfContents…); effects are your own effects (className, press, setup); variants are your own styles (button: { neon: "…classes" }, field: { glass: { extends: "filled", className } }, extends, tones). Names become type-checked with Register { appearance: typeof appearance }. Server components (Card, Badge) read the settings from the defineAppearance registry; import the settings file in the root layout. Floating label: UIProvider floatingLabel; field appearance in a container: data-field-variant="filled" (all fields in that section). The focus color is the --ui-field-focus variable.
  • For a link write <Button href="/x">; asChild is not needed. Do not manage loading state by hand: when onClick/onConfirm returns a Promise, the component shows loading itself.
  • Components marked "Client component" contain "use client". They can be used in server components, but functions (e.g. onClick) cannot be passed to them from the server; move the interactive part into a separate client component.
  • Mobile behaviors (closing with the back button, swipe to close, bottom sheet presentation, keyboard inset, 44 px touch targets) are built in; do not rewrite them.
  • For form validation use the browser's rules (required, type, minLength…) with Field and Form. If the project has a Zod (or Valibot, ArkType) schema, pass Form schema={Schema} and validate the same schema in the server action with validateForm(Schema, formData); do not write z.coerce or your own FormData parser.
  • Every interactive element must have a visible name or an aria-label.

Which component?

Pick the right one among components that do similar jobs; do not build the same thing by hand.

  • Form field: In forms use the *Field versions instead of bare inputs (TextField, NumberField, SelectField, DateField, CheckboxField, RadioField, SliderField, OtpField, FileField…); label, description, error and Form state come built in. Bare components (Input, Select…) are for use outside forms.
  • Building forms: a whole form from a schema or JSON definition → SchemaForm (sections, conditional fields, wizard via steps); a hand-written multi-step form → Wizard. Draft saving → draft, initial values → defaultValues (both on Form/Wizard/SchemaForm).
  • Repeating rows: rows that are added and removed, such as invoice lines, phone numbers or education history → FieldArray (title, add/remove/duplicate, drag to reorder via sortable, empty state and array error built in); useFieldArray for your own layout. Give field names with row.name("name") (items[0].name); use row.key as the key, not the index. If the schema has an array of objects, SchemaForm renders it itself.
  • Country / phone: country choice → CountryField/CountrySelect; phone with country code (submits E.164) → PhoneField/PhoneInput; for Turkish numbers only, TextField mask="phone" is enough.
  • Masked text: formatted inputs such as phone, licence plate, IBAN, Turkish national ID, card or date → TextField/Input mask (built-in names or a pattern like "(999) 999 99 99"); do not write your own onChange formatter. To format a stored value use applyMask. A label inside the field that moves up while typing (floating label) → floatingLabel.
  • Choice: 2–5 options → RadioGroup (variant="segment" or "card"); long list, search or remote loading → Select; free text + suggestions → Autocomplete; free tag list (keywords, email recipients) → TagInput/TagField; on/off → Switch; consent → Checkbox; star rating → Rating/RatingField; choice from nested options (category, department, multi-select) → TreeSelect/ TreeSelectField; level-by-level choice (province → district → neighborhood) → Cascader/CascaderField; multi-select by moving between two lists (role permissions, visible columns, ordered choice) → Transfer/TransferField; color → ColorPicker/ColorField (only to display it: ColorSwatch).
  • Long text: plain text → TextField multiline; plain text + @person/#tag mentions (comments, chat box) → MentionInput/ MentionField (showing saved text → MentionView, on the server parseMentions); rich text (headings, lists, links, images, @mentions) → RichTextEditor/ RichTextField, showing saved content → RichTextView; code → CodeBlock.
  • File and media input: picking/uploading files → FileUpload/FileField (layout="list" | "gallery" | "inline"); cropping, rotating, adding text/drawing to a chosen image/video, trimming video → FileUpload edit (standalone MediaEditor). For a profile photo use edit={{ image: { crop: { aspectRatio: 1, shape: "circle" } } }}.
  • Multi-step work: step indicator → Stepper; step-by-step form → Wizard.
  • Number: typed number (amount, quantity) → NumberInput; rough pick within a bounded range (volume, price range) → Slider; verification code → OtpInput.
  • Date: single day → DatePicker; range → DateRangePicker; time → TimePicker; countdown / timer (campaign end, exam time, call duration) → Countdown (your own UI → useCountdown; do not write setInterval); month only (billing period, expiry) → MonthPicker/ MonthField; year only → YearPicker/YearField; calendar embedded in the page → Calendar (month/year grid → MonthCalendar/YearCalendar).
  • Table: a list of up to a few hundred rows that can render on the server → Table; thousands of rows, filters, editing, grouping, column management or server mode → DataGrid. Nested hierarchy (folders, categories) → TreeView; a tree in table form → DataGrid (getChildren). A long non-table list (contacts, records) → VirtualList; a feed loaded page by page → InfiniteScroll (for tens of thousands of items VirtualList + onLoadMore).
  • Layer: confirmation or a short form → Dialog (for a question only, await confirm({...})); details/filters/menu opening from an edge, a bottom sheet resized by finger, a list over a map → Sheet (side="bottom", snapPoints, modal={false}); small panel attached to a button → Popover; small "Are you sure?" confirmation next to a button (deleting a row) → Popconfirm; preview on hovering a link → HoverCard; action list → Menu; right click → ContextMenu; short explanation → the tooltip prop or InfoTip; in-app search and commands (⌘K) → CommandPalette; introducing the UI to new users → Tour.
  • Buttons: single action → Button (icon only → IconButton); connected side-by-side buttons, toolbar, split button or single/multi select buttons → ButtonGroup (overflow goes into a ⋯ menu with overflow="menu").
  • Feedback: transient notification → toast(); message that stays on the page → Alert; loading → Skeleton (content placeholder), Spinner (small area), Progress (percentage). For a loading state on a button, return a Promise from onClick. Turning a real component into a placeholder → <Skeleton loading>{…}</Skeleton>. Empty list, no search results, error, no connection → EmptyState (preset). The bell in the top bar, unread badge and notification list → NotificationCenter (useNotifications for state; a list embedded in the page: inline).
  • Navigation: the app's main menu → Sidebar (bottom bar or sheet on mobile); site top menu, dropdown mega menu panel (corporate site, product page) → NavigationMenu (side sheet on mobile); page path → Breadcrumb; views on the same page → Tabs; paged list → Pagination (href for URL-based); table of contents and the section being read on a long page → TableOfContents (useScrollSpy for your own menu); back-to-top button → BackToTop; primary action on mobile → Fab.
  • Media: single image → Image; image/video grid, selection, fullscreen → Gallery (fullscreen only → Lightbox); video → VideoPlayer; sliding slides, product strip, logo marquee → Carousel; person → Avatar (several → AvatarGroup); status label → Badge.
  • Sorting: a list or grid reordered by drag and drop (todos, menu order, photo order) → SortableList (drag only from a handle with handle + SortableHandle); keyboard and touch built in. Use moveItem to move an array item. Across columns → Kanban, tree → TreeView.
  • Planning and flow: task board (drag and drop) → Kanban; appointment and event calendar (month/week/day/agenda) → EventCalendar; not for picking dates but for showing events in time order → Timeline.
  • Data visualization: axis chart, pie/donut → Chart; small trend inside text → Sparkline; dashboard metric card (value, change, trend) → Stat.
  • Page layout: stacking vertically / horizontally with spacing → Stack (direction={{ base: "column", md: "row" }}, gap, separator); grid → Grid (columns={{ base: 1, md: 3 }} or, without writing breakpoints, minItemWidth="16rem"); page width and side padding → Container (query for @md: classes based on box width); fixed ratio image/video → AspectRatio; screen-reader-only text, a "Skip to content" link → VisuallyHidden; show/hide by screen width → Show above="md" (flicker-free; useMediaQuery only for behavior). Tailwind classes (flex gap-4) are fine in simple cases; use these to pass responsive values as props.
  • Copying: copy-to-clipboard button → CopyButton; for your own button useClipboard. Do not hand-write navigator.clipboard (it does not work on http, and the "copied" state and screen reader announcement are missing).
  • Hooks: open/closed state (Dialog, Sheet) → useDisclosure (<Dialog {...modal.props}>); debounced search → useDebounce, a debounced or throttled function → useDebouncedCallback; a setting stored in the browser → useLocalStorage/useSessionStorage (hydration safe, synced across tabs); keyboard shortcut → useHotkeys("Mod+K", …) (Kbd to display it, shortcut on menu items); visibility, lazy loading → useIntersection; element size → useResizeObserver; media query → useMediaQuery. Do not rewrite these with useEffect + addEventListener.
  • Layout: grouping → Card (style variant; effect effect: lift, border, beam rotating light, glow cursor light, tilt 3D tilt, shine, ripple…; selected card → active); collapsible sections → Accordion; resizable panes → ResizablePanels; scroll area → ScrollArea; code → CodeBlock; JSON data (API response, config, log) as a tree → JsonView; "CONFIDENTIAL"/"DRAFT" watermark → Watermark (getWatermarkStyle on your own element); a single collapsible section or "show more" → Collapsible; writing a keyboard shortcut → Kbd; QR code → QRCode; signature → SignaturePad/SignatureField.
  • PWA: install → InstallPrompt/InstallButton; new version → UpdatePrompt; connection → OfflineIndicator; notch → SafeArea; sharing → ShareButton; browser bar color → ThemeColor.
  • Theme: switching theme → useTheme().setTheme; UI that shows the selected theme (picker, sun/moon icon) → ThemeView (no server/client mismatch and no flicker on first paint); transition animation → ThemeProvider transition.

Page templates

Before writing a new page, copy and adapt a suitable ready template: app-shell (app skeleton with sidebar), dashboard (KPI cards, charts, table, activity feed), settings (tabbed settings forms, server actions), login (sign-in + two-step verification code). npx @yasinsensoy/web template lists them, npx @yasinsensoy/web template dashboard copies the files into place in the project. In the skill they live in the templates/ folder.

For AI agents

This document is generated from the package's TSDoc comments (catalog.json, llms.txt and the Claude skill). To install the skill into a project run npx @yasinsensoy/web skill; run it again after updating the package.

Besides the skill there is also an MCP server: the agent can list and search components and read docs, prop tables, examples and templates on demand (get_guide, list_components, search, get_docs, get_props, list_templates, get_template). It always matches the installed version. npx @yasinsensoy/web mcp init writes the config to the project (Claude Code .mcp.json; for Cursor and VS Code --client cursor,vscode). Before using a component, read the prop table and examples in its reference file; do not invent a prop that is not in the table.

Components

APIs and utilities