Skip to content
Documentation

DocumentationMenu

Menu

Actions, context and submenus. One keyboard-friendly menu.

@rentnerkev/menuDocumented version: v1.2.0

Install the package

Use React 19 and import the package stylesheet once in your app’s global CSS. The bundled styles are built for Tailwind CSS 4.

Terminal
bun add @rentnerkev/menu
Global stylesheet / styles.css
@import '@rentnerkev/menu/tailwind.css';

Async actions: pending, retry and success#

Plain action items opt into onSelectAsync(event): Promise<void>; existing onSelect and onAction stay synchronous. Either synchronous callback can call preventDefault() to cancel the async operation before it starts. The item shows pendingLabel with aria-busy and ignores duplicate activation for its full stable submenu ID path, even across rerenders and close/reopen cycles. Different paths remain independent. Links, checkboxes and radio callbacks keep their synchronous behavior.

example.tsx
import { Menu, type MenuItem } from '@rentnerkev/menu'
import { useRef, useState } from 'react'

export default function AsyncSaveMenu() {
    const attempts = useRef(0)
    const [status, setStatus] = useState('No save yet')
    const items: MenuItem[] = [{
        id: 'save',
        label: 'Save changes',
        pendingLabel: 'Saving changes...',
        errorLabel: 'Saving failed. Try again.',
        onSelectAsync: async () => {
            const attempt = ++attempts.current
            await new Promise<void>((resolve) => setTimeout(resolve, 800))
            if (attempt === 1) throw new Error('Local demonstration failure')
            setStatus('Changes saved')
        },
    }]
    return (
        <div>
            <Menu
                ariaLabel="Save actions"
                trigger="Save actions"
                items={items}
                onActionError={() => setStatus('Saving failed. Try again.')}
            />
            <p role="status">{status}</p>
        </div>
    )
}

Installation and shared styling#

Install with bun add @rentnerkev/menu and provide React 19 plus react-dom 19 as peer dependencies. Import the Tailwind stylesheet once in your application CSS; it includes the shared theme tokens. The separate theme.css export contains tokens only. Translate ariaLabel, item labels, descriptions and trigger text in your application; Menu has no messages or locale prop.

styles.css
@import 'tailwindcss';
@import '@rentnerkev/menu/tailwind.css';

:root {
    --rentner-accent: #0369a1;
    --rentner-surface: #ffffff;
    --rentner-foreground: #0f172a;
}

Context menus and touch long press#

ContextMenu wraps your target in a focusable div. Right-click, the ContextMenu key and Shift+F10 open it; longPress optionally adds a stationary touch press. Moving or cancelling the touch cancels the pending press. targetProps customizes the wrapper and targetRef exposes it. The application supplies an accessible ariaLabel.

example.tsx
import { ContextMenu } from '@rentnerkev/menu'
import { useRef, useState } from 'react'

export default function FileContextMenu() {
    const targetRef = useRef<HTMLDivElement>(null)
    const [action, setAction] = useState('None')
    return (
        <div>
            <ContextMenu
                ariaLabel="File context actions"
                longPress
                targetRef={targetRef}
                targetProps={{ className: 'rounded border p-6' }}
                items={[
                    { id: 'rename', label: 'Rename' },
                    { id: 'delete', label: 'Delete', danger: true },
                ]}
                onAction={setAction}
            >
                Right-click or touch and hold this file.
            </ContextMenu>
            <p role="status">Selected: {action}</p>
        </div>
    )
}

Checkboxes, radio groups and indeterminate state#

Checkbox and radio items are controlled: update checked in their onCheckedChange callbacks. Checkbox checked also accepts indeterminate; selecting that state emits true. A radio callback runs only when the item was not already checked. Give related radio items the same name, and use closeOnSelect: false to keep the menu open while changing preferences.

example.tsx
import { Menu } from '@rentnerkev/menu'
import type { MenuItem } from '@rentnerkev/menu'
import { useState } from 'react'

