Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
holoviz
GitHub Repository: holoviz/panel
Path: blob/main/examples/how_to/custom/react/react_import_demo.py
2012 views
1
import param
2
3
import panel as pn
4
5
from panel.custom import Child, ReactComponent
6
7
8
class Example(ReactComponent):
9
10
child = Child()
11
12
child2 = Child()
13
14
color = param.Color()
15
16
text = param.String()
17
18
celebrate = param.Boolean()
19
20
_esm = 'react_demo.js'
21
22
_importmap = {
23
"imports": {
24
"@emotion/cache": "https://esm.sh/@emotion/cache",
25
"@emotion/react": "https://esm.sh/@emotion/[email protected]",
26
"@mui/material/": "https://esm.sh/@mui/[email protected]/",
27
"canvas-confetti": "https://esm.sh/[email protected]",
28
},
29
"scopes": {
30
}
31
}
32
33
example = Example(text='Hello World!', child='Wow!')
34
35
button = pn.widgets.Button(on_click=lambda e: example.param.update(child='Woo!'), name='Update')
36
37
pn.Row(
38
pn.Param(example.param, parameters=['color', 'text', 'celebrate']),
39
example, button
40
).servable()
41
42