Content nested in dark theme.
```
In Panda, themes are designed as semantic tokens. You can define the semantic tokens in the `semanticTokens` key of the
`panda.config` function.
```ts
import { defineConfig } from '@pandacss/dev'
export default defineConfig({
theme: {
semanticTokens: {
colors: {
gray100: {
value: { base: 'hsl(206,22%,99%)', _dark: 'hsl(206,8%,12%)' }
},
gray200: {
value: { base: 'hsl(206,12%,97%)', _dark: 'hsl(206,7%,14%)' }
}
}
}
}
})
```
### Token Aliases
In Stitches, you can create locally scoped tokens using the `$$` prefix
```ts
import { styled } from '@stitches/react'
const Button = styled('button', {
$$shadowColor: '$colors$pink500',
boxShadow: '0 0 0 15px $$shadowColor'
})
```
In Panda, there's no special syntax, you need to use the css variable syntax. CSS variables are able to query the theme
tokens directly using dot notation
```ts
import { styled } from '../styled-system/jsx'
const Button = styled('button', {
base: {
'--shadowColor': 'colors.pink500',
boxShadow: '0 0 0 15px var(--shadowColor)'
}
})
```
## Animations
In Stitches, you can define keyframes using the `keyframes` method.
```ts
import { keyframes, styled } from '@stitches/react'
const scaleUp = keyframes({
'0%': { transform: 'scale(1)' },
'100%': { transform: 'scale(1.5)' }
})
// usage
const Button = styled('button', {
'&:hover': {
animation: `${scaleUp} 200ms`
}
})
```
In Panda, you define keyframes in the `theme.keyframes` key of the `panda.config` function.
```ts
import { defineConfig } from '@pandacss/dev'
export default defineConfig({
theme: {
extend: {
keyframes: {
scaleUp: {
'0%': { transform: 'scale(1)' },
'100%': { transform: 'scale(1.5)' }
}
}
}
}
})
// usage
import { css } from '../styled-system/css'
const style = css({
'&:hover': {
animation: 'scaleUp 200ms'
}
})
```
## Utils
In Stitches, you can define utilities by using the `utils` key in the `createStitches` method.
```ts
import { createStitches, type PropertyValue } from '@stitches/react'
const { styled, css } = createStitches({
utils: {
linearGradient: (value: PropertyValue<'backgroundImage'>) => ({
backgroundImage: `linear-gradient(${value})`
})
}
})
```
In Panda, you get a lot of built-in utilities (like mx, marginX, my, py, etc.) that you can use out of the box. You can
also create custom utilites using the `utilities` key in the `panda.config` function.
The utilities API allows you define the connected token scale, generated className, and transform function.
```ts
import { defineConfig } from '@pandacss/dev'
export default defineConfig({
utilities: {
extend: {
linearGradient: {
// (optional): the css property this maps to (to inherit the types from)
property: 'backgroundImage',
// (optional): the className to generate
className: 'bg_gradient',
// (optional): the shorthand name to use in the css
shorthand: 'gradient',
// (required): maps the value to the raw css object
transform: value => ({
backgroundImage: `linear-gradient(${value})`
})
}
}
}
})
```
> Running `panda codegen` will update the typings for the utilities, allowing for a type-safe developer experience.
Then you can use the utility in your styles.
```tsx
import { css } from '../styled-system/css'
const buttonClass = css({
linearGradient: '19deg, #21D4FD 0%, #B721FF 100%'
})
```
## Global Styles
In Stitches, you define the global styles using the `globalCss` function, and then call it in your app.
```tsx
import { globalCss } from '@stitches/react'
const globalStyles = globalCss({
'*': { margin: 0, padding: 0 }
})
// then in your app
globalStyles()
```
In Panda, you define the global styles in the `panda.config.ts` using the `globalCss` function.
> The styles be injected automatically under the `base` cascade layer via PostCSS
```ts {3-5}
import { defineConfig, defineGlobalStyles } from '@pandacss/dev'
const globalCss = defineGlobalStyles({
'*': { margin: 0, padding: 0 }
})
export default defineConfig({
// ...
globalCss
})
```
## Targeting Components
In Stitches, you can directly target React or styled components via the `toString()` method.
```tsx
import { css } from '@stitches/react'
const Icon = () => (