export default function ViewPreferences() {
    const [checked, setChecked] = useState<boolean | 'indeterminate'>(
        'indeterminate',
    )
    const [density, setDensity] = useState<'compact' | 'comfortable'>(
        'comfortable',
    )
    const items: MenuItem[] = [
        {
            id: 'selection',
            type: 'checkbox',
            label: 'Select all',
            checked,
            onCheckedChange: setChecked,
            closeOnSelect: false,
        },
        { id: 'density', type: 'label', label: 'Density' },
        {
            id: 'compact',
            type: 'radio',
            name: 'density',
            label: 'Compact',
            checked: density === 'compact',
            onCheckedChange: () => setDensity('compact'),
            closeOnSelect: false,
        },
        {
            id: 'comfortable',
            type: 'radio',
            name: 'density',
            label: 'Comfortable',
            checked: density === 'comfortable',
            onCheckedChange: () => setDensity('comfortable'),
            closeOnSelect: false,
        },
    ]
    return <Menu ariaLabel="View preferences" trigger="View" items={items} />
}

Controlled state and shared defaults#

Use open and onOpenChange together, or defaultOpen for internal state. MenuProvider supplies customization such as controlSize, side, align, loop, classNames and modal. Nested providers inherit unspecified values and class-name slots; each menu can override them. onEscapeKeyDown can preventDefault() to cancel Escape dismissal.

example.tsx
import { Menu, MenuProvider } from '@rentnerkev/menu'
import { useState } from 'react'

export default function ControlledActions() {
    const [open, setOpen] = useState(false)
    return (
        <MenuProvider
            controlSize="sm"
            align="end"
            loop
            classNames={{ item: 'text-sm' }}
        >
            <Menu
                ariaLabel="Controlled actions"
                trigger="Actions"
                open={open}
                onOpenChange={setOpen}
                items={[{ id: 'refresh', label: 'Refresh' }]}
            />
            <button type="button" onClick={() => setOpen(true)}>
                Open actions
            </button>
        </MenuProvider>
    )
}

Mouse hover opening#

Since v1.0.1, set openOnHover to open a nonmodal Menu with a mouse while keeping the current focus. hoverOpenDelayMs defaults to 100 and hoverCloseDelayMs to 150; entering a menu surface cancels closing. Click, touch and keyboard activation stay available. Keyboard activation takes over from hover. Escape closes the popup; focus stays on an outside control or returns to the trigger when navigating inside. Touch, pen and compatibility mouse events do not trigger hover. Controlled menus use open with onOpenChange. Disabled triggers, preventDefault() and modal behavior are respected.

example.tsx
import { Menu } from '@rentnerkev/menu'

export default function HoverActions() {
    return (
        <Menu
            ariaLabel="Host actions"
            trigger="Actions"
            openOnHover
            hoverOpenDelayMs={100}
            hoverCloseDelayMs={150}
            items={[{ id: 'edit', label: 'Edit host' }]}
        />
    )
}

asChild: one custom native button#

By default trigger is button content, so never nest another button inside it. Set asChild when trigger is a single native button or a component forwarding props and its ref to one. Child handlers run before triggerProps handlers and menu behavior; preventDefault() cancels downstream handling. Child refs and triggerRef are composed, including React 19 callback-ref cleanup. Custom buttons keep their own styling.

example.tsx
import { Menu } from '@rentnerkev/menu'
import { useRef } from 'react'

export default function CustomTrigger() {
    const childRef = useRef<HTMLButtonElement>(null)
    const triggerRef = useRef<HTMLButtonElement>(null)
    return (
        <Menu
            asChild
            ariaLabel="Custom actions"
            triggerRef={triggerRef}
            triggerProps={{ className: 'border rounded px-3 py-2' }}
            trigger={
                <button ref={childRef} type="button">
                    Custom actions
                </button>
            }
            items={[{ id: 'inspect', label: 'Inspect' }]}
        />
    )
}

Separate dropdown and context positioning#

Since v1.1.0, MenuProvider accepts menu and contextMenu positioning defaults: side, align, sideOffset and collisionPadding. Precedence per property is local component, menu-type defaults, shared provider, then built-in defaults; nested providers merge each property. Keyboard opening uses the target rectangle; pointer opening uses the click or long-press coordinates. Without an explicit side, pointer context menus open right in LTR and left in RTL; an explicit side is physical. Nonmodal outside interactions dismiss a context menu even inside its original target while preserving native actions and focus. A long press suppresses its following compatibility click; later taps work normally.

example.tsx
import { ContextMenu, Menu, MenuProvider } from '@rentnerkev/menu'
import type { MenuPositioningProps } from '@rentnerkev/menu'

