Skip to content

Commit cd1e718

Browse files
authored
Merge branch 'main' into main
2 parents f042486 + 7d8246b commit cd1e718

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

docs/src/content/docs/guides/css-and-tailwind.mdx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Any styles in the `my-overrides` layer would take precedence over Starlight’s
6868

6969
## Tailwind CSS
7070

71-
Tailwind CSS support in Astro projects is provided by the [Tailwind Vite plugin](https://tailwindcss.com/docs/installation/using-vite).
71+
Tailwind CSS v4 support in Astro projects is provided by the [Tailwind Vite plugin](https://tailwindcss.com/docs/installation/using-vite).
7272
Starlight provides complementary CSS to help configure Tailwind for compatibility with Starlight’s styles.
7373

7474
The Starlight Tailwind CSS applies the following configuration:
@@ -182,6 +182,9 @@ If you already have a Starlight site and want to add Tailwind CSS, follow these
182182
@import 'tailwindcss/utilities.css' layer(utilities);
183183
```
184184

185+
This Tailwind theme config defines Starlight's [cascade layers](#cascade-layers) order, imports Starlight’s Tailwind complementary CSS, and imports Tailwind’s theme and utility styles.
186+
If your project requires additional Tailwind configuration, check out the [“Use multiple Tailwind configurations”](#use-multiple-tailwind-configurations) section.
187+
185188
4. Update the Starlight config to add the Tailwind CSS file as the first item in the `customCss` array:
186189

187190
```js ins={11-12}
@@ -208,7 +211,7 @@ If you already have a Starlight site and want to add Tailwind CSS, follow these
208211

209212
### Styling Starlight with Tailwind
210213

211-
Starlight will use values from your [Tailwind theme config](https://tailwindcss.com/docs/theme) in its UI.
214+
When [creating a new Starlight project with Tailwind](#create-a-new-project-with-tailwind), or when [adding Tailwind to an existing Starlight project](#add-tailwind-to-an-existing-project), Starlight will use values from your [Tailwind theme config](https://tailwindcss.com/docs/theme) located in the `src/styles/global.css` file to style its UI.
212215

213216
If set, the following CSS custom properties will override Starlight’s default styles:
214217

@@ -257,6 +260,34 @@ If set, the following CSS custom properties will override Starlight’s default
257260
}
258261
```
259262

263+
### Use multiple Tailwind configurations
264+
265+
Multiple Tailwind configurations can be used to apply different styles to different parts of your site, e.g. when [using Starlight at a subpath](/manual-setup/#use-starlight-at-a-subpath) or when adding [custom pages](/guides/pages/#custom-pages) to your site.
266+
For example, you may want to use Tailwind’s Preflight reset styles in your custom pages, while still applying Starlight’s compatibility layer to Starlight pages.
267+
268+
The following Tailwind CSS configuration sets up Tailwind without any plugins or extra configuration and can be used as a starting point for non-Starlight pages:
269+
270+
```css title="src/styles/custom-pages-tailwind.css"
271+
/* Load Tailwind without any of Starlight's complementary CSS. */
272+
@import 'tailwindcss';
273+
```
274+
275+
<Steps>
276+
277+
1. For Starlight pages, apply your preferred Tailwind CSS configuration by following [“Add Tailwind to an existing project”](#add-tailwind-to-an-existing-project).
278+
279+
2. For other pages, apply your preferred Tailwind CSS configuration by importing it in those pages. This is often done in a layout component so that Tailwind styles can be used on all pages sharing that layout.
280+
```astro
281+
---
282+
// src/layouts/CustomPageLayout.astro
283+
import '../styles/custom-pages-tailwind.css';
284+
---
285+
```
286+
287+
</Steps>
288+
289+
To learn more about Tailwind theme configurations, check out the [Tailwind CSS documentation](https://tailwindcss.com/docs/theme).
290+
260291
## Theming
261292

262293
Starlight’s color theme can be controlled by overriding its default custom properties.

0 commit comments

Comments
 (0)