How can I achieve on Magento 2 Frontend show a toggle button which will show/hide a custom option text area for user to fill in?

enter image description here

1 Answer 1


You can edit the PHTML file where you want to add these toggle option.

then add the tag script to add some jQuery functionality.

], function ($) {
     //Your code to show/hide the form users want to fill

To customize the style of the toggle button you can use CSS or add some bootstrap styles.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.