const contextPosition: MenuPositioningProps = {
    align: 'start',
    sideOffset: 8,
    collisionPadding: 12,
}

export default function PositionedActions() {
    const items = [{ id: 'inspect', label: 'Inspect' }]
    return (
        <MenuProvider
            align="end"
            menu={{ side: 'bottom', sideOffset: 6 }}
            contextMenu={contextPosition}
        >
            <Menu ariaLabel="Toolbar actions" trigger="Actions" items={items} />
            <ContextMenu ariaLabel="File actions" items={items}>
                <button type="button">Right-click or press Shift+F10</button>
            </ContextMenu>
        </MenuProvider>
    )
}

Independent icons, selection marks and arrows#

Since v1.1.0, classNames.icon, indicator and submenuIndicator style action icons, checkbox/radio marks and submenu arrows independently. Icons inherit item text color; selection marks keep the accent color. Icons and marks retain separate space, including unchecked marks. When upgrading, also set classNames.icon if indicator previously styled icons. Replace icon selectors using [data-rentner-menu-indicator] with [data-rentner-menu-icon]; arrows expose [data-rentner-menu-submenu-indicator].

example.tsx
import { Menu } from '@rentnerkev/menu'
import { useState } from 'react'

export default function StyledIndicators() {
    const [checked, setChecked] = useState(false)
    return (
        <Menu
            ariaLabel="Display options"
            trigger="Display"
            classNames={{
                icon: 'text-sky-700',
                indicator: 'text-emerald-700',
                submenuIndicator: 'text-violet-700',
            }}
            items={[
                {
                    id: 'details',
                    type: 'checkbox',
                    label: 'Show details',
                    icon: <span aria-hidden="true">☰</span>,
                    checked,
                    onCheckedChange: setChecked,
                    closeOnSelect: false,
                },
                {
                    id: 'more',
                    type: 'submenu',
                    label: 'More',
                    items: [{ id: 'reset', label: 'Reset view' }],
                },
            ]}
        />
    )
}

Typed menu design tokens#

Since v1.1.0, MenuStyle types nine CSS properties: --rentner-menu-content-min-width, -padding, -radius and -border-width, plus --rentner-menu-item-min-height, -padding-x, -padding-y, -radius and -gap. Pass style to a menu or provider, or set tokens through classNames.content. Explicit item tokens override controlSize defaults. Use tokens for predictable sizing instead of conflicting Tailwind utilities. Tokens inherit from the portal DOM container; use :root or a themed portalContainer. Forced-colors mode retains a visible system-color border.

example.tsx
import { Menu, MenuProvider } from '@rentnerkev/menu'
import type { MenuStyle } from '@rentnerkev/menu'

const menuStyle: MenuStyle = {
    '--rentner-menu-content-min-width': '14rem',
    '--rentner-menu-content-padding': '0.5rem',
    '--rentner-menu-content-radius': '1rem',
    '--rentner-menu-content-border-width': '0px',
    '--rentner-menu-item-min-height': '2rem',
    '--rentner-menu-item-padding-x': '0.75rem',
    '--rentner-menu-item-padding-y': '0.375rem',
    '--rentner-menu-item-radius': '0.5rem',
    '--rentner-menu-item-gap': '0.5rem',
}

export default function CompactActions() {
    return (
        <MenuProvider controlSize="sm" style={menuStyle}>
            <Menu
                ariaLabel="File actions"
                trigger="Actions"
                items={[{ id: 'save', label: 'Save' }]}
            />
        </MenuProvider>
    )
}

Canonical documentation and the optional MCP server#

The canonical public MCP endpoint is https://packages.rentner.dev/mcp. Configure it explicitly in a compatible client for read-only package documentation. https://packages.rentner.dev/llms.txt indexes the catalog, and https://packages.rentner.dev/ai/menu?locale=en returns the English Menu guide. These remote pages describe the website catalog; the local /ai helpers below describe your installed package. Neither installation nor importing /ai configures or connects an AI client.

documentation-sources.ts
export const menuDocumentation = {
    mcp: 'https://packages.rentner.dev/mcp',
    index: 'https://packages.rentner.dev/llms.txt',
    guide: 'https://packages.rentner.dev/ai/menu?locale=en',
}

