Create HTML UI component
h = uihtml
creates an HTML UI component in a new figure and returns
the HTML
UI component object. MATLAB® calls the uifigure
function to create the
figure.
With the uihtml
function, you can embed HTML, JavaScript®, or CSS content in your app and interface with third-party libraries to
display content like widgets or data visualizations. All supporting files (including HTML,
JavaScript, CSS, images) must be saved in a location that your local file system can
access.
h = uihtml(
creates an HTML UI
component in the specified parent container. The parent can be a parent
)Figure
object created with the uifigure
function, or one of its child
containers.
h = uihtml(___,
specifies HTML UI component properties using one or more name-value pair arguments. For
example, Name,Value
)'HTMLSource','timepicker.html'
sets the HTML source to the
specified HTML file.
You cannot link to URL web resources or embed applications from external web pages
using the uihtml
function.
HTML files that you specify for the HTMLSource
property cannot
access third-party JavaScript libraries by way of a Content Delivery Network (CDN). Save libraries in a
location that your local file system can access.
Common web file types, like JavaScript and CSS, can be referenced from the HTML file you specify for the
HTMLSource
property, but other web file types might not be
supported.
Content cannot overflow the bounds of the HTML UI component. If you are creating dynamic content, like pop-up widgets, make the size of your HTML UI component large enough to display the widget when the pop-up is in its opened state.
On MATLAB desktop, certain HTML features such as web plugins and access to webcams or microphones are not supported.
You cannot set the HTMLSource
property to an HTML file that has
query parameters appended to its file name. As a workaround, set these parameters in
htmlComponent.Data
.
Hyperlinks with matlab:
operations are not supported.
If you are creating an HTML file to embed in your app, first verify that the static HTML renders properly in a browser. For more information, see Create HTML File That Can Trigger or Respond to Data Changes.
If you want to refresh the value of the HTMLSource
property, use
this workaround to save the original value of HTMLSource
to a
variable, reset HTMLSource
it to an empty value and update the figure
to clear its contents, and finally set HTMLSource
back to its
original
value.
oldValue = h.HTMLSource;
h.HTMLSource = '';
drawnow()
h.HTMLSource = oldValue;
MATLAB figures created with the uifigure
function use the
Chromium browser and run HTML5. New Chromium versions are released frequently and can vary
between operating systems. Consult external Chromium resources for supported features and
functionality. Take this factor into consideration if you plan to share your app or use it
in different environments.
Check external resources, like https://caniuse.com/, for the types of features that are supported across different desktop and web browsers.
MathWorks® does not promote any third-party libraries.