Tabbed interface with Stimulus

Hi there,

I made a small stimulus controller to show and hide tabs based on which tab the user clicks. It’s similar to the slideshow example on the Managing State page.

Here’s a link to the fiddle: https://jsfiddle.net/qwvurt0p/2/
…and the gist: https://gist.github.com/crispinheneise/3e6f731c053103cdbc7b6f702ba080f8

It works well, but I’m not super-happy with the dual loops for activating the tab and the pane. Does anyone have any ideas for improving it?

Also, you’re welcome to use it for inspiration or copy it in your project!

Here’s my attempt: https://jsfiddle.net/javan/w5mfn443/

5 Likes