File size: 2,893 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: Chakra 3.16
description: "Introducing Overlay Manager, and new examples"
type: release
version: "3.16"
authors: ["sage"]
publishedAt: "2025-04-14"
---

We're excited to announce the release of Chakra UI `v3.16`. This release brings
new features including the [overlay manager](/docs/components/overlay-manager)
component, and improvements to enhance your development experience.

## Overlay Manager

When building modern web applications, you'll often need to display temporary UI
elements that overlay the main content. These elementstypically modals,
dialogs, drawers, or alertsare crucial for user interactions but can be
challenging to manage programmatically.

With Chakra UI's Overlay Manager, you can:

- Open and close overlays from anywhere in your codebase
- Pass data to overlays and receive return values
- Update overlay content without re-rendering the entire component
- Manage multiple overlays with a controlled lifecycle

The foundation of the overlay manager is the `createOverlay` function

```tsx
import { Button, Dialog, Portal, createOverlay } from "@chakra-ui/react"

interface DialogProps {
  title: string
  description?: string
  content?: React.ReactNode
}

const dialog = createOverlay<DialogProps>((props) => {
  const { title, description, content, ...rest } = props
  return (
    <Dialog.Root {...rest}>
      <Portal>
        <Dialog.Backdrop />
        <Dialog.Positioner>
          <Dialog.Content>
            {title && (
              <Dialog.Header>
                <Dialog.Title>{title}</Dialog.Title>
              </Dialog.Header>
            )}
            <Dialog.Body spaceY="4">
              {description && (
                <Dialog.Description>{description}</Dialog.Description>
              )}
              {content}
            </Dialog.Body>
          </Dialog.Content>
        </Dialog.Positioner>
      </Portal>
    </Dialog.Root>
  )
})
```

Once you've created the overlay, you can use it in your component:

```tsx
export const MyComponent = () => {
  return (
    <>
      <Button
        onClick={() => {
          dialog.open("a", {
            title: "Dialog Title",
            description: "Dialog Description",
          })
        }}
      >
        Open Modal
      </Button>
      <dialog.Viewport />
    </>
  )
}
```

The `<dialog.Viewport />` component is crucialit's where your overlay will be
rendered. Don't forget to include it in your component tree.

## Other Improvements

- **Global CSS**: We've improved text selection contrast for all color palettes

- **System**: Add support for `borderEnd` shorthand style prop.

```tsx
<Box borderEnd="2px solid red">
  <Text>Hello</Text>
</Box>
```

- **All components**: Soften the focus ring for all color palettes, making it a
  bit more subtle.

## Upgrading

To upgrade to the latest version, run:

```bash
npm install @chakra-ui/react@latest
```