loke-ui
Entry point and router for @loke/ui headless React UI primitives. Subpath imports only — never import from @loke/ui directly. Components across overlays (Dialog, AlertDialog, Popover, Tooltip, DropdownMenu), forms (Checkbox, RadioGroup, Select, Switch, Label), navigation (Accordion, Tabs, Collapsible, Command), and composition (Primitive+Slot, Context+Collection, Overlay Infrastructure, Hooks). All are thin shells over 4 shared infrastructure patterns: DismissableLayer, FocusScope, Presence, useControllableState.
@loke/ui
Headless, unstyled React UI primitives with granular subpath exports. Every component ships accessible behavior, keyboard navigation, and ARIA semantics. Styling is entirely your responsibility.
Import Rule
ALWAYS import from the component subpath. Never from the root package or Radix paths.
// CORRECT
import { Dialog, DialogContent, DialogTitle } from "@loke/ui/dialog";
import { Select, SelectItem, SelectItemText } from "@loke/ui/select";
// WRONG — these all fail
import { Dialog } from "@loke/ui";
import { Dialog } from "@radix-ui/react-dialog";
import { Dialog } from "@loke/design-system";Mental Model
All components are thin shells over 4 shared infrastructure patterns. Learn these once and every component becomes readable:
| Infrastructure | What it does | Components that use it |
|---|---|---|
| DismissableLayer | Stacked dismiss logic, outside-click, escape key | Dialog, Popover, Tooltip, DropdownMenu |
| FocusScope | Focus trapping, looping, auto-focus on open | Dialog, AlertDialog, Popover (modal) |
| Presence | Animation state machine — delays unmount for exit transitions | All overlays with forceMount |
| useControllableState | Controlled/uncontrolled dual-mode with dev warnings | All stateful components |
Sub-Skills
Route to the skill that matches what you're building:
| Need to… | Skill |
|---|---|
| Build a modal or non-modal dialog | dialog |
| Build a destructive confirmation dialog | alert-dialog |
| Build a floating panel anchored to a trigger | popover |
| Add hover/focus tooltips | tooltip |
| Build a trigger-based dropdown menu | dropdown-menu |
| Build accessible checkboxes (incl. indeterminate) | checkbox |
| Build a single-selection radio group | radio-group |
| Build a listbox-style select for forms | select |
| Build an on/off toggle switch | switch |
| Label a form control accessibly | label |
| Build expandable section groups | accordion |
| Build a tabbed interface | tabs |
| Build a single collapsible section | collapsible |
| Build a command palette or searchable list | command |
| Use asChild / delegate element rendering | primitive-and-slot |
| Build compound components with scoped context | context-and-collection |
| Build a custom overlay from scratch | overlay-infrastructure |
| Use shared hooks (controllable state, size, etc.) | hooks |
| Unsure which component to use | choosing-the-right-component |
Quick Decision Tree
Need floating/overlay UI?
├─ Triggered by hover/focus only + non-interactive content → Tooltip
├─ Triggered by click + interactive content (forms, buttons) → Popover
├─ Triggered by click + list of actions → DropdownMenu
├─ Triggered by click + form value selection (static list) → Select
├─ Triggered by click + searchable/async option list → Popover + Command
├─ Full overlay with title + description
│ ├─ Destructive action confirmation → AlertDialog
│ └─ General purpose modal/sheet → Dialog
└─ Nothing floats, just expand/collapse
├─ Single section → Collapsible
├─ Multiple coordinated sections → Accordion
└─ Tabbed panel switching → Tabs
Need a form control?
├─ Boolean on/off toggle → Switch
├─ Multi-select or tri-state (indeterminate) → Checkbox
├─ Single selection from a group → RadioGroup
├─ Pick a value, submit in a form → Select
└─ Any control needs an accessible name → LabelAll Subpath Imports
import { ... } from "@loke/ui/accordion";
import { ... } from "@loke/ui/alert-dialog";
import { ... } from "@loke/ui/arrow";
import { ... } from "@loke/ui/avatar";
import { ... } from "@loke/ui/checkbox";
import { ... } from "@loke/ui/collapsible";
import { ... } from "@loke/ui/collection";
import { ... } from "@loke/ui/command";
import { ... } from "@loke/ui/compose-events";
import { ... } from "@loke/ui/compose-refs";
import { ... } from "@loke/ui/context";
import { ... } from "@loke/ui/dialog";
import { ... } from "@loke/ui/dismissable-layer";
import { ... } from "@loke/ui/drawer";
import { ... } from "@loke/ui/dropdown-menu";
import { ... } from "@loke/ui/focus-guards";
import { ... } from "@loke/ui/focus-scope";
import { ... } from "@loke/ui/label";
import { ... } from "@loke/ui/menu";
import { ... } from "@loke/ui/number";
import { ... } from "@loke/ui/popper";
import { ... } from "@loke/ui/popover";
import { ... } from "@loke/ui/portal";
import { ... } from "@loke/ui/presence";
import { ... } from "@loke/ui/primitive";
import { ... } from "@loke/ui/radio-group";
import { ... } from "@loke/ui/rect";
import { ... } from "@loke/ui/roving-focus";
import { ... } from "@loke/ui/select";
import { ... } from "@loke/ui/separator";
import { ... } from "@loke/ui/slot";
import { ... } from "@loke/ui/switch";
import { ... } from "@loke/ui/tabs";
import { ... } from "@loke/ui/tooltip";
import { ... } from "@loke/ui/use-callback-ref";
import { ... } from "@loke/ui/use-controllable-state";
import { ... } from "@loke/ui/use-direction";
import { ... } from "@loke/ui/use-escape-keydown";
import { ... } from "@loke/ui/use-id";
import { ... } from "@loke/ui/use-is-document-hidden";
import { ... } from "@loke/ui/use-is-hydrated";
import { ... } from "@loke/ui/use-layout-effect";
import { ... } from "@loke/ui/use-previous";
import { ... } from "@loke/ui/use-size";
import { ... } from "@loke/ui/visually-hidden";Key Patterns
Exit animations need no extra props. Presence keeps the element mounted until a CSS @keyframes animation on data-state="closed" finishes (transitions do not delay unmount). forceMount keeps it mounted permanently, for JS animation libraries that control visibility themselves:
<DialogPortal>
<DialogOverlay className="animate-fade-out data-[state=open]:animate-fade-in" />
<DialogContent className="animate-slide-out data-[state=open]:animate-slide-in">
...
</DialogContent>
</DialogPortal>All stateful components support controlled and uncontrolled mode:
// Uncontrolled (internal state)
<Dialog defaultOpen={false}>...</Dialog>
// Controlled (external state)
<Dialog open={open} onOpenChange={setOpen}>...</Dialog>Do not mix controlled and uncontrolled. Switching at runtime triggers dev warnings and loses state.