# @dopt/react-theme

> A library for creating themes to style Dopt's React components

Latest version **1.2.4** (published 2024-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @dopt/react-theme
pnpm add @dopt/react-theme
yarn add @dopt/react-theme
bun add @dopt/react-theme
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.4 |
| Published | 2024-04-18 |
| First published | 2023-06-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | kseth, alexchantastic, pankaj-avhad-dopt, chasebish, joemckenney |

## Links

- npm: https://www.npmjs.com/package/@dopt/react-theme
- Repository: https://github.com/dopt/odopt
- Homepage: https://github.com/dopt/odopt/tree/main/components/%40dopt/react/theme
- Issues: https://github.com/dopt/odopt/issues
- npm.io page: https://npm.io/package/@dopt/react-theme

## Dependencies (2)

- [@dopt/core-theme](https://npm.io/package/@dopt/core-theme.md) 2.3.1
- [@vanilla-extract/dynamic](https://npm.io/package/@vanilla-extract/dynamic.md) 2.0.3

## Recent versions

- 1.2.4 (latest) — 2024-04-18
- 1.2.3 — 2024-02-26
- 1.2.2 — 2024-02-22
- 1.2.1 — 2023-09-13
- 1.2.0 — 2023-08-28
- 1.1.0 — 2023-08-25
- 1.0.2 — 2023-08-02
- 1.0.1 — 2023-07-31
- 1.0.0 — 2023-07-25
- 0.0.2 — 2023-07-07
- 0.0.1 — 2023-06-29

## README

# @dopt/react-theme

Dopt's React components leverage a unified theme which consists of tokens for things like colors, typography, and spacing. You can override or extend these tokens as you go about styling the components. Leveraging a theme can be useful for quickly styling multiple components at the same time so they all feel cohesive.

All of Dopt's React components have a `theme` prop that you can use to pass in your custom theme definition.

[Learn more about Dopt's styling and theming →](https://docs.dopt.com/components/react/styling/).

## Installation

```bash
# npm
npm install @dopt/react-theme

# Yarn
yarn add @dopt/react-theme

# pnpm
pnpm add @dopt/react-theme
```

## Usage

```jsx
import { createTheme } from '@dopt/react-theme';
import Modal from '@dopt/react-modal';

const customTheme = createTheme({
  colors: {
    primary: '#b4d455',
  },
  fonts: {
    sans: 'Inter, sans-serif',
  },
});

function MyModal() {
  return <Modal.Root theme={customTheme}>...</Modal.Root>;
}
```

## Theme interface

When defining a custom theme, you will need adhere to a strict interface that maps to specific [theme tokens](https://docs.dopt.com/components/react/tokens/) as defined in [@dopt/core-theme](https://www.npmjs.com/package/@dopt/core-theme).

```ts
interface Theme {
  colors?: {
    black?: string;
    white?: string;
    primary?: string;
    primaryLight?: string;
    primaryDark?: string;
    secondary?: string;
    secondaryLight?: string;
    secondaryDark?: string;
    content?: string;
    contentLight?: string;
    contentContrast?: string;
    border?: string;
    overlay?: string;
    background?: string;
  };
  space?: {
    1?: string;
    2?: string;
    3?: string;
    4?: string;
    5?: string;
    6?: string;
    7?: string;
    8?: string;
    9?: string;
    10?: string;
    12?: string;
    16?: string;
  };
  sizes?: {
    1?: string;
    2?: string;
    3?: string;
    4?: string;
    5?: string;
    6?: string;
    7?: string;
    8?: string;
    9?: string;
    10?: string;
    12?: string;
    16?: string;
  };
  radii?: {
    1?: string;
    2?: string;
    round?: string;
  };
  shadows?: {
    1?: string;
    2?: string;
  };
  fonts?: {
    sans?: string;
    mono?: string;
  };
  fontSizes?: {
    base?: string;
    xs?: string;
    sm?: string;
    md?: string;
    lg?: string;
  };
  fontWeights?: {
    normal?: string;
    medium?: string;
    bold?: string;
  };
  lineHeights?: {
    base?: string;
    sm?: string;
    md?: string;
    lg?: string;
  };
  borderWidths?: {
    1?: string;
    2?: string;
  };
  transitions?: {
    linear?: string;
    linearFast?: string;
    ease?: string;
    easeFast?: string;
  };
}
```

---
_Source: https://npm.io/package/@dopt/react-theme · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
