---
title: Background
description:
  Bamboo provides the following utilities or style properties for styling background colors, gradients, and images.
---

Use these utilities to style background colors, gradients, and images.

## Background Colors

```jsx
<div className={css({ bg: 'red.200' })} />
<div className={css({ bg: 'blue.200/30' })} /> // with alpha
```

| Prop                         | CSS Property       | Token Category |
| ---------------------------- | ------------------ | -------------- |
| `bg`, `background`           | `background`       | `colors`       |
| `bgColor`, `backgroundColor` | `background-color` | `colors`       |

## Background Gradients

Properties to create a background gradient based on color stops.

```jsx
<div
  className={css({
    bgGradient: 'to-r',
    gradientFrom: 'red.200',
    gradientTo: 'blue.200',
  })}
/>
```

Background and text gradients can be connected to design tokens. Here's how to define a gradient token in your theme.

```ts
const theme = {
  tokens: {
    gradients: {
      // string value
      simple: { value: 'linear-gradient(to right, red, blue)' },
      // composite value
      primary: {
        value: {
          type: 'linear',
          placement: 'to right',
          stops: ['red', 'blue'],
        },
      },
    },
  },
}
```

These tokens can be used in the `bgGradient` or `textGradient` properties.

```jsx
<div
  className={css({
    bgGradient: "simple",
  })}
/>

<div
  className={css({
    bgGradient: "primary",
  })}
/>
```

| Prop           | CSS Property       | Token Category |
| -------------- | ------------------ | -------------- |
| `bgGradient`   | `background-image` | `gradients`    |
| `textGradient` | `background-image` | `gradients`    |
| `gradientFrom` | `--gradient-from`  | `colors`       |
| `gradientTo`   | `--gradient-to`    | `colors`       |
| `gradientVia`  | `--gradient-via`   | `colors`       |

## Background Position

Properties for controlling the src and position of a background image.

```jsx
<div
  className={css({
    bgImage: 'url(/images/bg.jpg)',
    bgPosition: 'center',
  })}
/>
```

| Prop                                   | CSS Property                                 | Token Category |
| -------------------------------------- | -------------------------------------------- | -------------- |
| `bgPosition`, `backgroundPosition`     | `background-position`                        | none           |
| `bgPositionX`, `backgroundPositionX`   | `background-position-x`                      | none           |
| `bgPositionY`, `backgroundPositionY`   | `background-position-y`                      | none           |
| `bgAttachment` ,`backgroundAttachment` | `background-attachment`                      | none           |
| `bgClip`, `backgroundClip`             | `background-clip`, `-webkit-background-clip` | none           |
| `bgOrigin`, `backgroundOrigin`         | `background-origin`                          | none           |
| `bgImage`, `backgroundImage`           | `background-image`                           | assets         |
| `bgRepeat`, `backgroundRepeat`         | `background-repeat`                          | none           |
| `bgBlendMode`, `backgroundBlendMode`   | `background-blend-mode`                      | none           |
| `bgSize`, `backgroundSize`             | `background-size`                            | none           |
