Skip to content

Add Algolia DocSearch to docs site#19

Open
kaci8 wants to merge 3 commits intomainfrom
algolia-docs-search
Open

Add Algolia DocSearch to docs site#19
kaci8 wants to merge 3 commits intomainfrom
algolia-docs-search

Conversation

@kaci8
Copy link
Copy Markdown
Contributor

@kaci8 kaci8 commented Apr 8, 2026

Summary

  • Configures Algolia DocSearch (appId, apiKey, indexName) in themeConfig
  • Shows search bar only on /docs pages via CSS class selectors, hidden on home, blog, and legacy-policies
  • Styles DocSearch button and modal to match site dark theme (colors, fonts, border-radius, border)
  • Positions search to the left of the Download button in the navbar
  • Hides Download button on mobile for docs pages to prevent overlap with search

Test plan

  • Search bar appears in navbar on /docs pages
  • Search bar is hidden on home page, blog, and /legacy-policies pages
  • Search modal opens and matches dark theme (no blue hues)
  • Search bar sits left of Download button on desktop
  • Download button hidden on mobile docs pages, still shows on home page
  • Search results return relevant docs content

🤖 Generated with Claude Code

@kaci8 kaci8 requested a review from cmbartschat April 8, 2026 17:40
/* DocSearch modal theme */
html[data-theme='dark'], html {
--docsearch-primary-color: var(--color-primary);
--docsearch-highlight-color: var(--color-primary) !important;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!important being required on any of these variable assignments would be somewhat surprising.

}

.DocSearch-Modal {
border-radius: var(--radius-lg) !important;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The amount of !important being used here is questionable. Is this coming from docusaurus/algolia docs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DocSearch injects its own CSS dynamically via JavaScript after our custom.css loads, the only way to override them from a static stylesheet is !important. I could try swizzling the search component if you'd prefer that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only way to override them from a static stylesheet is !important

Not true unless the styles are assigned on the element itself (in which case yeah, swizzling is probably better). CSS precedence rules are the primary way to override styles. For example .docs-page .DocSearch-Modal is stronger than just .DocSearch-Modal, which is a weaker selector. Load order is only the tie breaker in the case of equivalent precedence.

Would be good to compare to another project using this component and seeing what their custom styles look like.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, Claude had me certain that wasn't the case. I've changed the approach in the latest commit

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you find another project to take inspiration from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No but I found the docs and referenced that https://www.mintlify.com/algolia/docsearch/concepts/styling

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like those are 3rd party AI generated docs, no?

- Configure Algolia DocSearch (appId, apiKey, indexName) in themeConfig
- Show search bar only on /docs pages using CSS class selectors
- Style DocSearch button and modal to match site dark theme
- Position search left of Download button in navbar
- Hide Download button on mobile for docs pages to prevent overlap

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kaci8 kaci8 force-pushed the algolia-docs-search branch from f90457c to 51f30d1 Compare April 8, 2026 18:34
kaci8 and others added 2 commits April 8, 2026 16:32
- Replace !important with higher-specificity selectors (body prefix, html[data-theme='dark']:root for variables)
- Fix modal inner elements clipping by restoring overflow: hidden on DocSearch-Modal
- Fix search bar visibility on non-docs pages using body .DocSearch-Button selector
- Add algolia-site-verification meta tag
- Simplify html[data-theme='dark'], html selector to just html

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Kaci Lambeth <97469517+kaci8@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants