- Include the file
dist/js/stacks.min.jsin your page. For example, if you use the unpkg CDN, add the tag
<script src="https://unpkg.com/@stackoverflow/stacks/dist/js/stacks.min.js"></script>to your HTML. See Using Stacks for more information on Unpkg and installing Stacks via NPM.
Stimulus allows you to add functionality to your markup in a way that is similar to how you add styling to your markup: by modifying HTML attributes.
Just as you style components by adding classes to the
data-… attributes to the HTML.
s-…, just like component CSS classes. You give functionality to an HTML element by setting its
Refer to the documentation of individual components on how to configure a component’s behavior.
This helper is called
targets property, which will be available on the controller constructor itself, i.e. statically.
With that, you can create and register the final Hello World controller example from the official documentation like this: