Main Content

enableLegacyPadding

Decrease padding in panel UI container

Since R2025a

    Description

    enableLegacyPadding(p) slightly decreases the padding around the title and inside borders of the specified panel.

    In most cases, you do not need to use this function. By default, legacy padding is enabled for panels in figure-based apps and disabled for panels in uifigure-based apps. If you update an app to use uifigure and notice a panel in the app has clipped components, enableLegacyPadding updates the spacing of panel elements to match that of panels in figure-based apps.

    example

    enableLegacyPadding(fig) updates the padding of all the panels contained in the specified figure.

    Examples

    collapse all

    Create an app that contains a panel with some UI components. The components extend slightly outside the interior area of the panel.

    fig = uifigure(Position=[100 100 500 300]);
    fig.Position = [100 100 500 300];
    pnl = uipanel(fig,Position=[10 10 480 280],Title="My Panel");
    tg = uitabgroup(pnl,Position=[10 24 460 240]);
    t1 = uitab(tg,Title="Tab 1");
    t2 = uitab(tg,Title="Tab 2");
    b = uibutton(pnl,Text="Plot Data",Position=[200 0 80 22]);

    Figure contains an object of type uipanel.

    Enable legacy padding for the panel. The components fit entirely inside the interior area.

    enableLegacyPadding(pnl)

    Figure contains an object of type uipanel.

    Revert the panel padding changes.

    disableLegacyPadding(pnl)

    Figure contains an object of type uipanel.

    Input Arguments

    collapse all

    Panel UI container, specified as a Panel object created using the uipanel function.

    Figure, specified as a Figure object. enableLegacyPadding updates the padding for all panels in the figure.

    Version History

    Introduced in R2025a