Skip to content

Commit 576e67b

Browse files
authored
feat(b-link): support exact-path and exact-path-active-class props for router link (fixes #6434) (#6811)
1 parent 49d8a9d commit 576e67b

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

docs/common-props.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
"exactActiveClass": {
7575
"description": "<router-link> prop: Configure the active CSS class applied when the link is active with exact match. Typically you will want to set this to class name 'active'"
7676
},
77+
"exactPath": {
78+
"description": "<router-link> prop: Allows matching only using the path section of the url, effectively ignoring the query and the hash sections"
79+
},
80+
"exactPathActiveClass": {
81+
"description": "<router-link> prop: Configure the active CSS class applied when the link is active with exact path match. Typically you will want to set this to class name 'active'"
82+
},
7783
"fade": {
7884
"description": "When set to `true`, enables the fade animation/transition on the component"
7985
},

docs/markdown/reference/router-links/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,34 @@ With components that support router links (have a `to` prop), you will want to s
149149
`'active'` (or a space separated string that includes `'active'`) to apply Bootstrap's active
150150
styling on the component when the current route matches the `to` prop.
151151

152+
### `exact-path`
153+
154+
- type: `boolean`
155+
- default: `false`
156+
- availability: Vue Router 3.5.0+
157+
158+
Allows matching only using the `path` section of the url, effectively ignoring the `query` and the
159+
`hash` sections.
160+
161+
```html
162+
<!-- this link will also be active at `/search?page=2` or `/search#filters` -->
163+
<router-link to="/search" exact-path> </router-link>
164+
```
165+
166+
### `exact-path-active-class`
167+
168+
- type: `string`
169+
- default: `'router-link-exact-path-active'`
170+
- availability: Vue Router 3.5.0+
171+
172+
Configure the active CSS class applied when the link is active with exact path match. Note the
173+
default value can also be configured globally via the `linkExactPathActiveClass` router constructor
174+
option.
175+
176+
With components that support router links (have a `to` prop), you will want to set this to the class
177+
`'active'` (or a space separated string that includes `'active'`) to apply Bootstrap's active
178+
styling on the component when the current route matches the `to` prop.
179+
152180
## Nuxt.js specific router link props
153181

154182
When BootstrapVue detects that your app is running under [Nuxt.js](https://nuxtjs.org), it will

src/components/link/link.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export const routerLinkProps = {
3232
event: makeProp(PROP_TYPE_ARRAY_STRING),
3333
exact: makeProp(PROP_TYPE_BOOLEAN, false),
3434
exactActiveClass: makeProp(PROP_TYPE_STRING),
35+
exactPath: makeProp(PROP_TYPE_BOOLEAN, false),
36+
exactPathActiveClass: makeProp(PROP_TYPE_STRING),
3537
replace: makeProp(PROP_TYPE_BOOLEAN, false),
3638
routerTag: makeProp(PROP_TYPE_STRING),
3739
to: makeProp(PROP_TYPE_OBJECT_STRING)

0 commit comments

Comments
 (0)