diff --git a/docs/docs/gatsby-link.md b/docs/docs/gatsby-link.md
index 769db48cc629d..0bdb5a8c89d37 100644
--- a/docs/docs/gatsby-link.md
+++ b/docs/docs/gatsby-link.md
@@ -80,28 +80,27 @@ const SiteNavigation = () => (
### Show active styles for partially matched and parent links
-
-
-Video hosted on [egghead.io][egghead].
-
-The `activeStyle` or `activeClassName` prop are only set on a `` component if the current URL matches its `to` prop _exactly_. Sometimes, we may want to style a `` as active even if it partially matches the current URL. For example:
+By default the `activeStyle` and `activeClassName` props will only be set on a `` component if the current URL matches its `to` prop _exactly_. Sometimes, we may want to style a `` as active even if it partially matches the current URL. For example:
- We may want `/blog/hello-world` to match ``
- Or `/gatsby-link/#passing-state-through-link-and-navigate` to match ``
-In instances like these, we can use [@reach/router's](https://reach.tech/router/api/Link) `getProps` API to set active styles as follows:
+In instances like these, just add the `partiallyActive` prop to your `` component and the style will also be applied even if the `to` prop only is a partial match:
```jsx
import React from "react"
import { Link } from "gatsby"
-const partiallyActive = className => ({ isPartiallyCurrent }) => ({
- className: className + (isPartiallyCurrent ? ` active` : ``),
-})
-
-const PartiallyActiveLink = ({ className, ...rest }) => (
-
-)
+const Header = <>
+
+ Articles
+
+>;
```
### Pass state as props to the linked page
diff --git a/packages/gatsby-link/index.d.ts b/packages/gatsby-link/index.d.ts
index 43a51922da898..321a4af7f503c 100644
--- a/packages/gatsby-link/index.d.ts
+++ b/packages/gatsby-link/index.d.ts
@@ -6,6 +6,8 @@ export interface GatsbyLinkProps extends LinkProps {
activeStyle?: object
innerRef?: Function
onClick?: (event: React.MouseEvent) => void
+ partiallyActive?: boolean
+ replace?: boolean
to: string
}
diff --git a/packages/gatsby-link/package.json b/packages/gatsby-link/package.json
index 006abb10ae1db..1534770147538 100644
--- a/packages/gatsby-link/package.json
+++ b/packages/gatsby-link/package.json
@@ -8,7 +8,6 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0",
- "@reach/router": "^1.1.1",
"@types/reach__router": "^1.0.0",
"prop-types": "^15.6.1"
},
@@ -26,6 +25,7 @@
"license": "MIT",
"main": "index.js",
"peerDependencies": {
+ "@reach/router": "^1.1.1",
"gatsby": "^2.0.0",
"react": "^16.4.2",
"react-dom": "^16.4.2"
diff --git a/packages/gatsby-link/src/__tests__/__snapshots__/index.js.snap b/packages/gatsby-link/src/__tests__/__snapshots__/index.js.snap
index 1ca29b31090d6..8ac8c603da7da 100644
--- a/packages/gatsby-link/src/__tests__/__snapshots__/index.js.snap
+++ b/packages/gatsby-link/src/__tests__/__snapshots__/index.js.snap
@@ -24,3 +24,15 @@ exports[` matches basic snapshot 1`] = `
`;
+
+exports[` matches partially active snapshot 1`] = `
+