Main Content


Create panel container


p = uipanel creates a panel in the current figure and returns the Panel object. If there is no figure available, MATLAB® calls the figure function to create one.

p = uipanel(Name,Value) specifies panel property values using one or more name-value pair arguments.

p = uipanel(parent) creates the panel in the specified parent container. The parent container can be a figure created with either the figure or uifigure function, or a child container such as a tab or grid layout. Property values for uipanel vary slightly depending on whether the app is created with the figure or uifigure function. For more information, see Name-Value Pair Arguments.


p = uipanel(parent,Name,Value) specifies the parent container and one or more properties values.


collapse all

Create a figure containing two panels and a push button. The panels use the default Units property value, 'normalized'. The default units for the uicontrol is 'pixels'.

f = figure;
p = uipanel('Title','Main Panel','FontSize',12,...
             'Position',[.25 .1 .67 .67]);
sp = uipanel('Parent',p,'Title','Subpanel','FontSize',12,...
              'Position',[.4 .1 .5 .5]);
c = uicontrol('Parent',sp,'String','Push here',...
              'Position',[18 18 72 36]);

The Scrollable property enables scrolling within a panel that has components outside its borders. Scrolling is only possible when the panel is in a figure created with the uifigure function. App Designer uses this type of figure for creating apps.

Create a panel within a figure. Add six UI components to the panel, with the first three lying outside the upper border of the panel.

fig = uifigure;
p = uipanel(fig,'Position',[20 20 196 135]);
ef1 = uieditfield(p,'Text','Position',[11 165 140 22],'Value','First Name');
ef2 = uieditfield(p,'Text','Position',[11 140 140 22],'Value','Last Name');
ef3 = uieditfield(p,'Text','Position',[11 115 140 22],'Value','Address');
dd = uidropdown(p,'Position',[11 90 140 22],'Items',{'Male','Female'});
cb = uicheckbox(p,'Position',[11 65 140 22],'Text','Member');
btn = uibutton(p,'Position',[11 40 140 22],'Text','Send');

Enable scrolling by setting the Scrollable property of the panel to 'on'. By default, the scroll box displays at the top.

p.Scrollable = 'on';

Input Arguments

collapse all

Parent container, specified as a figure created with either the figure or uifigure function, or a child container:

  • Panels, tabs, and button groups can be containers in either type of figure.

  • Grid layouts can be containers only in figures created with the uifigure function.

Name-Value Pair Arguments

Example: 'Title','Options' specifies that the panel title is Options.

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments as Name1,Value1,...,NameN,ValueN.

  • For a list of properties available for apps created with the uifigure function or in App Designer, see Panel Properties.

  • For a list of properties available for apps created with the figure function, see Panel Properties.


If you set the Visible property of a panel object to 'off', then any child objects it contains (buttons, button groups, axes, etc.) become invisible along with the parent panel. However, the Visible property value of each child object remains unaffected.

See Also


Introduced before R2006a