Skip to content

Commit 31534cb

Browse files
authoredFeb 12, 2025
add Navbar.className prop (#4203)
1 parent 18a6f80 commit 31534cb

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed
 

‎.changeset/kind-cameras-join.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextra-theme-docs": patch
3+
---
4+
5+
add `Navbar.className` prop

‎docs/app/docs/docs-theme/built-ins/navbar/page.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { ToggleVisibilitySection } from 'components/toggle-visibility-section'
1515
| `chatLink` | `string{:ts}` | | URL of the chat link. |
1616
| `chatIcon` | `ReactNode{:ts}` | `<DiscordIcon width="24" />{:ts}` | Icon of the chat link. |
1717
| `children` | `ReactNode{:ts}` | | Extra content after last icon. |
18+
| `className` | `string{:ts}` | | CSS class name. |
1819

1920
## Logo
2021

‎packages/nextra-theme-docs/src/components/navbar/index.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const propsSchema = z.strictObject({
1616
projectLink: z.string().optional(),
1717
projectIcon: element.default(<GitHubIcon height="24" />),
1818
chatLink: z.string().optional(),
19-
chatIcon: element.default(<DiscordIcon width="24" />)
19+
chatIcon: element.default(<DiscordIcon width="24" />),
20+
className: z.string().optional()
2021
})
2122

2223
type NavbarProps = z.input<typeof propsSchema>
@@ -33,7 +34,8 @@ export const Navbar: FC<NavbarProps> = props => {
3334
projectLink,
3435
projectIcon,
3536
chatLink,
36-
chatIcon
37+
chatIcon,
38+
className
3739
} = data
3840
return (
3941
<header
@@ -52,7 +54,10 @@ export const Navbar: FC<NavbarProps> = props => {
5254
/>
5355
<nav
5456
style={{ height: 'var(--nextra-navbar-height)' }}
55-
className="x:mx-auto x:flex x:max-w-(--nextra-content-width) x:items-center x:justify-end x:gap-4 x:pl-[max(env(safe-area-inset-left),1.5rem)] x:pr-[max(env(safe-area-inset-right),1.5rem)]"
57+
className={cn(
58+
'x:mx-auto x:flex x:max-w-(--nextra-content-width) x:items-center x:justify-end x:gap-4 x:pl-[max(env(safe-area-inset-left),1.5rem)] x:pr-[max(env(safe-area-inset-right),1.5rem)]',
59+
className
60+
)}
5661
>
5762
{logoLink ? (
5863
<NextLink

0 commit comments

Comments
 (0)
Please sign in to comment.