How to Add Prev/Next Buttons to Tab Component
This is a Webflow Tabs Component with Navigation (Prev/Next) buttons:
Method
Step 1:
Add a new div tab-wrapper, give it a position of relative and display of inline-block, and drag your tabs component inside it.
Step 2:
Add two buttons or two block links with class tab-prev and tab-next, give both a position of absolute, and position them anywhere inside the wrapper. I gave both a top of 50% to vertically align middle. You can style them however you want.
Step 3:
Go to the current page settings on the left toolbar. Under the Custom Code section in "Before </body> tag", paste this JavaScript code. You can also paste this code in an embed component.
<script>
// On page ready
var Webflow = Webflow || [];
Webflow.push(function() {
// For any tab-prev and tab-next clicks
$('.tab-wrapper').on('click', '.tab-prev, .tab-next', function() {
// Get direction
var direction = $(this).hasClass('tab-prev') ? -1 : 1;
// Get the tab links
var tablinks = $(this).parent().find('.w-tab-menu');
// Get index of current tab link, add direction
var index = tablinks.find('.w--current').index() + direction;
// If array out of bounds, click on the first
index = index >= tablinks.children().length ? 0 : index;
// Update tabs by triggering a "tap" event on the corresponding slide button
tablinks.find('.w-tab-link').eq(index).trigger('click');
}); // End click handler
}); // End ready function
</script>
Step 4:
Publish your site and preview it in the sub-domain (this doesn't work in the editor's Toggle Preview).
Notes:
- The above code works for multiple sets of tabs on the same page, as long as there is a wrapper div, and buttons/links named the same as above.
- Discuss or ask any questions on the forum at http://forum.webflow.com/t/25060.
- You can clone this project "Webflow Tricks" from my profile at https://webflow.com/samliew, to see how it is done.