https://github.com/konvajs/react-konva-utils
https://github.com/konvajs/react-konva-utils
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/konvajs/react-konva-utils
- Owner: konvajs
- License: mit
- Created: 2021-04-06T17:50:08.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-01-23T17:39:20.000Z (over 1 year ago)
- Last Synced: 2024-05-23T07:02:02.111Z (about 1 year ago)
- Language: TypeScript
- Size: 49.8 KB
- Stars: 52
- Watchers: 4
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Useful components and hooks for [react-konva](https://github.com/konvajs/react-konva/) apps.
## Html
`Html` components allows you to create DOM components inside Konva stage. All DOM components will be placed over canvas content.
```js
import { Html } from 'react-konva-utils';newAttrs} // function to overwrite transformation attributes, not used if transform = false, default is undefined
groupProps={{}} // additional properties to the group wrapper, useful for some position offset
divProps={{}} // additional props for wrapped div elements, useful for styles
>
DOM content
;
```### How does it work?
Konva is a canvas library. It can't render DOM elements directly. `` component will just create a div element and put it top top of the canvas with absolute positioning. That means HTML will be not visible if you export canvas as image.
The most common use case is to create HTML content for temporary tooltips or textareas.
## Portal
`Portal` allows you to create portal from one Konva container (such as `Layer` or `Group`) into another.
```js
import { Portal } from 'react-konva-utils';
{/* content of that portal will be moved into "top" group*/}
;
```