Local AI helpers: metadata & guides#

Import the /ai entry in a local Node.js or Bun script. These synchronous, read-only helpers use node:fs to read the installed package without importing its UI. getPackageInfo() returns PackageInfo, including the installed version, public exports and peer dependencies. getPackageDocumentation() returns a PackageDocument with path and content; its default is usage, and readme selects README.md. Only these two packaged documents are accepted. Results describe your installed version, which can differ from this website.

inspect-package.ts · Node.js / Bun
import { getPackageDocumentation, getPackageInfo } from '@rentnerkev/menu/ai'
import type { PackageDocument, PackageInfo } from '@rentnerkev/menu/ai'

const info: PackageInfo = getPackageInfo()
const usage: PackageDocument = getPackageDocumentation()
const readme = getPackageDocumentation('readme')

console.log(info.name, info.version, info.exports, info.peerDependencies)
console.log(usage.path, usage.content)
console.log(readme.path, readme.content)

Local AI helpers: public declarations#

getPackageApi() returns PackageApi with package, installed version, selected subpaths and declarations as PackageDocument objects. It reads public typed entries and their local declaration dependencies; /ai itself is excluded. Use subpath such as . or ./types to select a public entry. symbol validates that a name is exported by the selected entry; it does not trim declaration files to that symbol. Unknown subpaths, invalid names and names not exported by the selected entry throw errors. Callers cannot provide arbitrary file paths.

inspect-api.ts · Node.js / Bun
import { getPackageApi } from '@rentnerkev/menu/ai'
import type { PackageApi } from '@rentnerkev/menu/ai'

const api: PackageApi = getPackageApi()
const selected = getPackageApi({ subpath: '.', symbol: 'Menu' })

console.log(api.package, api.version, api.subpaths)
for (const declaration of selected.declarations) {
    console.log(declaration.path, declaration.content)
}

Local AI helpers: search & examples#

searchPackageDocumentation(query) searches README.md and docs/usage.md using a trimmed, case-insensitive literal query. It returns PackageSearchMatch objects with path, a one-based line number and matching text; an empty query returns an empty array. getPackageExamples() returns every fenced code block from the installed usage guide as a PackageExample with language and code. These helpers return text for your own tools; they do not execute examples or contact an AI service.

search-package.ts · Node.js / Bun
import { getPackageExamples, searchPackageDocumentation } from '@rentnerkev/menu/ai'
import type { PackageExample, PackageSearchMatch } from '@rentnerkev/menu/ai'

const matches: PackageSearchMatch[] = searchPackageDocumentation('Menu')
const examples: PackageExample[] = getPackageExamples()

for (const match of matches) {
    console.log(match.path, match.line, match.text)
}
for (const example of examples) {
    console.log(example.language, example.code)
}

Docs for your AI tools

Connect a compatible MCP client to read package APIs, guides and examples. Public access, no account or API key required.

Remote access is optional: add this public URL yourself to your MCP client. Clients use Streamable HTTP; the configuration format may vary. The local package /ai helpers read the installed version in Node.js or Bun and never connect to this server automatically.

MCP / Streamable HTTP
{
    "mcpServers": {
        "rentnerPackages": {
            "url": "https://packages.rentner.dev/mcp"
        }
    }
}

Tools: list_packages, read_package_docs, read_package_api, read_package_examples and search_package_docs.

API & types

Published signatures, props and types for this version. Expand an entry to inspect its definition and available import paths.

Menufunction
  • @rentnerkev/menu
  • @rentnerkev/menu/menu
Menu.d.ts
export function Menu(props: MenuProps): import("react").JSX.Element
ContextMenufunction
  • @rentnerkev/menu
  • @rentnerkev/menu/context-menu
ContextMenu.d.ts
export function ContextMenu(props: ContextMenuProps): import("react").JSX.Element
MenuProviderfunction
  • @rentnerkev/menu
  • @rentnerkev/menu/provider
