@dxos/react-ui-menu
    Preparing search index...

    Interface MenuBuilder

    Top-level builder that creates the root group and produces the final action graph.

    interface MenuBuilder {
        action<P extends {} = {}>(
            id: string,
            props: P & MenuItemChrome & {
                checked?: boolean;
                indent?: number;
                render?: (props: CustomRenderProps) => ReactNode;
                value?: string;
                variant?: "action" | "primary" | "toggle" | "switch" | "custom" | "text";
            } & { presentation?: Partial<Record<string, Partial<MenuActionChrome>>> },
            invoke: () => void,
        ): this;
        build(): ActionGraphProps;
        custom(
            id: string,
            props: Omit<MenuActionProperties, "variant" | "render">,
            render: (props: CustomRenderProps) => ReactNode,
        ): this;
        group(
            id: string,
            props: MenuItemGroupProperties,
            cb: ActionGroupBuilderFn,
        ): this;
        menu(id: string, cb: ActionGroupBuilderFn, testId?: string): this;
        root(props: MenuItemGroupProperties): this;
        separator(variant?: "line" | "gap"): this;
        subgraph(
            subgraphOrCb:
                | undefined
                | null
                | false
                | ActionGraphProps
                | ActionGroupBuilderFn,
        ): this;
        switch(
            id: string,
            props: Omit<MenuActionProperties, "variant"> & { checked: boolean },
            invoke: () => void,
        ): this;
        text(
            id: string,
            props: Omit<MenuActionProperties, "variant" | "render">,
        ): this;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Add an action node as a child of the current group.

      Type Parameters

      • P extends {} = {}

      Parameters

      • id: string
      • props: P & MenuItemChrome & {
            checked?: boolean;
            indent?: number;
            render?: (props: CustomRenderProps) => ReactNode;
            value?: string;
            variant?: "action" | "primary" | "toggle" | "switch" | "custom" | "text";
        } & { presentation?: Partial<Record<string, Partial<MenuActionChrome>>> }
        • Optionalchecked?: boolean
        • Optionalindent?: number

          Depth of the row in a menu listing a tree, which indents it beneath its parent row; a toolbar ignores it.

        • Optionalrender?: (props: CustomRenderProps) => ReactNode

          Renders an arbitrary control in place of the standard button. Required when variant is 'custom'; the contributor owns the element (and its interactions) so the toolbar can host affordances the action model cannot express (e.g. press-and-hold, an embedded dropdown).

        • Optionalvalue?: string
        • Optionalvariant?: "action" | "primary" | "toggle" | "switch" | "custom" | "text"

          text is a plain label (a panel's name) that takes the free space; it is not an item and never collapses.

        • Optionalpresentation?: Partial<Record<string, Partial<MenuActionChrome>>>

          Per-surface chrome overrides, keyed by disposition — lets one action declare multiple dispositions (e.g. ['toolbar', 'list-item']) yet render appropriately in each: a primary toolbar button here, a plain context-menu row there. Applied by the surface bridge that already knows which disposition it's rendering (graphActions's surface option, getListActions), so producers declare it once alongside disposition.

      • invoke: () => void

      Returns this

    • Add a control the caller renders itself (a picker, a field); it stays in the toolbar and never collapses.

      Parameters

      • id: string
      • props: Omit<MenuActionProperties, "variant" | "render">
      • render: (props: CustomRenderProps) => ReactNode

      Returns this

    • Set properties on the root menu group. May only be called once.

      Parameters

      • props: MenuItemGroupProperties

      Returns this

    • Add a switch action rendered as a labeled Field.Switch.

      Parameters

      • id: string
      • props: Omit<MenuActionProperties, "variant"> & { checked: boolean }
      • invoke: () => void

      Returns this

    • Add a plain label (e.g. a panel's name) that takes the toolbar's free space.

      Parameters

      • id: string
      • props: Omit<MenuActionProperties, "variant" | "render">

      Returns this