Skip to content

Commit

Permalink
feat(Link): add active prop to override default behaviour (#732)
Browse files Browse the repository at this point in the history
Co-authored-by: Sébastien Chopin <seb@nuxt.com>
  • Loading branch information
benjamincanac and atinux authored Sep 25, 2023
1 parent 6887f73 commit 8257a11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime/components/elements/Link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default defineComponent({
type: Boolean,
default: null
},
active: {
type: Boolean,
default: false
},
exact: {
type: Boolean,
default: false
Expand All @@ -65,6 +69,10 @@ export default defineComponent({
},
setup (props) {
function resolveLinkClass (route, $route, { isActive, isExactActive }: { isActive: boolean, isExactActive: boolean }) {
if (props.active) {
return props.activeClass
}
if (props.exactQuery && !isEqual(route.query, $route.query)) {
return props.inactiveClass
}
Expand Down
1 change: 1 addition & 0 deletions src/runtime/types/link.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { NuxtLinkProps } from '#app'

export interface Link extends NuxtLinkProps {
active?: boolean
exact?: boolean
exactQuery?: boolean
exactMatch?: boolean
Expand Down

1 comment on commit 8257a11

@vercel
Copy link

@vercel vercel bot commented on 8257a11 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui.nuxt.com
ui-git-dev-nuxt-js.vercel.app
ui-nuxt-js.vercel.app

Please sign in to comment.