MenuProvider.d.ts
export function MenuProvider({ children, ...props }: MenuProviderProps): import("react").JSX.Element
ContextMenuPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
ContextMenuProps.d.ts
export interface ContextMenuProps extends MenuCommonProps {
    children: ReactNode
    targetRef?: Ref<HTMLDivElement>
    targetProps?: HTMLAttributes<HTMLDivElement>
    /** Enables a stationary touch press in addition to contextmenu and Shift+F10. */
    longPress?: boolean
}
MenuActionIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuActionItem.d.ts
export interface MenuActionItem extends MenuItemBase {
    type?: 'item'
    danger?: boolean
    closeOnSelect?: boolean
    onSelect?: (event: MenuSelectEvent) => void
    /** Opt into pending/error handling and close only after successful completion. */
    onSelectAsync?: (event: MenuSelectEvent) => Promise<void>
    /** Visible while onSelectAsync is running. Defaults to 'Working…'. */
    pendingLabel?: string
    /** Safe, visible failure message. Defaults to 'Action failed. Try again.'. */
    errorLabel?: string
}

interface MenuItemBase {
    id: string
    label: string
    icon?: ReactNode
    description?: string
    disabled?: boolean
    shortcut?: string
}
MenuAligntype
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuAlign.d.ts
export type MenuAlign = 'start' | 'center' | 'end'
MenuCheckboxIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuCheckboxItem.d.ts
export interface MenuCheckboxItem extends MenuItemBase {
    type: 'checkbox'
    checked: boolean | 'indeterminate'
    closeOnSelect?: boolean
    onCheckedChange: (checked: boolean) => void
}

interface MenuItemBase {
    id: string
    label: string
    icon?: ReactNode
    description?: string
    disabled?: boolean
    shortcut?: string
}
MenuClassNamesinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuClassNames.d.ts
export interface MenuClassNames {
    trigger?: string
    target?: string
    portal?: string
    content?: string
    item?: string
    icon?: string
    label?: string
    description?: string
    shortcut?: string
    indicator?: string
    /** Styles the submenu arrow independently from icons and selection indicators. */
    submenuIndicator?: string
    separator?: string
    groupLabel?: string
}
MenuCommonPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuCommonProps.d.ts
export interface MenuCommonProps extends MenuCustomizationProps {
    items: readonly MenuItem[]
    ariaLabel: string
    id?: string
    disabled?: boolean
    open?: boolean
    defaultOpen?: boolean
    onOpenChange?: (open: boolean) => void
    onAction?: (id: string, event: MenuSelectEvent) => void
    /** Observes async action failures, including operations completed after dismissal. */
    onActionError?: (error: unknown, event: MenuSelectEvent) => void | Promise<void>
    onEscapeKeyDown?: (event: KeyboardEvent) => void
}
MenuCustomizationPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuCustomizationProps.d.ts
export interface MenuCustomizationProps extends MenuPositioningProps {
    /** Blocks background interaction and scrolling while open. Defaults to false. */
    modal?: boolean
    dir?: MenuDirection
    controlSize?: 'sm' | 'md' | 'lg'
    loop?: boolean
    portalContainer?: Element | DocumentFragment | null
    portalZIndex?: number
    classNames?: MenuClassNames
    style?: MenuStyle
}
MenuDirectiontype
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuDirection.d.ts
export type MenuDirection = 'ltr' | 'rtl'
MenuItemtype
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuItem.d.ts
export type MenuItem = MenuActionItem | MenuLinkItem | MenuCheckboxItem | MenuRadioItem | MenuSubmenuItem | MenuSeparatorItem | MenuLabelItem
MenuLabelIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuLabelItem.d.ts
export interface MenuLabelItem {
    type: 'label'
    id: string
    label: string
}
MenuPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuProps.d.ts
export interface MenuProps extends MenuCommonProps {
    /** Opt into mouse hover opening for nonmodal menus without moving focus. */
    openOnHover?: boolean
    /** Mouse hover opening delay in milliseconds. Defaults to 100. */
    hoverOpenDelayMs?: number
    /** Mouse leave closing delay in milliseconds. Defaults to 150. */
    hoverCloseDelayMs?: number
    /** Use a single custom button element as the trigger, forwarding its props/ref. */
    asChild?: boolean
    /** Content of the native button rendered by Menu do not pass another button. */
    trigger?: ReactNode
    triggerRef?: Ref<HTMLButtonElement>
    triggerProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'disabled' | 'aria-controls' | 'aria-expanded' | 'aria-haspopup'>
}
MenuPositioningPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuPositioningProps.d.ts
export interface MenuPositioningProps {
    side?: MenuSide
    align?: MenuAlign
    sideOffset?: number
    collisionPadding?: number
}
MenuProviderPropsinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuProviderProps.d.ts
export interface MenuProviderProps extends MenuCustomizationProps {
    children: ReactNode
    /** Positioning defaults for dropdowns local menu props take precedence. */
    menu?: MenuPositioningProps
    /** Positioning defaults for context menus shared provider props still inherit. */
    contextMenu?: MenuPositioningProps
}
MenuRadioIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuRadioItem.d.ts
export interface MenuRadioItem extends MenuItemBase {
    type: 'radio'
    name: string
    checked: boolean
    closeOnSelect?: boolean
    onCheckedChange: () => void
}

