screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.12/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Change tab active color</h3> <div class="tabs"> <button v-for="tab in tabs" :key="tab" :class="[activeTab === tab ? 'active-tab' : '', 'tab-button']" @click="activeTab = tab">{{ tab }}</button> </div> </div> <script type="module"> const app = Vue.createApp({ data() { return { activeTab: 'tab1', // Assuming 'tab1' is the initially active tab tabs: ['tab1', 'tab2', 'tab3'], // Array of tab names }; }, }); app.mount('#app'); </script> <style> #app { text-align: center; margin-top: 20px; } h3 { font-size: 18px; margin-bottom: 10px; } .tabs { display: flex; justify-content: center; margin-top: 20px; } .tab-button { padding: 8px 16px; background-color: transparent; border: none; border-bottom: 2px solid #f2f2f2; margin-right: 10px; cursor: pointer; font-size: 16px; color: #555; } .tab-button.active-tab { background-color: #f1f1f1; border-bottom: 2px solid #007bff; color: #007bff; } .tab-button:focus { outline: none; } </style> </body> </html>