diff --git a/docs/components/content/examples/TabsExampleChange.vue b/docs/components/content/examples/TabsExampleChange.vue new file mode 100644 index 00000000..751e7741 --- /dev/null +++ b/docs/components/content/examples/TabsExampleChange.vue @@ -0,0 +1,22 @@ + + + diff --git a/docs/components/content/examples/TabsExampleVModel.vue b/docs/components/content/examples/TabsExampleVModel.vue new file mode 100644 index 00000000..aa76745b --- /dev/null +++ b/docs/components/content/examples/TabsExampleVModel.vue @@ -0,0 +1,34 @@ + + + diff --git a/docs/content/5.navigation/4.tabs.md b/docs/content/5.navigation/4.tabs.md index 43110faa..5066c24c 100644 --- a/docs/content/5.navigation/4.tabs.md +++ b/docs/content/5.navigation/4.tabs.md @@ -83,6 +83,78 @@ const items = [...] ``` :: +::callout{icon="i-heroicons-exclamation-triangle"} + This will have no effect if you are using a `v-model` to control the selected index. +:: + +### Listen to changes :u-badge{label="Edge" class="ml-2 align-text-bottom !rounded-full" variant="subtle"} + +You can listen to changes by using the `@change` event. The event will emit the index of the selected item. + +::component-example +#default +:tabs-example-change{class="w-full"} + +#code +```vue + + + +``` +:: + +### Control the selected index :u-badge{label="Edge" class="ml-2 align-text-bottom !rounded-full" variant="subtle"} + +Use a `v-model` to control the selected index. + +::component-example +#default +:tabs-example-v-model{class="w-full"} + +#code +```vue + + + +``` +:: + +::callout{icon="i-heroicons-information-circle"} +In this example, we are binding tabs to the route query. Refresh the page to see the selected tab change. +:: + ## Slots You can use slots to customize the buttons and items content of the Accordion. diff --git a/src/runtime/components/navigation/Tabs.vue b/src/runtime/components/navigation/Tabs.vue index 1f3e1df0..b7f86110 100644 --- a/src/runtime/components/navigation/Tabs.vue +++ b/src/runtime/components/navigation/Tabs.vue @@ -1,6 +1,7 @@