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]);

App with two panels and a button. The main panel contains a gray subpanel nested inside it. The button sits inside the subpanel.

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');

An app that contains a panel with many UI components. Two edit fields and half of the third are not visible.

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

p.Scrollable = 'on';

An app that contains a scrollable panel. The panel has a scroll bar on its right. The bar is scrolled to the top, and all three edit fields are visible in the panel.

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 Arguments

Example: uipanel('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.


The properties listed here are a subset of the available properties. For the full list, see Panel Properties.

Title, specified as a character vector, string scalar, or categorical array. If you specify this property as a categorical array, MATLAB displays only the first element in the array.

MATLAB does not interpret a vertical slash ('|') character as a line break, it displays as a vertical slash in the title.

If you want to specify a Unicode® character, pass the Unicode decimal code to the char function. For example, ['Multiples of ' char(960)] displays as Multiples of π.

Background color, specified as an RGB triplet, a hexadecimal color code, or one of the color options listed in the table.

RGB triplets and hexadecimal color codes are useful for specifying custom colors.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Thus, the color codes '#FF8800', '#ff8800', '#F80', and '#f80' are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
'red''r'[1 0 0]'#FF0000'

Sample of the color red

'green''g'[0 1 0]'#00FF00'

Sample of the color green

'blue''b'[0 0 1]'#0000FF'

Sample of the color blue

'cyan' 'c'[0 1 1]'#00FFFF'

Sample of the color cyan

'magenta''m'[1 0 1]'#FF00FF'

Sample of the color magenta

'yellow''y'[1 1 0]'#FFFF00'

Sample of the color yellow

'black''k'[0 0 0]'#000000'

Sample of the color black

'white''w'[1 1 1]'#FFFFFF'

Sample of the color white

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]'#0072BD'

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]'#D95319'

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]'#EDB120'

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]'#7E2F8E'

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]'#77AC30'

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]'#4DBEEE'

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]'#A2142F'

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Location and size of the panel, including borders and title, specified as a four-element vector of the form [left bottom width height]. This table describes each element in the vector.

leftDistance from the inner left edge of the parent container to the outer left edge of the panel
bottomDistance from the inner bottom edge of the parent container to the outer bottom edge of the panel
widthDistance between the right and left outer edges of the panel
heightDistance between the top and bottom outer edges of the panel

All measurements are in units specified by the Units property.

The Position values are relative to the drawable area of the parent container. The drawable area is the area inside the borders of the container and does not include the area occupied by decorations such as a menu bar or title.

Units of measurement, specified as one of the values in this table.

Units ValueDescription
'pixels' (default)

Distances in pixels are independent of your system resolution on Windows® and Macintosh systems:

  • On Windows systems, a pixel is 1/96th of an inch.

  • On Macintosh systems, a pixel is 1/72nd of an inch.

On Linux® systems, the size of a pixel is determined by your system resolution.


These units are normalized with respect to the parent container. The lower-left corner of the container maps to (0,0) and the upper-right corner maps to (1,1).

'points'Points. One point equals 1/72nd of an inch.

The recommended value is 'pixels', because most MATLAB app building functionality measures distances in pixels. You can create a panel that rescales based on the size of the parent container by parenting the panel to a grid layout manager created using the uigridlayout function. For more information, see Lay Out Apps Programmatically.

figure-Based Apps

For panels in apps created using the figure function, the default value of Units is 'normalized'.

In addition, you can specify Units as 'characters'. Character units are based on the default uicontrol font of the graphics root object:

  • Character width = width of the letter x.

  • Character height = distance between the baselines of two lines of text.

To access the default uicontrol font, use get(groot,'defaultuicontrolFontName') or set(groot,'defaultuicontrolFontName').


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