Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e43a435

Browse files
elliotcourantdimaMachina
andauthoredDec 15, 2024··
[v4] feat(theme): Content width css variable for easier customization (#3767)
* feat(theme): Content width css variable for easier customization This moves the content width that was used throughout nextra `max-w-[90rem]` to a css variable. This way the changing the value in the future should be easier, but it also makes it possible to customize the max width of the content for people using nextra without needing to overload a tailwind class in a hacky way. * chore: Adding changeset * chore: Tweak docs css to use variable * Update packages/nextra-theme-docs/src/components/footer/index.tsx Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> * Update packages/nextra-theme-docs/src/components/footer/index.tsx Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> * Update packages/nextra-theme-docs/src/components/navbar/index.tsx Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> * Update packages/nextra-theme-docs/src/mdx-components/index.tsx Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> * Update .changeset/afraid-foxes-deny.md Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com> --------- Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
1 parent 96fb083 commit e43a435

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed
 

‎.changeset/afraid-foxes-deny.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'nextra-theme-docs': minor
3+
---
4+
5+
content width could be configured via CSS `--nextra-content-width` variable

‎docs/app/page.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.content-container {
2-
max-width: 90rem;
2+
max-width: var(--nextra-content-width);
33
padding-left: max(env(safe-area-inset-left), 1.5rem);
44
padding-right: max(env(safe-area-inset-right), 1.5rem);
55
margin: 0 auto;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ export const Footer: FC<ComponentProps<'footer'>> = ({
1212
return (
1313
<div className="x:bg-gray-100 x:pb-[env(safe-area-inset-bottom)] x:dark:bg-neutral-900 x:print:bg-transparent">
1414
<Switchers>
15-
<div className="x:mx-auto x:flex x:max-w-[90rem] x:gap-2 x:py-2 x:px-4">
15+
<div className="x:mx-auto x:flex x:max-w-(--nextra-content-width) x:gap-2 x:py-2 x:px-4">
1616
<LocaleSwitch />
1717
<ThemeSwitch />
1818
</div>
1919
</Switchers>
2020
<hr className="nextra-border" />
2121
<footer
2222
className={cn(
23-
'x:mx-auto x:flex x:max-w-[90rem] x:justify-center x:py-12 x:text-gray-600 x:dark:text-gray-400 x:md:justify-start',
23+
'x:mx-auto x:flex x:max-w-(--nextra-content-width) x:justify-center x:py-12 x:text-gray-600 x:dark:text-gray-400 x:md:justify-start',
2424
'x:pl-[max(env(safe-area-inset-left),1.5rem)] x:pr-[max(env(safe-area-inset-right),1.5rem)]',
2525
className
2626
)}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const Navbar: FC<NavbarProps> = props => {
5252
/>
5353
<nav
5454
style={{ height: 'var(--nextra-navbar-height)' }}
55-
className="x:mx-auto x:flex x:max-w-[90rem] 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)]"
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)]"
5656
>
5757
{logoLink ? (
5858
<NextLink

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const DEFAULT_COMPONENTS = getNextraMDXComponents({
8989
value: removeLinks(item.value)
9090
}))
9191
return (
92-
<div className="x:mx-auto x:flex x:max-w-[90rem]">
92+
<div className="x:mx-auto x:flex x:max-w-(--nextra-content-width)">
9393
<Sidebar toc={toc} />
9494

9595
<ClientWrapper toc={toc} {...props}>

‎packages/nextra/src/client/components/head.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const Head_: FC<HeadProps> = ({ children, ...props }) => {
7272
--nextra-primary-saturation: ${color.saturation.light}%;
7373
--nextra-primary-lightness: ${color.lightness.light}%;
7474
--nextra-bg: ${backgroundColor.light};
75+
--nextra-content-width: 90rem;
7576
}
7677
.dark {
7778
--nextra-primary-hue: ${color.hue.dark}deg;

0 commit comments

Comments
 (0)
Please sign in to comment.