Skip to content
Discussion options

You must be logged in to vote

Hi @dragonsdenexotech

Here is the idiomatic way to handle this in Nuxt UI, along with a step-by-step guide on how you can contribute this to the documentation.


1. The Idiomatic Solution

Instead of hardcoding every child route in a manual equality check, use computed() with route.path.startsWith().

Because links / items is an array evaluated during component setup, it must be wrapped inside a computed() property so Vue's reactivity system recalculates the active status whenever the user navigates between routes:

<script setup lang="ts">
const route = useRoute()

const items = computed(() => [
  {
    label: 'Businesses',
    icon: 'i-lucide:flame',
    to: '/businesses/list',
    // Autom…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dragonsdenexotech
Comment options

Answer selected by dragonsdenexotech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants