-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add Astro integration page (#1283)
Co-authored-by: Remus Mate <3297808+mrm007@users.noreply.github.com> Co-authored-by: Mirko Basic bejzik8@gmail.com
- Loading branch information
1 parent
b7c182b
commit 39909db
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
title: Astro | ||
parent: integrations | ||
--- | ||
|
||
# Astro | ||
|
||
Integrating Vanilla Extract with [Astro](https://astro.build) is done with the help of the [Vite plugin][vite integration]. | ||
|
||
## Installation | ||
|
||
```bash | ||
npm install @vanilla-extract/css | ||
npm install @vanilla-extract/vite-plugin --save-dev | ||
``` | ||
|
||
## Setup | ||
|
||
Add Vanilla Extract Vite plugin to the Astro configuration: | ||
|
||
```js | ||
import { defineConfig } from 'astro/config'; | ||
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
vite: { | ||
plugins: [vanillaExtractPlugin()] | ||
} | ||
}); | ||
``` | ||
|
||
You'll then be able to use `style` and other APIs in `.css.ts` files. | ||
|
||
```ts | ||
// button.css.ts | ||
|
||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const button = style({ | ||
padding: '0.5rem 1rem', | ||
border: 'none', | ||
borderRadius: '0.25rem', | ||
color: 'white', | ||
background: '#333' | ||
}); | ||
``` | ||
|
||
And now you can reference styles in your Astro component: | ||
|
||
```tsx | ||
// Button.astro | ||
|
||
--- | ||
import { button } from './button.css' | ||
--- | ||
|
||
<button class={button}>Click Me!</button> | ||
``` | ||
|
||
## Configuration | ||
|
||
See the [Vite integration page][vite integration] for documentation on the Vite plugin. | ||
|
||
[vite integration]: /documentation/integrations/vite |