{"id":1649,"date":"2021-03-29T12:38:58","date_gmt":"2021-03-29T12:38:58","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/change-dropdown-to-radio-buttons-in-magento-2\/"},"modified":"2025-05-22T10:46:29","modified_gmt":"2025-05-22T05:16:29","slug":"change-dropdown-to-radio-buttons-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/change-dropdown-to-radio-buttons-in-magento-2\/","title":{"rendered":"How to Change Dropdown to Radio Buttons in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 CMS offers a dropdown menu to allow the frontend users to select a choice from multiple options. It can be the name of city, country, or an option for a configurable product.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Though dropdowns are convenient for selection, a store owner may want to&nbsp;<em><strong>change dropdown to radio buttons in Magento 2<\/strong><\/em>&nbsp;to make it look neat and clean.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Dropdowns may not be suitable for your theme or layout. Radio buttons may enhance the design of the page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All these are the reasons, a merchant may want to change the attribute dropdown to radio buttons in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Though Magento 2 does not offer radio buttons by default, here\u2019s the programmatic solution using which you can implement it in your store:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Change Dropdown to Radio Buttons in Magento 2:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/\/Using id or class get Exising Select Options   \n\n$('form#product select').each(function(i, select){\n    var $select = $(select);\n    $select.find('option').each(function(j, option){\n        var $option = $(option);\n        var $radio = $('&lt;input type=\"radio\" \/>');                                \/\/ Create a radio:\n        $radio.attr('name', $select.attr('name')).attr('value', $option.val());  \/\/ Set name and value to radio \n        if ($option.attr('selected')) $radio.attr('checked', 'checked');         \/\/ Set checked if the select's option was selected\n        $select.before($radio);\n        $select.before(\n          $(\"&lt;label \/>\").attr('for', $select.attr('name')).text($option.text())\n        );\n        $select.before(\"&lt;br\/>\");\n    });\n    $select.remove();\n});\n\n\/\/ In Magento 2 if you want to change configurable product's dropdown options into radio buttons then you can also use this code. In that case, you have to take the class \"super-attribute-select\" instead of \"form#product select\".<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do make sure to share the post with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 CMS offers a dropdown menu to allow the frontend users to select a choice from multiple options. It can be the name of&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1649","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1649","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1649"}],"version-history":[{"count":2,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1649\/revisions"}],"predecessor-version":[{"id":14413,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1649\/revisions\/14413"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1649"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1649"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1649"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}