Main Content


Create radio button component


rb = uiradiobutton creates a radio button within a button group and returns the RadioButton object. MATLAB® calls the uifigure function to create the parent figure of the button group.

rb = uiradiobutton(parent) creates the radio button within the specified button group. The button group must be the child of a Figure created with the uifigure function, or must be parented to a child container of the figure: Tab, Panel, ButtonGroup, or GridLayout.


rb = uiradiobutton(___,Name,Value) specifies RadioButton properties using one or more Name,Value pair arguments. Use this option with any of the input argument combinations in the previous syntaxes.


collapse all

Create a button group in a window.

fig = uifigure('Position',[680 678 398 271]);
bg = uibuttongroup(fig,'Position',[137 113 123 85]);   

Create three RadioButton objects, and specify the parent and location of each.

rb1 = uiradiobutton(bg,'Position',[10 60 91 15]);
rb2 = uiradiobutton(bg,'Position',[10 38 91 15]);
rb3 = uiradiobutton(bg,'Position',[10 16 91 15]);

Change the text associated with each radio button.

rb1.Text = 'English';
rb2.Text = 'French';
rb3.Text = 'German';

Change the radio button selection to German.

rb3.Value = true;

Determine the font name of the German radio button text.

font = rb3.FontName
font =


Input Arguments

collapse all

Parent container, specified as a ButtonGroup object. The ButtonGroup must be parented to a Figure created using the uifigure function, or to a child container of a uifigure, such as: Tab, Panel, ButtonGroup, or GridLayout.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Text', 'French' specifies that the text “French” displays next to the radio button.

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

State of radio button, specified as 1 (true) or 0 (false). Within a button group, only one button can be selected at a time. The state of the first radio button added to a button group is 1, by default. Subsequent buttons added to the same button group have a default state of 0.

When the Value property of a RadioButton changes to 1, the Value of the property for the previously selected RadioButton changes to 0. In addition, the SelectedObject property value of the parent ButtonGroup is updated.

If you programmatically change the Value property of a RadioButton to 0, MATLAB sets the Value property of the first RadioButton added to the ButtonGroup to 1. If the first RadioButton added is the one for which you programmatically set the Value property to 0, then MATLAB sets the Value property for the second RadioButton added to the ButtonGroup to 1.


The first RadioButton added to a ButtonGroup is not necessarily the first RadioButton listed in the Children property of the ButtonGroup.

Button label, specified as a character vector, cell array of character vectors, string scalar, string array, or 1-D categorical array. Specify a character vector or string scalar to label the button with a single line of text. Use a cell array or string array to label the button with multiple lines of text. Each element in the array represents a separate line of text. If you specify this property as a categorical array, MATLAB uses the values in the array, not the full set of categories.

Location and size of radio button, specified as a vector of the form [left bottom width height]. This table describes each element in the vector.

leftDistance from the inner left edge of the button group to the outer left edge of the radio button
bottomDistance from the inner bottom edge of the button group to the outer bottom edge of the radio button
widthDistance between the right and left outer edges of the radio button (including text)
heightDistance between the top and bottom outer edges of the radio button

The Position values are relative to the drawable area of the button group. The drawable area is the area inside the borders of the button group and does not include the area occupied by the title.

All measurements are in pixel units.


  • Button groups can contain any UI component type, but can only manage the selection of radio buttons and toggle buttons.

  • To make your program respond when the user selects a radio button or toggle button that is inside a button group, define a SelectionChangedFcn callback function for the ButtonGroup. You cannot define callbacks for the individual buttons.

  • To determine which radio button or toggle button is selected, query the SelectedObject property of the ButtonGroup. You can execute this query anywhere in your code.

  • If you set the Visible property of a button group object to 'off', then any child objects it contains become invisible along with the parent ButtonGroup. However, the Visible property value of each child object remains unaffected.

Version History

Introduced in R2016a