TabComponent.vue 896 Bytes
Newer Older
abergavenny's avatar
abergavenny committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<script setup>
defineEmits(['onTabSelect'])
const props = defineProps(['active', 'tabs'])
</script>

<template>
  <div class="tabs">
    <div class="tab" :class="{ tab__active: tab.value === props.active }" v-for="tab in props.tabs" :key="tab.key"
      @click="$emit('onTabSelect', tab.value)">
      <span>{{ tab.name }}</span>
    </div>
  </div>
</template>

<style scoped>
.tabs {
  overflow-x: auto;
  padding: var(--spacing);
  display: flex;
  gap: var(--spacing-s);
}

@media (min-width: 48em) {
  .tabs {
    flex-direction: row;
  }
}

.tab {
  padding: 0 var(--spacing);
  display: flex;
  border-radius: var(--radius);
  cursor: pointer;
}

.tab__active {
  background-color: hsl(var(--clr-primary));
  display: flex;
  color: var(--clr-white);
}

.tab:hover:not(.tab__active) {
  background-color: hsl(var(--clr-background));
  transition: background-color ease-in 250ms;
}
</style>