> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.getMenuButtonBoundingClientRect

> Get the layout position of the capsule (menu) button and the favorite button.

Retrieves the layout position of the capsule button (top-right) and of the favorite button.

> [!NOTE]
>
> Requires Appx 1.25.4 or higher.

## Parameters

| Property | Type | Required | Description |
| - | - | - | - |
| success | Function | No | Callback on success |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |

## Return Value / Success Callback

| Property | Type | Description |
| - | - | - |
| width | Number | Width of the capsule button, in px |
| height | Number | Height of the capsule button, in px |
| top | Number | Top edge, in px, from the screen's top-left corner |
| bottom | Number | Bottom edge, in px, from the screen's top-left corner |
| left | Number | Left edge, in px, from the screen's top-left corner |
| right | Number | Right edge, in px, from the screen's top-left corner |
| favIcon | Object | Position of the favorite button: `width`, `height`, `top`, `bottom`, `left`, `right` (px, from the screen's top-left corner) |

## Error Codes

| Code | Message | Action |
| - | - | - |
| 1111 | not titleBar | The capsule button may not have finished rendering (on iOS, `left` and similar values may be `0`). Call the API again after a short delay |

## Code Example

```javascript theme={null}
Page({
  onReady() {
    // Call after the navigation bar has rendered
    setTimeout(() => {
      const res = my.getMenuButtonBoundingClientRect();
      if (res) {
        console.log('Capsule:', res.top, res.right, 'Favorite:', res.favIcon);
      }
    }, 100);
  }
});
```

## FAQ

> [accordion] How do I get the favorite button position?
>
> Read the `favIcon` object returned by this API. To check whether the Mini Program has been added to favorites, use [my.isCollected](https://docs.rebellapp.com/jsapi/collection/my.isCollected.md).

> [accordion] Why are the values inaccurate, zero or negative?
>
> On iOS the values can be `0` if the API is called before the capsule button has rendered. Call it with a short delay.

## Related APIs

> [card] [my.setNavigationBar](https://docs.rebellapp.com/jsapi/ui/navigation-bar/my.setNavigationBar.md)
>
> Set the navigation bar

> [card] [my.isCollected](https://docs.rebellapp.com/jsapi/collection/my.isCollected.md)
>
> Check favorite status


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.