How to create a textarea component in MATLAB
Last Updated :
28 Mar, 2022
Matlab offers tools for developing GUI applications. It provides functions that can create TextFields, Labels, Buttons, and many more, along with properties to manipulate the components. In this article, we will learn to create a TextArea Component using Matlab.
Creating a textarea component
A Text Area component is a UI component that allows us to input multiple lines of text. To create a text area object, we use the Matlab function uitextarea(), which accepts two optional parameters, the parent window in which this component resides and its values.
uitextarea(parent, Name:Value);
The parent is a figure or window that will hold all the components of our GUI. The Name-Value pair is the value that the text area will be initialized with.
Properties of textarea component
Properties of UI components are used to access and mutate their content as well as their appearances. Use dot notation to refer to a specific property.
A few of the important properties of the text area component are as follows:
- Value: We can use the Value property of a text area to access or set its content.
- Placeholder: The text that will be shown in the text area when it’s empty. Default is an empty string.
- Horizontal Alignment: Specifies the alignment of the text within the text area. possible options are left, right or centre. Default is ‘left’.
- WordWrap: Wraps the content to match the container’s width. Default is ‘on’.
- FontName: Used to set the font name for the content of the text area.
- FontSize: Used to set the font size of the text.
- FontWeight: this property is used to set the boldness level of the text in the text area.
- FontAngle: Use to change the angle of the font.
- FontColor: Used to change the font colour.
- BackgroundColor: This property helps to set the background colour of the text.
- Enable: Using this property a text area can be disabled or enabled for use.
- Position: accepts a list of 4 values, the first 2 are locations and the last two are the size of the text area.
- Visible: Visibility of the text area is controlled by this property. Default is ‘on’.
There are three syntaxes of uitextarea:
- textareaObject = uitextarea;
- textareaObject = uitextarea(parent);
- textareaObject = uitextarea(parent, Name, Value);
Now we see the first syntax without any parameters. It creates the text area component and the Matlab creates a figure window to hold the component.
Example 1:
Matlab
textareaObject = uitextarea;
|
Output:

uitextarea also accepts an optional parent container or window. If you have defined a window and want to add a text area to it, then textareaObject = uitextarea(parent) used.
Example 2:
Matlab
fig = uifigure;
textareaObject = uitextarea(fig);
|
Output:

We also have the option to set the properties while instantiating a text area.
Example 3:
Matlab
fig = uifigure;
txa = uitextarea(fig, 'Value' , { 'Mango' ; 'Apple' ; 'Litchi' });
txa.Position = [100,100,150,150];
|
Output:

Using uifigure, we created a figure window which will be our parent window. It will hold other components. The uitextarea() is used to create a text area component, and we pass the parent window as its parameter and a key-value pair to set its property Value, which determines the text area’s content. The Position property accepts a 4 value list, the first 2 values are the component’s position in the parent window, and the last two are the size of the components (width and height).
Example 4:
Matlab
fig = uifigure;
textareaObject = uitextarea(fig);
textareaObject.Position = [100 100 80 80];
textareaObject.Value = 'Apple Mango Banana Litchi guava Pineapple Watermelon Orange grapes Pomegranate' ;
|
Output before scroll:

Now, we can use the scroll function with the component and the location where to scroll like ‘bottom’. as parameter.
Syntax:
scroll(textareaObject, ‘bottom’);
Output after scroll:

Similar Reads
How to Create an Image Component in MATLAB?
MATLAB is an extensive tool that provides various options to its users. Creating image components is one of those tools. MATLAB provides simple functions to create image components. The uiimage function creates a new image component in a new figure by calling on the uifigure function. Usage of uiima
2 min read
How to Create a Hyperlink Component in MATLAB?
MATLAB is a matrix-based computational environment that has its own programming language which is very easy to use and learn. It is used for heavy mathematical concepts, understanding huge data sets with the help of the GUI Graphical User Interface of MATLAB. Â In GUIs, hyperlinked text labels are f
4 min read
Create a Slider Component in MATLAB
A slider component is a graphical interface that allows the end users to select discrete values in the range of the slider component. MATLAB provides built-in functionalities to create slider components in a MATLAB figure component. This article will explain how to create a slider component in MATLA
3 min read
How To Add an EditField Component in MATLAB?
An EditField component in MATLAB is a user interface control that allows you to input and edit text. It is a useful tool for creating user-friendly GUI (Graphical User Interface) applications. In this article, we will explain how to add an EditField component to a GUI and show some examples of its u
4 min read
How to Style Textarea-Element in Grid Column?
The <textarea> element in HTML is used for multi-line text input, and it can be styled effectively within a grid column layout using CSS. To style it, you can control its appearance through properties like padding, border, and background color, and use grid layout properties to ensure proper a
3 min read
How to Append Data to a File in MATLAB?
Appending data to a text file means adding data to a file that already exists in the storage. print() function is used to write/append data to a file in MATLAB. It writes formatted text to a file based on the format string provided to it. The format of the output/input is determined by the formattin
4 min read
How to create a dropdown menu in MATLAB
In this article, we will learn about the dropDown menu component, how to create it and what are its important properties. Then we will create a simple Matlab Gui application. Creating a dropdown menu in MATLABA Dropdown menu is a UI component that helps users to select one of the given options or ty
4 min read
Onsen UI CSS Component Basic Textarea
Onsen UI CSS is used to create beautiful HTML components. It is one of the most efficient ways to create HTML5 hybrid components that are compatible with both mobile and desktop. Onsen UI CSS Component Basic Textarea is used to create the basic textarea with a given number of rows. To create the bas
2 min read
How to create a multiline input control text area in HTML5 ?
The HTML <textarea> tag is used to specify a multiline input control text area in HTML5. Â The <cols> and <rows> attributes specify size of a textarea. Syntax <textarea rows="" cols=""> Contents... </textarea> The <textarea> tag contains 5 attributes that are liste
1 min read
Onsen UI Textarea CSS Components
Onsen UI CSS is used to create beautiful HTML components. It is one of the most efficient ways to create HTML5 hybrid components that are compatible with both mobile and desktop. In this article, we will learn about how to include a textarea using Onsen UI. Textarea is a small area where users can w
2 min read