Skip to content

Commit 7ca16c9

Browse files
documentation improvement
1 parent a1e23aa commit 7ca16c9

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

docs/content/drafts/UnderlineNav2.mdx

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,23 @@ render(<Navigation />)
153153
### With React Router
154154

155155
```jsx
156-
import {Link} from 'react-router-dom'
156+
import {Link, useNavigate} from 'react-router-dom'
157157
import {UnderlineNav} from '@primer/react/drafts'
158158

159159
const Navigation = () => {
160+
const navigate = useNavigate()
160161
return (
161162
<UnderlineNav aria-label="Repository">
162163
<UnderlineNav.Item as={Link} to="code" counter={4} selected>
163164
Code
164165
</UnderlineNav.Item>
165-
<UnderlineNav.Item counter={44} as={Link} to="issues">
166+
<UnderlineNav.Item
167+
counter={44}
168+
as={Link}
169+
onSelect={() => {
170+
navigate('issues')
171+
}}
172+
>
166173
Issues
167174
</UnderlineNav.Item>
168175
<UnderlineNav.Item as={Link} to="pulls">
@@ -173,15 +180,24 @@ const Navigation = () => {
173180
}
174181
```
175182

183+
<Note>
184+
You can bind the routing with both 'to' and 'onSelect' prop here. However; please note that if an 'href' prop is
185+
passed, it will be ignored here.
186+
</Note>
187+
176188
## Props
177189

178190
### UnderlineNav
179191

180192
<PropsTable>
193+
<PropsTableRow name="children" required type="UnderlineNav.Item[]" />
181194
<PropsTableRow
182195
name="aria-label"
183196
type="string"
184-
description="A unique name for the rendered 'nav' landmark. It will also be used to label the arrow buttons that control the scroll behaviour on coarse pointer devices. (I.e. 'Scroll ${aria-label} left/right')"
197+
description="A unique name for the rendered 'nav' landmark. It will also be used to label the arrow
198+
buttons that control the scroll behaviour on coarse pointer devices. (I.e.
199+
'Scroll ${aria-label} left/right')
200+
"
185201
/>
186202
<PropsTableRow
187203
name="loadingCounters"
@@ -200,18 +216,23 @@ const Navigation = () => {
200216
### UnderlineNav.Item
201217

202218
<PropsTable>
219+
<PropsTableRow
220+
name="href"
221+
type="string"
222+
description="The URL that the item navigates to. 'href' is passed to the underlying '<a>' element. If 'as' is specified, the component may need different props and 'href' is ignored. (Required prop for the react router is 'to' for example)"
223+
/>
203224
<PropsTableRow name="icon" type="Component" description="The leading icon comes before item label" />
204225
<PropsTableRow name="selected" type="boolean" description="Whether the link is selected" />
205226
<PropsTableRow
206227
name="onSelect"
207228
type="(event) => void"
208-
description="The handler that gets called when a nav link is selected"
229+
description="The handler that gets called when a nav link is selected. For example, a manual route binding can be done here(I.e. 'navigate(href)' for the react router.)"
209230
/>
210231
<PropsTableRow
211232
name="as"
212-
type="string | Component"
233+
type="string | React.ElementType"
213234
defaultValue="a"
214-
description="What kind of component needs to be rendered"
235+
description="The underlying element to render — either a HTML element name or a React component."
215236
/>
216237
<PropsTableSxRow />
217238
</PropsTable>

0 commit comments

Comments
 (0)