Skip to content

Commit

Permalink
Fix Tailwind font-family reset when using Starlight plugin (#1906)
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis authored May 21, 2024
1 parent f3b5007 commit b079ae1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-plums-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/starlight-tailwind': patch
---

Fixes default `font-family` in non-Starlight pages when using Tailwind plugin
12 changes: 12 additions & 0 deletions packages/tailwind/__tests__/tailwind.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ describe('@tailwind base;', async () => {
::before, ::after {
--tw-content: ;
}
html, :host {
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
code, kbd, samp, pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
:root {
--sl-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
Expand Down Expand Up @@ -105,6 +111,12 @@ describe('@tailwind base;', async () => {
::before, ::after {
--tw-content: ;
}
html, :host {
font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
code, kbd, samp, pre {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
:root {
--sl-font: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
--sl-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
Expand Down
3 changes: 3 additions & 0 deletions packages/tailwind/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const StarlightTailwindPlugin = () =>
borderColor: theme('borderColor.DEFAULT', 'currentColor'),
},
'::before, ::after': { '--tw-content': '' },
// Keep base font-family styles even in non-Starlight pages.
'html, :host': { 'font-family': theme('fontFamily.sans') },
'code, kbd, samp, pre': { 'font-family': theme('fontFamily.mono') },

// Wire up Starlight theme to use Tailwind config.
':root': {
Expand Down

0 comments on commit b079ae1

Please sign in to comment.