Implement CSS classnames for nextra-theme-docs #4815
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why:
The size of Nextra DOM on big projects gets huge, as many pages generate a huge Navigation DOM due to the incline css of Tailwind. One Nav item looks like this:
So if your page has 500 articles this would be included in the DOM 500 times.
With custom CSS classes one Navigation item could look something like this:
Which would reduce the DOM size quite a bit.
This PR focusses on the transition from inline css utility classes to custom CSS classes. It started with just Nextra-Theme-Docs in order to keep the review process simple, however, I would like to transition also the nextra core and the blog theme, as soon as this PR gets approved.
I kept the utility classes in the CSS file and did not move to native CSS for easier review, and to keep it a non-breaking change. However, if preferred, I could also migrate the utility classes to native CSS. Also please feel free to rename the CSS class names I chose.
Closes:
What's being changed (if available, include any code snippets, screenshots, or gifs):
Most of the inline CSS utility classes moved to CSS file.
Check off the following:
deployment link in this PR's timeline (this link will be available after
opening the PR).