Clarify rules of define:vars (#1937)
This is an attempt to make it clear that the provided arg to `define:vars` must be an object, and that the values must be serializable.
This commit is contained in:
parent
69d518dd8c
commit
8d7abfcbc5
1 changed files with 4 additions and 3 deletions
|
@ -42,14 +42,15 @@ _These aliases are integrated automatically into [VSCode](https://code.visualstu
|
|||
|
||||
## Variables in Scripts & Styles
|
||||
|
||||
In Astro v0.21, server-side variables can be passed into client-side `<style>` or `<script>`.
|
||||
In Astro v0.21, _serializable_ server-side variables can be passed into client-side `<style>` or `<script>`.
|
||||
|
||||
```astro
|
||||
---
|
||||
// tick.astro
|
||||
const colors = { foregroundColor: "rgb(221 243 228)", backgroundColor: "rgb(24 121 78)" }
|
||||
const foregroundColor = "rgb(221 243 228)";
|
||||
const backgroundColor = "rgb(24 121 78)";
|
||||
---
|
||||
<style define:vars={colors}>
|
||||
<style define:vars={{foregroundColor, backgroundColor}}>
|
||||
h-tick {
|
||||
background-color: var(--backgroundColor);
|
||||
border-radius: 50%;
|
||||
|
|
Loading…
Reference in a new issue