How to create functionality using Polaris CDN

I am using Polaris for my shopify app development, but with HTML code (provided in polaris documentation) and

the problem is that there is no functionality on those elements. so do i have to use javascript or jquery for making them dynamic content?? if yes then how tot embedd that ??

Hi Rahul_V,

Yes, for adding dynamic behavior to your HTML elements, you will need to use JavaScript (or a library). Here’s how you can do it:

  1. Add a <script> tag at the end of your HTML file, right before the closing </body> tag.
<script src="your-js-file.js"></script>

  1. In your JavaScript file, you can add event listeners to your HTML elements to make them interactive. Here’s an example:
document.getElementById('your-button-id').onclick = function() {
    // Code to execute when button is clicked
}

  1. If you’re using a library like jQuery, make sure to include the jQuery library in your HTML file, then you can use jQuery syntax to add behavior:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Then in your JavaScript file:

$(document).ready(function(){
    $("#your-button-id").click(function(){
        // Code to execute when button is clicked
    });
});

Also, when using the Shopify Polaris library alongside React, you can use React’s built-in event handling and state management to create dynamic behavior. If you’re not using React, then you’ll need to use JavaScript to add that behavior.

Hope this helps!

can i use to React as UI component along with PHP as backend component ??