# Lava: Getting started

> Install Lava and fill a box with a lava lamp: in React, or in any element, alone or behind content.

Source: https://cesarvenzac.com/lava/docs/getting-started

```sh
npm install @cesarvenzac/lava
```

Plain TypeScript, published as ES modules with their types, and no dependencies. React is an optional peer, for the React entry alone. It draws with WebGL 2 and a float target to render into, which every current browser has; where there's none, the box shows the liquid lit from below.

## A first lamp

`lava` lays a lamp in an element. The element is the lamp: give it a size, and the wax fills it.

```typescript
import { lava } from "@cesarvenzac/lava";

const lamp = lava(document.querySelector(".lamp")!, {
  palette: "magenta",
});
```

It comes in five palettes, or colours of your own: [Colours and light](https://cesarvenzac.com/lava/docs/colours-and-light). How it moves, and how it behaves on a page: [Motion and the page](https://cesarvenzac.com/lava/docs/motion-and-the-page).

## In React

`Lava` is a `<div>` with a lamp in it. Its other props go on the `<div>`:

```tsx
import { Lava } from "@cesarvenzac/lava/react";

<Lava palette="magenta" className="h-[30rem]" />;
```

A server draws the liquid lit from below, as a CSS background, and the wax fades in over it once the browser has drawn it: nothing moves as the page hydrates. It's a client component, React 18 or later.

## Behind content

A lamp on its own is a picture, named by `label` for assistive tech. With content inside, it's that content's background, drawn under it, and says nothing itself:

```tsx
<Lava palette="ember" className="grid h-[36rem] place-items-center">
  <h1 className="text-white">Slow down</h1>
</Lava>
```

`lava()` does the same with an element that has children: its canvas lies under them, in a stacking context of the element's own.

## Lava's docs

- [Overview](https://cesarvenzac.com/lava.md): A lava lamp for any box: thick 3D wax glowing in a dark liquid, shot through a long lens.
- [Getting started](https://cesarvenzac.com/lava/docs/getting-started.md): Install Lava and fill a box with a lava lamp: in React, or in any element, alone or behind content.
- [Colours and light](https://cesarvenzac.com/lava/docs/colours-and-light.md): The five palettes, colours of your own, and the light and lens a lamp is drawn with.
- [Motion and the page](https://cesarvenzac.com/lava/docs/motion-and-the-page.md): How the wax moves, any moment drawn on its own, and how a lamp behaves on a page.
- [API reference](https://cesarvenzac.com/lava/docs/api.md): Every function, option and type Lava exports.
