All threads / How do I set the active tab on the tailwindcss-stimulus-components

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I set the active tab on the tailwindcss-stimulus-components

Edmundo Ramirez-Semprit asked in Gems / Libraries

Hi Chris,
I am using the tailwindcss-stimulus-components on a project. The tabs work great, but I can't find how to set the active tab. The problem is that I have different links to forms in each tab and I want to return to the sending tab once the form is processed. Currently it always returns to the first tab . This is something I could do with Foundation. I am sure that there must be a way to di this.

Best regards,

Edmundo

Hey Edmundo,

Oh yeah, great point. I believe you just set data-controller="tabs" data-tabs-index="1" to have it select the 2nd tab, but that would have to be rendered in the HTML.

We may want to add some other method of doing this too. Possibly looking at the anchor in the url and selecting the target with the matching ID.

Perfect, that is just what I needed.

Thanks

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,344+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.