Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/yummy-files-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': minor
---

Adds className prop to UnderlineNav component.
8 changes: 7 additions & 1 deletion packages/react/src/UnderlineNav/UnderlineNav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ResponsiveUnderlineNav = ({

return (
<div>
<UnderlineNav aria-label="Repository" loadingCounters={loadingCounters}>
<UnderlineNav aria-label="Repository" className="foo" loadingCounters={loadingCounters}>
{items.map(item => (
<UnderlineNav.Item
key={item.navigation}
Expand Down Expand Up @@ -142,6 +142,12 @@ describe('UnderlineNav', () => {
expect(counter).toHaveAttribute('aria-hidden', 'true')
})

it('adds className prop to base wrapper classes', () => {
const {getByRole} = render(<ResponsiveUnderlineNav />)
const nav = getByRole('navigation')
expect(nav).toHaveAttribute('class', 'UnderlineWrapper foo')
})

it('renders the content of visually hidden span properly for screen readers', () => {
const {getByRole} = render(<ResponsiveUnderlineNav />)
const item = getByRole('link', {name: 'Issues (120)'})
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/UnderlineNav/UnderlineNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type UnderlineNavProps = {
children: React.ReactNode
'aria-label'?: React.AriaAttributes['aria-label']
as?: React.ElementType
className?: string
sx?: SxProp['sx']
/**
* loading state for all counters. It displays loading animation for individual counters (UnderlineNav.Item) until all are resolved. It is needed to prevent multiple layout shift.
Expand Down Expand Up @@ -140,6 +141,7 @@ export const UnderlineNav = forwardRef(
'aria-label': ariaLabel,
sx: sxProp = defaultSxProp,
loadingCounters = false,
className,
children,
}: UnderlineNavProps,
forwardedRef,
Expand Down Expand Up @@ -306,7 +308,7 @@ export const UnderlineNav = forwardRef(
}}
>
{ariaLabel && <VisuallyHidden as="h2">{`${ariaLabel} navigation`}</VisuallyHidden>}
<UnderlineWrapper as={as} aria-label={ariaLabel} ref={navRef} sx={sxProp}>
<UnderlineWrapper as={as} aria-label={ariaLabel} className={className} ref={navRef} sx={sxProp}>
<UnderlineItemList ref={listRef} role="list">
{listItems}
{menuItems.length > 0 && (
Expand Down
Loading