diff --git a/.changeset/hot-mirrors-feel.md b/.changeset/hot-mirrors-feel.md
new file mode 100644
index 00000000000..aa57993ff14
--- /dev/null
+++ b/.changeset/hot-mirrors-feel.md
@@ -0,0 +1,5 @@
+---
+'@primer/react': major
+---
+
+Update UnderlineNav component to no longer support sx and remove Box usage from it.
diff --git a/packages/react/src/UnderlineNav/UnderlineNav.docs.json b/packages/react/src/UnderlineNav/UnderlineNav.docs.json
index 65b5a0da13f..622a5c7dd59 100644
--- a/packages/react/src/UnderlineNav/UnderlineNav.docs.json
+++ b/packages/react/src/UnderlineNav/UnderlineNav.docs.json
@@ -55,11 +55,6 @@
"type": "'inset' | 'flush'",
"defaultValue": "'inset'",
"description": "`inset` children are offset horizontally from container edges. `flush` children are flush horizontally with container edges"
- },
- {
- "name": "sx",
- "type": "SystemStyleObject",
- "deprecated": true
}
],
"subcomponents": [
@@ -100,11 +95,6 @@
"name": "as",
"type": "React.ElementType",
"defaultValue": "\"a\""
- },
- {
- "name": "sx",
- "type": "SystemStyleObject",
- "deprecated": true
}
],
"passthrough": {
@@ -113,4 +103,4 @@
}
}
]
-}
+}
\ No newline at end of file
diff --git a/packages/react/src/UnderlineNav/UnderlineNav.module.css b/packages/react/src/UnderlineNav/UnderlineNav.module.css
new file mode 100644
index 00000000000..b016174571a
--- /dev/null
+++ b/packages/react/src/UnderlineNav/UnderlineNav.module.css
@@ -0,0 +1,5 @@
+.MenuItemContent {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
diff --git a/packages/react/src/UnderlineNav/UnderlineNav.tsx b/packages/react/src/UnderlineNav/UnderlineNav.tsx
index c0f44fe244c..989395eca2c 100644
--- a/packages/react/src/UnderlineNav/UnderlineNav.tsx
+++ b/packages/react/src/UnderlineNav/UnderlineNav.tsx
@@ -1,8 +1,5 @@
import type {MutableRefObject, RefObject} from 'react'
import React, {useRef, forwardRef, useCallback, useState, useEffect} from 'react'
-import Box from '../Box'
-import type {SxProp} from '../sx'
-import sx from '../sx'
import {UnderlineNavContext} from './UnderlineNavContext'
import type {ResizeObserverEntry} from '../hooks/useResizeObserver'
import {useResizeObserver} from '../hooks/useResizeObserver'
@@ -18,16 +15,15 @@ import {useOnEscapePress} from '../hooks/useOnEscapePress'
import {useOnOutsideClick} from '../hooks/useOnOutsideClick'
import {useId} from '../hooks/useId'
import {ActionList} from '../ActionList'
-import {defaultSxProp} from '../utils/defaultSxProp'
import CounterLabel from '../CounterLabel'
import {invariant} from '../utils/invariant'
+import classes from './UnderlineNav.module.css'
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.
*/
@@ -45,11 +41,6 @@ export const MORE_BTN_WIDTH = 86
// The height is needed to make sure we don't have a layout shift when the more button is the only item in the nav.
const MORE_BTN_HEIGHT = 45
-// Needed this because passing a ref using HTMLULListElement to `Box` causes a type error
-export const NavigationList = styled.ul`
- ${sx};
-`
-
export const MoreMenuListItem = styled.li`
display: flex;
align-items: center;
@@ -145,7 +136,6 @@ export const UnderlineNav = forwardRef(
{
as = 'nav',
'aria-label': ariaLabel,
- sx: sxProp = defaultSxProp,
loadingCounters = false,
variant = 'inset',
className,
@@ -316,19 +306,12 @@ export const UnderlineNav = forwardRef(
}}
>
{ariaLabel && {`${ariaLabel} navigation`}}
-
+
{listItems}
{menuItems.length > 0 && (
- {!onlyMenuVisible && }
+ {!onlyMenuVisible && }
-
+
{menuItemChildren}
{loadingCounters ? (
) : (
counter !== undefined && (
-
+
{counter}
-
+
)
)}
-
+
)
})}
diff --git a/packages/react/src/UnderlineNav/UnderlineNavItem.module.css b/packages/react/src/UnderlineNav/UnderlineNavItem.module.css
new file mode 100644
index 00000000000..c1e75b06204
--- /dev/null
+++ b/packages/react/src/UnderlineNav/UnderlineNavItem.module.css
@@ -0,0 +1,5 @@
+.UnderlineNavItem {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
diff --git a/packages/react/src/UnderlineNav/UnderlineNavItem.tsx b/packages/react/src/UnderlineNav/UnderlineNavItem.tsx
index f63c38c270b..963f7c033f1 100644
--- a/packages/react/src/UnderlineNav/UnderlineNavItem.tsx
+++ b/packages/react/src/UnderlineNav/UnderlineNavItem.tsx
@@ -1,13 +1,11 @@
import type {MutableRefObject, RefObject} from 'react'
import React, {forwardRef, useRef, useContext} from 'react'
-import Box from '../Box'
-import type {SxProp} from '../sx'
import type {IconProps} from '@primer/octicons-react'
import type {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import {UnderlineNavContext} from './UnderlineNavContext'
import useLayoutEffect from '../utils/useIsomorphicLayoutEffect'
-import {defaultSxProp} from '../utils/defaultSxProp'
import {UnderlineItem} from '../internal/components/UnderlineTabbedInterface'
+import classes from './UnderlineNavItem.module.css'
// adopted from React.AnchorHTMLAttributes
export type LinkProps = {
@@ -47,22 +45,11 @@ export type UnderlineNavItemProps = {
* Counter
*/
counter?: number | string
-} & SxProp &
- LinkProps
+} & LinkProps
export const UnderlineNavItem = forwardRef(
(
- {
- sx: sxProp = defaultSxProp,
- as: Component = 'a',
- href = '#',
- children,
- counter,
- onSelect,
- 'aria-current': ariaCurrent,
- icon: Icon,
- ...props
- },
+ {as: Component = 'a', href = '#', children, counter, onSelect, 'aria-current': ariaCurrent, icon: Icon, ...props},
forwardedRef,
) => {
const backupRef = useRef(null)
@@ -111,7 +98,7 @@ export const UnderlineNavItem = forwardRef(
)
return (
-
+
{children}
-
+
)
},
) as PolymorphicForwardRefComponent<'a', UnderlineNavItemProps>
diff --git a/packages/react/src/UnderlineNav/styles.ts b/packages/react/src/UnderlineNav/styles.ts
index 227a66e20fa..2295c558562 100644
--- a/packages/react/src/UnderlineNav/styles.ts
+++ b/packages/react/src/UnderlineNav/styles.ts
@@ -7,7 +7,7 @@ export const getDividerStyle = (theme?: Theme) => ({
borderLeft: '1px solid',
width: '1px',
borderLeftColor: `${theme?.colors.border.muted}`,
- marginRight: 1,
+ marginRight: '4px',
height: '24px', // The height of the divider - reference from Figma
})
diff --git a/packages/styled-react/src/index.tsx b/packages/styled-react/src/index.tsx
index d68fb6d6ec4..23411aec0c1 100644
--- a/packages/styled-react/src/index.tsx
+++ b/packages/styled-react/src/index.tsx
@@ -18,8 +18,12 @@ import {
SegmentedControl as PrimerSegmentedControl,
type SegmentedControlButtonProps as PrimerSegmentedControlButtonProps,
type SegmentedControlIconButtonProps as PrimerSegmentedControlIconButtonProps,
+ UnderlineNav as PrimerUnderlineNav,
+ type UnderlineNavProps as PrimerUnderlineNavProps,
+ type UnderlineNavItemProps as PrimerUnderlineNavItemProps,
+ sx,
} from '@primer/react'
-import React, {forwardRef, type PropsWithChildren} from 'react'
+import React, {type PropsWithChildren, forwardRef} from 'react'
import type {
BackgroundProps,
BorderProps,
@@ -32,6 +36,8 @@ import type {
SpaceProps,
TypographyProps,
} from 'styled-system'
+import styled from 'styled-components'
+import type {ForwardRefComponent} from './polymorphic'
import {LinkButton, type LinkButtonProps} from './components/LinkButton'
type StyledProps = SxProp &
@@ -107,7 +113,37 @@ const ToggleSwitch = forwardRef(function T
return
})
-export {LinkButton, type LinkButtonProps, Checkbox, CounterLabel, SegmentedControl, StateLabel, SubNav, ToggleSwitch}
+type UnderlineNavProps = PrimerUnderlineNavProps & SxProp
+
+const UnderlineNavImpl = forwardRef(function UnderlineNav(props, ref) {
+ return
+})
+
+type UnderlineNavItemProps = PrimerUnderlineNavItemProps & SxProp
+
+const UnderlineNavItem: ForwardRefComponent<'a', UnderlineNavItemProps> = styled(
+ PrimerUnderlineNav.Item,
+).withConfig({
+ shouldForwardProp: prop => prop !== 'sx',
+})`
+ ${sx}
+`
+
+const UnderlineNav = Object.assign(UnderlineNavImpl, {
+ Item: UnderlineNavItem,
+})
+
+export {
+ LinkButton,
+ type LinkButtonProps,
+ Checkbox,
+ CounterLabel,
+ SegmentedControl,
+ StateLabel,
+ SubNav,
+ ToggleSwitch,
+ UnderlineNav,
+}
export {
ActionList,
@@ -145,7 +181,6 @@ export {
type TokenProps,
Tooltip,
Truncate,
- UnderlineNav,
// styled-components components or types
Box,