# Get root widget of UMG in blueprints?

**URL:** <https://forums.unrealengine.com/t/get-root-widget-of-umg-in-blueprints/364290>\
**Category:** UI\
**Tags:** unreal-engine, UE4, question, Blueprint, UMG\
**Created:** [July 17, 2016, 3:51pm UTC](https://forums.unrealengine.com/t/get-root-widget-of-umg-in-blueprints/364290 "2016-07-17T15:51:51Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![HungryHenry](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/hungryhenry/32/722352_2.png) [@HungryHenry](https://forums.unrealengine.com/u/HungryHenry)\
**Post date:** [April 11, 2024, 2:08am UTC](https://forums.unrealengine.com/t/get-root-widget-of-umg-in-blueprints/364290/8 "2024-04-11T02:08:36Z")

</div>

For anyone in need of the “Get Root Widget” function in blueprints, especially in the dynamic widget tree where assigning manually isn’t practical, here’s a recursive function inspired by “BDC\_Patrick 🇩🇪🇬🇧🇺🇸” from the Discord community.  
I have tested it. Started from Image. Got the CanvasPanel. Not the Top “CustomUserWidget” as I expected. But this might be handy for you.

 ![Snipaste_2024-04-11_10-01-53](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/6/0f6cc852b8e521afc14026d347799716b3f303ba.png)

In case of the image not loaded properly:

```auto
UUserWidget* FindRootWidget(UUserWidget* CurrentWidget)
{
    if(!IsValid(CurrentWidget->GetParent())){
        return CurrentWidget;
    }
    return FindRootWidget(CurrentWidget->GetParent());
}

```

---

_[View the full topic](https://forums.unrealengine.com/t/get-root-widget-of-umg-in-blueprints/364290)._
