{"id":16252,"date":"2021-09-28T07:02:09","date_gmt":"2021-09-28T07:02:09","guid":{"rendered":"https:\/\/www.cmarix.com\/blog\/?p=16252"},"modified":"2026-04-14T09:50:56","modified_gmt":"2026-04-14T09:50:56","slug":"key-steps-to-create-a-simple-ui-component-in-magento-2","status":"publish","type":"post","link":"https:\/\/www.cmarix.com\/blog\/key-steps-to-create-a-simple-ui-component-in-magento-2\/","title":{"rendered":"Key Steps to Create A Simple UI Component in Magento 2"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<?xml encoding=\"utf-8\" ?><html><body><p>UI components are designed for simple and adaptable (UI) delivery. Components are responsible for delivering result page pieces and giving\/supporting further interactions of JavaScript components and servers. <a href=\"https:\/\/www.cmarix.com\/hire-magento-developer.html\">Hire a Magento developers<\/a> to integrate these UI components and use them in the custom module.<\/p>\n<p>Magento UI components are carried out as a standard module named Magento_UI.<\/p>\n<p>To utilize UI components in your custom module, Magento Development Services need to add a reliance for the Magento_UI module in your part&rsquo;s composer.json file.<\/p>\n<p>The accompanying <a href=\"https:\/\/www.lifewire.com\/xsd-file-2622606\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">XSD file<\/a> contains rules and limitations divided among all components (the two definitions and instance configurations):<\/p>\n<p>&lt;your module root dir&gt;\/Magento\/Ui\/and so forth\/ui_definition.xsd<\/p>\n<p>Augmentation engineers can&rsquo;t broaden this XSD conspire and present new components, however, they can customize existing ones.<\/p>\n<p><img class=\"aligncenter wp-image-16257 size-full\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/Best-Practices-for-Magento-2-Custom-Theme-Development.jpg\" alt=\"Best Practices for Magento 2 Custom Theme Development\" width=\"1500\" height=\"800\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/Best-Practices-for-Magento-2-Custom-Theme-Development.jpg 1500w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/Best-Practices-for-Magento-2-Custom-Theme-Development-400x213.jpg 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/Best-Practices-for-Magento-2-Custom-Theme-Development-1024x546.jpg 1024w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/Best-Practices-for-Magento-2-Custom-Theme-Development-768x410.jpg 768w\" sizes=\"auto, (max-width: 1500px) 100vw, 1500px\" \/><\/p>\n<h2>Standard Design<\/h2>\n<p>In Magento 2 there are essential and auxiliary UI components.<\/p>\n<p>Essential components are:<\/p>\n<ul>\n<li>Listing part<\/li>\n<li>Form part<\/li>\n<\/ul>\n<p>Essential components are proclaimed in the page format files; optional components are announced in the high-level components&rsquo; instances configuration files.<\/p>\n<p>All components can be designed both for Admin and customer-facing facade.<\/p>\n<h2>When to Utilize UI Components?<\/h2>\n<p>With Magento, you may apply various ways to deal with carrying out a UI element, and use:<\/p>\n<ul>\n<li>PHTML template with inline JavaScript<\/li>\n<li>PHTML template with the declaration of related JavaScript file by means of XML design<\/li>\n<li>jQuery gadget<\/li>\n<li>Magento 2 UI segment<\/li>\n<\/ul>\n<p>We suggest utilizing UI components however much as could reasonably be expected and will, in general, do likewise in the Magento center.<\/p>\n<p>UI components function admirably together: they speak with one another through the ui Registry service that tracks their nonconcurrent introduction. If you need to broaden something that has effectively been carried out as a chain of command of UI components or add another feature that ought to interact with other UI components, it&rsquo;s simpler and more effective to utilize a UI part.<\/p>\n<p><a href=\"https:\/\/www.cmarix.com\/inquiry.html\"><img width=\"951\" height=\"271\" class=\"size-full wp-image-16256 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/146-copy.png\" alt=\"CTA\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/146-copy.png 951w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/146-copy-400x114.png 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/146-copy-768x219.png 768w\" sizes=\"auto, (max-width: 951px) 100vw, 951px\" \/><\/a><\/p>\n<h2>What is a UI Component?<\/h2>\n<p><strong>UI segment is a blend of:<\/strong><\/p>\n<ol>\n<li>XML declaration that indicates the segment&rsquo;s configuration settings and inward construction.<\/li>\n<li>JavaScript class acquired from one of the Magento JavaScript structure UI components base classes (like UIElement, UIClass or UICollection).<\/li>\n<li>Related template(s)<\/li>\n<\/ol>\n<p><strong>Read more: <\/strong><a href=\"https:\/\/www.cmarix.com\/blog\/a-comprehensive-guide-to-magento-integration-with-3rd-party-applications\/\">A Comprehensive Guide To Magento Integration with 3rd Party Applications<\/a><\/p>\n<h2>XML Declaration<\/h2>\n<p>XML is broadly utilized in Magento 2, which permits engineers to effortlessly reuse existing functionalities and add customizations.<\/p>\n<p>Contrasted with XML designs, UI components utilize a more semantic way to deal with pronouncing and arranging the UI.<\/p>\n<p>An instance of a UI part is typically founded on the progression of kid UI components.<\/p>\n<p>The UI part is designed for Magento 2 programming to deliver a <a href=\"https:\/\/searchapparchitecture.techtarget.com\/definition\/user-interface-UI\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">User Interface<\/a> (UI) in a straightforward and adaptable way. In this article, I will train you to create a UI structure in Magento 2 by utilizing the UI segment. Accept that you need to create an employee structure as a UI structure in administrator, which has Employee Name,Id, Salary, and Employee Address field. The table name should be employee_details. Above all else, you need to create a Model and Resource Model for this employee_details table. Here I assume that you, as of now, can create a model and resource model for the table.<\/p>\n<p><strong>We should follow these steps underneath for effectively making a UI structure in Magento 2<\/strong><\/p>\n<h3>Step 1: Create Router for Controller<\/h3>\n<p><strong>In the primary step, you need to create a routes.xml file in CMARIX\/UiForm\/view\/adminhtml\/layout folder.<\/strong><\/p>\n<p><img width=\"993\" height=\"210\" class=\"size-full wp-image-16258 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/1-1.png\" alt=\"Code\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/1-1.png 993w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/1-1-400x85.png 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/1-1-768x162.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/p>\n<h3>Step 2: Create a Controller<\/h3>\n<p>You can create an Edit.php file in CMARIX\/UniForm\/Controller\/Adminhtml\/Employeefolder folder.<\/p>\n<p><img class=\"aligncenter wp-image-16259 size-full\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/2-1.png\" alt=\"Create a Controller\" width=\"884\" height=\"373\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/2-1.png 884w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/2-1-400x169.png 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/2-1-768x324.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/p>\n<h3>Step 3: Create Layout File<\/h3>\n<p><strong>In this step<\/strong>, you need to create a uiform_employee_edit.xml layout file in &lsquo;CMARIX\/UiForm\/view\/adminhtml\/layout&rsquo; folder.<\/p>\n<p><img class=\"size-full wp-image-16260 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/3-1-1.png\" alt=\"Code\" loading=\"lazy\" decoding=\"async\"><\/p>\n<h3>Step 4: Create employee_form.xml File<\/h3>\n<p>In CMARIX\/UiForm\/view\/adminhtml\/ui_component<\/p>\n<p>You need to create employee_form.xml file in CMARIX\/UiForm\/view\/adminhtml\/ui_component<\/p>\n<p><img class=\"aligncenter wp-image-16261 size-full\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4-1.png\" alt=\"Code\" width=\"1040\" height=\"616\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4-1.png 1040w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4-1-400x237.png 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4-1-1024x607.png 1024w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4-1-768x455.png 768w\" sizes=\"auto, (max-width: 1040px) 100vw, 1040px\" \/><\/p>\n<p><img class=\"size-full wp-image-16262 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4.2-1.png\" alt=\"Code\" loading=\"lazy\" decoding=\"async\"><\/p>\n<p><img class=\"size-full wp-image-16265 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/4.3-1.png\" alt=\"Code\" loading=\"lazy\" decoding=\"async\"><\/p>\n<h3>Step 5: Create DataProvider.php File In CMARIX\/UiForm\/Model Folder<\/h3>\n<p>Finally, you need to create a DataProvider.php file in CMARIX\/UiForm\/Model folder.<\/p>\n<p><img width=\"800\" height=\"629\" class=\"size-full wp-image-16266 aligncenter\" src=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/5-1.png\" alt=\"Code\" loading=\"lazy\" decoding=\"async\" srcset=\"https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/5-1.png 800w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/5-1-400x315.png 400w, https:\/\/www.cmarix.com\/blog\/wp-content\/uploads\/2021\/08\/5-1-768x604.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>After going through the five above steps, your UI form is ready.<\/p>\n<h2>List of UI Components<\/h2>\n<p>Here are components that can be used by <a href=\"https:\/\/www.cmarix.com\/magento-development.html\">Magento Development Company<\/a> to form components:<\/p>\n<ul>\n<li>ActionDelete<\/li>\n<li>Checkbox<\/li>\n<li>Checkbox Set<\/li>\n<li>DataSource<\/li>\n<li>FieldSet<\/li>\n<li>FileUploader<\/li>\n<li>Hidden<\/li>\n<li>Input<\/li>\n<li>Multiline<\/li>\n<li>Multiselect<\/li>\n<li>Radio set<\/li>\n<li>Select<\/li>\n<li>Text<\/li>\n<li>Textarea<\/li>\n<li>Wysiwyg<\/li>\n<\/ul>\n<\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>UI components are designed for simple and adaptable (UI) delivery. Components are [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":16255,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[24],"tags":[],"class_list":["post-16252","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento-development"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/posts\/16252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/comments?post=16252"}],"version-history":[{"count":11,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/posts\/16252\/revisions"}],"predecessor-version":[{"id":49392,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/posts\/16252\/revisions\/49392"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/media\/16255"}],"wp:attachment":[{"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/media?parent=16252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/categories?post=16252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmarix.com\/blog\/wp-json\/wp\/v2\/tags?post=16252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}