# @dcl/react-ecs

> Decentraland ECS

Latest version **7.29.0** (published 2026-09-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dcl/react-ecs
pnpm add @dcl/react-ecs
yarn add @dcl/react-ecs
bun add @dcl/react-ecs
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.29.0 |
| Published | 2026-09-15 |
| First published | 2022-09-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 105.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 40 |
| Author | DCL |
| Maintainers | decentralandbot, imazzara |
| Keywords | @dcl/react-ecs, dcl, ecs, react |

## Links

- npm: https://www.npmjs.com/package/@dcl/react-ecs
- Repository: https://github.com/decentraland/js-sdk-toolchain
- Homepage: https://github.com/decentraland/js-sdk-toolchain#readme
- Issues: https://github.com/decentraland/js-sdk-toolchain/issues
- npm.io page: https://npm.io/package/@dcl/react-ecs

## Dependencies (3)

- [react](https://npm.io/package/react.md) ^18.2.0
- [@dcl/ecs](https://npm.io/package/@dcl/ecs.md) 7.29.0
- [react-reconciler](https://npm.io/package/react-reconciler.md) ^0.29.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 7.29.0 (latest) — 2026-09-15
- 7.29.1-36716815278.commit-ab46c81 (next) — 2026-09-30
- 7.29.1-36637355925.commit-d261ba1 (auth-server) — 2026-09-29
- 7.29.1-35901015152.commit-d1b7b96 (experimental-bevy) — 2026-09-23
- 7.27.1-34382248832.commit-ca3b679 (experimental) — 2026-09-09
- 7.25.1-30828532396.commit-0c215c3 (protocol-squad) — 2026-08-03
- 7.8.16 (ci) — 2025-07-07
- 7.29.1-36625469671.commit-2d5ffac — 2026-09-29
- 7.29.1-36624944101.commit-bb81ac6 — 2026-09-29
- 7.29.1-36591934525.commit-48aa9b5 — 2026-09-29
- 7.29.1-36041177279.commit-502e633 — 2026-09-24
- 7.29.1-35978346337.commit-823107b — 2026-09-24
- 7.29.1-35917671376.commit-046b268 — 2026-09-23
- 7.29.1-35862852104.commit-1f44e80 — 2026-09-23
- 7.29.1-35861881691.commit-e4e55e9 — 2026-09-23
- … 1255 more at https://npm.io/package/@dcl/react-ecs/versions

## README

# @dcl/react-ecs

React bindings for Decentraland's Entity Component System (ECS), providing a declarative way to build UIs in Decentraland scenes using React's component model and JSX syntax.

## Features

- **Flexbox-based Layout**: Implements a subset of CSS Flexbox for powerful and intuitive UI layouts
- **React Components**: Familiar React-like component API for building UIs
- **Type Safety**: Full TypeScript support with proper type definitions
- **Event Handling**: Support for mouse events and user interactions
- **Performance**: Optimized reconciliation for minimal runtime overhead
- **Theme Support**: Built-in light and dark theme system with context-based switching

## Component Guidelines

All components in @dcl/react-ecs must:

- Return JSX.Elements for consistency and composability
- Support theme integration through context
- Be reusable and composable with other components

## Installation

```bash
npm install @dcl/react-ecs
```

## Basic Usage

```tsx
import { ReactEcs, UiEntity, Label, Button } from '@dcl/react-ecs'

export function MyUI() {
  return (
    <UiEntity
      uiTransform={{
        width: 300,
        height: 100,
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center'
      }}
    >
      <Label value="Hello Decentraland!" />
      <Button value="Click Me!" onMouseDown={() => console.log('clicked!')} />
    </UiEntity>
  )
}
```

## Theme System

The package includes a theme system for consistent UI styling:

```tsx
import { ReactEcs, ThemeProvider, Button } from '@dcl/react-ecs'

// Wrap your UI with ThemeProvider
export function MyUI() {
  return (
    <ThemeProvider>
      <Button value="Theme-Aware Button" />
    </ThemeProvider>
  )
}

// Use themes in custom components
function CustomComponent() {
  const { theme, toggleTheme } = React.useContext(ThemeContext)

  return (
    <UiEntity
      uiBackground={{
        color: theme === 'light' ? '#FFFFFF' : '#000000'
      }}
      onMouseDown={toggleTheme}
    />
  )
}
```

## Components

### Core Components

- **UiEntity**: Base component for UI elements
- **Label**: Text display component
- **Button**: Interactive button component
- **Input**: Text input field
- **Dropdown**: Selection dropdown menu

### Layout System

The layout system is based on Flexbox and supports the following properties:

- `display: 'flex'`
- `flexDirection: 'row' | 'column'`
- `justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around'`
- `alignItems: 'flex-start' | 'center' | 'flex-end' | 'stretch'`
- `width`, `height`
- `margin`, `padding`
- `positionType: 'absolute' | 'relative'`

## Event Handling

Components support the following mouse events:

```tsx
<Button onMouseDown={() => {}} onMouseUp={() => {}} onMouseEnter={() => {}} onMouseLeave={() => {}} />
```

## Technical Details

The package implements a custom React reconciler that bridges React's component model with Decentraland's ECS. It:

1. Translates JSX into ECS entities and components
2. Manages component lifecycle and updates
3. Handles event delegation and bubbling
4. Provides a performant update mechanism

## Related Documentation

For more details about the UI system architecture and design decisions:

- [ADR-124: Implementing Flexbox-based UI](https://adr.decentraland.org/adr/ADR-124)
- [ADR-125: User Interface Components](https://adr.decentraland.org/adr/ADR-125)
- [ADR-237: SDK 7 Custom UI Components](https://adr.decentraland.org/adr/ADR-237)

## License

Apache 2.0

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