interface MenuItemBase {
    id: string
    label: string
    icon?: ReactNode
    description?: string
    disabled?: boolean
    shortcut?: string
}
MenuSelectEventinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuSelectEvent.d.ts
export interface MenuSelectEvent {
    readonly id: string
    readonly originalEvent: Event
    readonly defaultPrevented: boolean
    preventDefault: () => void
}
MenuSeparatorIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuSeparatorItem.d.ts
export interface MenuSeparatorItem {
    type: 'separator'
    id: string
}
MenuSidetype
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuSide.d.ts
export type MenuSide = 'top' | 'right' | 'bottom' | 'left'
MenuStyleinterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuStyle.d.ts
export interface MenuStyle extends CSSProperties {
    '--rentner-menu-content-min-width'?: string
    '--rentner-menu-content-padding'?: string
    '--rentner-menu-content-radius'?: string
    '--rentner-menu-content-border-width'?: string
    '--rentner-menu-item-min-height'?: string
    '--rentner-menu-item-padding-x'?: string
    '--rentner-menu-item-padding-y'?: string
    '--rentner-menu-item-radius'?: string
    '--rentner-menu-item-gap'?: string
}
MenuSubmenuIteminterface
  • @rentnerkev/menu
  • @rentnerkev/menu/types
MenuSubmenuItem.d.ts
export interface MenuSubmenuItem extends MenuItemBase {
    type: 'submenu'
    items: readonly MenuItem[]
}

interface MenuItemBase {
    id: string
    label: string
    icon?: ReactNode
    description?: string
    disabled?: boolean
    shortcut?: string
}
PackageInfointerface
  • @rentnerkev/menu/ai
PackageInfo.d.ts
export interface PackageInfo {
    name: string
    version: string
    description: string
    license: string
    homepage: string
    repository: {
        type: string
        url: string
    }
    exports: Record<string, string | {
        types?: string
        import?: string
        default?: string
    }>
    peerDependencies: Record<string, string>
}
PackageDocumentinterface
  • @rentnerkev/menu/ai
PackageDocument.d.ts
export interface PackageDocument {
    path: string
    content: string
}
PackageApiinterface
  • @rentnerkev/menu/ai
PackageApi.d.ts
export interface PackageApi {
    package: string
    version: string
    subpaths: Record<string, string>
    declarations: PackageDocument[]
}
PackageSearchMatchinterface
  • @rentnerkev/menu/ai
PackageSearchMatch.d.ts
export interface PackageSearchMatch {
    path: string
    line: number
    text: string
}
PackageExampleinterface
  • @rentnerkev/menu/ai
PackageExample.d.ts
export interface PackageExample {
    language: string
    code: string
}
getPackageInfofunction
  • @rentnerkev/menu/ai
getPackageInfo.d.ts
export function getPackageInfo(): PackageInfo
getPackageDocumentationfunction
  • @rentnerkev/menu/ai
getPackageDocumentation.d.ts
export function getPackageDocumentation(document?: 'readme' | 'usage'): PackageDocument
getPackageApifunction
  • @rentnerkev/menu/ai
getPackageApi.d.ts
export function getPackageApi(options?: {
    subpath?: string
    symbol?: string
}): PackageApi
searchPackageDocumentationfunction
  • @rentnerkev/menu/ai
searchPackageDocumentation.d.ts
export function searchPackageDocumentation(query: string): PackageSearchMatch[]
getPackageExamplesfunction
  • @rentnerkev/menu/ai
getPackageExamples.d.ts
export function getPackageExamples(): PackageExample[]