Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
holoviz
GitHub Repository: holoviz/panel
Path: blob/main/examples/how_to/custom/react/material_ui.py
2012 views
1
import param
2
3
import panel as pn
4
5
from panel.custom import ReactComponent
6
7
8
class MuiComponent(ReactComponent):
9
10
_importmap = {
11
"imports": {
12
"@mui/material/": "https://esm.sh/@mui/[email protected]/",
13
}
14
}
15
16
class Button(MuiComponent):
17
18
label = param.String()
19
20
variant = param.Selector(default='contained', objects=['text', 'contained', 'outlined'])
21
22
_esm = 'mui_button.js'
23
24
class DiscreteSlider(MuiComponent):
25
26
marks = param.List(default=[])
27
28
value = param.Number(default=20)
29
30
_esm = 'mui_slider.js'
31
32
33
b = Button()
34
s = DiscreteSlider(marks=[
35
{
36
'value': 0,
37
'label': '0°C',
38
},
39
{
40
'value': 20,
41
'label': '20°C',
42
},
43
{
44
'value': 37,
45
'label': '37°C',
46
},
47
{
48
'value': 100,
49
'label': '100°C',
50
},
51
])
52
53
pn.Row(
54
pn.Param(b.param, parameters=['label', 'variant']),
55
pn.Column(b, s)
56
).servable()
57
58