streamlit-react-components 0.1.1__tar.gz → 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {streamlit_react_components-0.1.1/src/streamlit_react_components.egg-info → streamlit_react_components-1.0.1}/PKG-INFO +222 -22
  2. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/README.md +221 -21
  3. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/pyproject.toml +1 -1
  4. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/__init__.py +2 -0
  5. streamlit_react_components-1.0.1/src/streamlit_react_components/_frontend/index.css +1 -0
  6. streamlit_react_components-1.0.1/src/streamlit_react_components/_frontend/index.js +3920 -0
  7. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/__init__.py +2 -0
  8. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/button_group.py +13 -1
  9. streamlit_react_components-1.0.1/src/streamlit_react_components/common/plotly_chart.py +284 -0
  10. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/section_header.py +33 -3
  11. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/stat_card.py +10 -1
  12. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/form/form_slider.py +12 -1
  13. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1/src/streamlit_react_components.egg-info}/PKG-INFO +222 -22
  14. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components.egg-info/SOURCES.txt +1 -0
  15. streamlit_react_components-0.1.1/src/streamlit_react_components/_frontend/index.css +0 -1
  16. streamlit_react_components-0.1.1/src/streamlit_react_components/_frontend/index.js +0 -63
  17. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/MANIFEST.in +0 -0
  18. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/setup.cfg +0 -0
  19. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/_frontend/index.html +0 -0
  20. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/chart_legend.py +0 -0
  21. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/data_table.py +0 -0
  22. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/metric_row.py +0 -0
  23. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/panel.py +0 -0
  24. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/common/step_indicator.py +0 -0
  25. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/form/__init__.py +0 -0
  26. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/form/checkbox_group.py +0 -0
  27. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components/form/form_select.py +0 -0
  28. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components.egg-info/dependency_links.txt +0 -0
  29. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components.egg-info/requires.txt +0 -0
  30. {streamlit_react_components-0.1.1 → streamlit_react_components-1.0.1}/src/streamlit_react_components.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: streamlit-react-components
3
- Version: 0.1.1
3
+ Version: 1.0.1
4
4
  Summary: Reusable React-based Streamlit components with Tailwind CSS styling
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/your-org/streamlit-react-components
@@ -19,7 +19,7 @@ Requires-Dist: streamlit>=1.24.0
19
19
 
20
20
  # Streamlit React Components
21
21
 
22
- A collection of 11 reusable React-based Streamlit components with Tailwind CSS styling. All components support custom inline styles and Tailwind class names.
22
+ A collection of 12 reusable React-based Streamlit components with Tailwind CSS styling. All components support custom inline styles and Tailwind class names.
23
23
 
24
24
  ## Installation
25
25
 
@@ -34,7 +34,7 @@ import streamlit as st
34
34
  from streamlit_react_components import (
35
35
  panel, section_header, stat_card, metric_row,
36
36
  data_table, step_indicator, button_group, chart_legend,
37
- form_select, form_slider, checkbox_group
37
+ plotly_chart, form_select, form_slider, checkbox_group
38
38
  )
39
39
  ```
40
40
 
@@ -123,11 +123,15 @@ actions = [
123
123
  | `id` | `str` | Unique identifier (returned on click) |
124
124
  | `label` | `str` | Button text (optional) |
125
125
  | `icon` | `str` | Emoji/icon (optional) |
126
- | `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"` |
126
+ | `color` | `str` | Preset (`"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"`) or hex (e.g., `"#94a3b8"`) |
127
+ | `style` | `dict` | Inline CSS styles for this button (optional) |
128
+ | `className` | `str` | Tailwind classes for this button (optional) |
129
+ | `href` | `str` | URL for link actions. External URLs (http/https) open in new tab (optional) |
127
130
 
128
131
  #### Example
129
132
 
130
133
  ```python
134
+ # Using preset colors
131
135
  clicked = section_header(
132
136
  title="Executive Summary",
133
137
  icon="📊",
@@ -137,8 +141,31 @@ clicked = section_header(
137
141
  ]
138
142
  )
139
143
 
140
- if clicked == "refresh":
141
- st.rerun()
144
+ # Using hex colors and custom styling
145
+ clicked = section_header(
146
+ title="Custom Actions",
147
+ actions=[
148
+ {"id": "custom", "label": "Custom", "color": "#ff5733"},
149
+ {"id": "styled", "label": "Styled", "style": {"padding": "12px", "borderRadius": "20px"}}
150
+ ]
151
+ )
152
+
153
+ # External link (opens in new tab)
154
+ section_header(
155
+ title="Resources",
156
+ actions=[
157
+ {"id": "docs", "label": "Documentation", "href": "https://docs.example.com", "icon": "📚"},
158
+ {"id": "github", "label": "GitHub", "href": "https://github.com", "color": "slate"}
159
+ ]
160
+ )
161
+
162
+ # Internal page navigation
163
+ clicked = section_header(
164
+ title="Settings",
165
+ actions=[{"id": "home", "label": "Home", "icon": "🏠"}]
166
+ )
167
+ if clicked == "home":
168
+ st.switch_page("pages/home.py")
142
169
  ```
143
170
 
144
171
  ---
@@ -161,13 +188,17 @@ stat_card(
161
188
 
162
189
  #### Colors
163
190
 
164
- | Color | Border | Text |
165
- |-------|--------|------|
191
+ Supports preset color names or hex values:
192
+
193
+ | Preset | Border | Text |
194
+ |--------|--------|------|
166
195
  | `"blue"` | `border-blue-500` | `text-blue-400` |
167
196
  | `"green"` | `border-green-500` | `text-green-400` |
168
197
  | `"red"` | `border-red-500` | `text-red-400` |
169
198
  | `"yellow"` | `border-yellow-500` | `text-yellow-400` |
170
199
  | `"purple"` | `border-purple-500` | `text-purple-400` |
200
+ | `"slate"` | `border-slate-500` | `text-slate-400` |
201
+ | `"#xxxxxx"` | Custom hex color | Custom hex color |
171
202
 
172
203
  #### Example
173
204
 
@@ -182,6 +213,9 @@ with col3:
182
213
  stat_card(label="Below (Underutil)", value="1", color="yellow")
183
214
  with col4:
184
215
  stat_card(label="Avg OEE", value="78.4%", color="blue")
216
+
217
+ # Using hex color
218
+ stat_card(label="Custom Color", value="42", color="#ff5733")
185
219
  ```
186
220
 
187
221
  ---
@@ -364,12 +398,15 @@ buttons = [
364
398
  | `id` | `str` | Unique identifier (returned on click) |
365
399
  | `label` | `str` | Button text (optional) |
366
400
  | `icon` | `str` | Emoji/icon (optional) |
367
- | `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"` |
401
+ | `color` | `str` | Preset (`"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"`) or hex (e.g., `"#94a3b8"`) |
368
402
  | `disabled` | `bool` | Disable the button |
403
+ | `style` | `dict` | Inline CSS styles for this button (optional) |
404
+ | `className` | `str` | Tailwind classes for this button (optional) |
369
405
 
370
406
  #### Example
371
407
 
372
408
  ```python
409
+ # Using preset colors
373
410
  clicked = button_group(
374
411
  buttons=[
375
412
  {"id": "view", "icon": "👁️", "label": "View"},
@@ -378,6 +415,14 @@ clicked = button_group(
378
415
  ]
379
416
  )
380
417
 
418
+ # Using hex colors and custom styling
419
+ clicked = button_group(
420
+ buttons=[
421
+ {"id": "custom", "icon": "🎨", "color": "#ff5733"},
422
+ {"id": "styled", "label": "Styled", "style": {"padding": "12px"}}
423
+ ]
424
+ )
425
+
381
426
  if clicked == "delete":
382
427
  st.warning("Delete clicked!")
383
428
  ```
@@ -427,7 +472,163 @@ chart_legend(
427
472
 
428
473
  ---
429
474
 
430
- ### 9. Form Select
475
+ ### 9. Plotly Chart
476
+
477
+ Render Plotly charts with full interactivity and event callbacks.
478
+
479
+ ```python
480
+ plotly_chart(
481
+ # Data source (one required)
482
+ figure: Any = None, # Plotly figure or dict
483
+ data: DataFrame = None, # pandas DataFrame
484
+
485
+ # DataFrame options (when using data=)
486
+ x: str = None, # Column name for x-axis
487
+ y: str | list = None, # Column name(s) for y-axis
488
+ color: str = None, # Column name for color grouping
489
+ chart_type: str = "line", # "line", "bar", "scatter", "area", "pie", "histogram"
490
+ title: str = None, # Chart title
491
+
492
+ # Plotly config
493
+ config: dict = None, # Plotly config options
494
+
495
+ # Event callbacks
496
+ on_click: bool = False, # Enable click events
497
+ on_select: bool = False, # Enable selection events
498
+ on_hover: bool = False, # Enable hover events
499
+ on_relayout: bool = False, # Enable zoom/pan events
500
+
501
+ # Expandable dialog
502
+ expandable: bool = False, # Show expand button
503
+ modal_title: str = "", # Dialog header title
504
+
505
+ # Styling
506
+ style: dict = None,
507
+ class_name: str = "",
508
+ key: str = None
509
+ ) -> dict | None # Returns event dict or None
510
+ ```
511
+
512
+ #### Using Plotly Figure
513
+
514
+ ```python
515
+ import plotly.graph_objects as go
516
+
517
+ fig = go.Figure(
518
+ data=[
519
+ go.Scatter(x=[1,2,3,4,5], y=[10,15,13,17,20], mode='lines+markers', name='Sales'),
520
+ go.Bar(x=[1,2,3,4,5], y=[5,8,6,9,12], name='Orders')
521
+ ],
522
+ layout=go.Layout(title='Sales Dashboard')
523
+ )
524
+
525
+ event = plotly_chart(
526
+ figure=fig,
527
+ on_click=True,
528
+ on_select=True,
529
+ style={"height": "400px"}
530
+ )
531
+
532
+ if event and event['type'] == 'click':
533
+ st.write(f"Clicked: {event['points']}")
534
+ ```
535
+
536
+ #### Using DataFrame
537
+
538
+ ```python
539
+ import pandas as pd
540
+
541
+ df = pd.DataFrame({
542
+ 'month': ['Jan', 'Feb', 'Mar', 'Apr'],
543
+ 'sales': [100, 150, 120, 180],
544
+ 'orders': [50, 75, 60, 90]
545
+ })
546
+
547
+ # Simple line chart
548
+ event = plotly_chart(
549
+ data=df,
550
+ x='month',
551
+ y='sales',
552
+ chart_type='line',
553
+ title='Monthly Sales'
554
+ )
555
+
556
+ # Multiple y columns as bar chart
557
+ event = plotly_chart(
558
+ data=df,
559
+ x='month',
560
+ y=['sales', 'orders'],
561
+ chart_type='bar',
562
+ title='Sales vs Orders'
563
+ )
564
+
565
+ # Scatter with color grouping
566
+ event = plotly_chart(
567
+ data=df,
568
+ x='sales',
569
+ y='orders',
570
+ color='month',
571
+ chart_type='scatter'
572
+ )
573
+ ```
574
+
575
+ #### Chart Types (DataFrame mode)
576
+
577
+ | Type | Description |
578
+ |------|-------------|
579
+ | `"line"` | Line chart with connected points |
580
+ | `"scatter"` | Scatter plot with markers only |
581
+ | `"bar"` | Vertical bar chart |
582
+ | `"area"` | Area chart (filled line) |
583
+ | `"pie"` | Pie chart (x=labels, y=values) |
584
+ | `"histogram"` | Histogram of x values |
585
+
586
+ #### Event Types
587
+
588
+ | Event | When Triggered | Data Returned |
589
+ |-------|----------------|---------------|
590
+ | `click` | User clicks a data point | `{type: 'click', points: [...]}` |
591
+ | `select` | User box/lasso selects points | `{type: 'select', points: [...]}` |
592
+ | `hover` | User hovers over a point | `{type: 'hover', points: [...]}` |
593
+ | `relayout` | User zooms/pans the chart | `{type: 'relayout', relayout: {...}}` |
594
+
595
+ #### Point Data Structure
596
+
597
+ Each point in the `points` array contains:
598
+
599
+ ```python
600
+ {
601
+ "curveNumber": 0, # Index of the trace
602
+ "pointNumber": 2, # Index of the point in the trace
603
+ "pointIndex": 2, # Same as pointNumber
604
+ "x": "Mar", # X value
605
+ "y": 120, # Y value
606
+ "customdata": None # Custom data if provided
607
+ }
608
+ ```
609
+
610
+ #### Expandable Dialog
611
+
612
+ Charts can be expanded into a full-page dialog using Streamlit's native `st.dialog()`:
613
+
614
+ ```python
615
+ event = plotly_chart(
616
+ figure=fig,
617
+ expandable=True, # Show expand button in corner
618
+ modal_title="Sales Dashboard", # Title in dialog header
619
+ style={"height": "300px"}
620
+ )
621
+ ```
622
+
623
+ **Dialog Features:**
624
+ - Click the expand icon (⛶) in the top-right corner to open
625
+ - Dialog uses Streamlit's native full-width dialog overlay
626
+ - Click outside the dialog or press Escape to close
627
+ - Chart renders at full dialog width for better visibility
628
+
629
+ ---
630
+
631
+ ### 10. Form Select
431
632
 
432
633
  A styled dropdown select input.
433
634
 
@@ -490,7 +691,7 @@ scenario = form_select(
490
691
 
491
692
  ---
492
693
 
493
- ### 10. Form Slider
694
+ ### 11. Form Slider
494
695
 
495
696
  A styled range slider input.
496
697
 
@@ -502,7 +703,7 @@ form_slider(
502
703
  max_val: float, # Maximum value
503
704
  step: float = 1, # Step increment
504
705
  unit: str = "", # Unit suffix (e.g., "%", "hrs")
505
- color: str = "blue", # Value display color
706
+ color: str = "blue", # Preset or hex color (e.g., "#94a3b8")
506
707
  style: dict = None,
507
708
  class_name: str = "",
508
709
  key: str = None
@@ -512,7 +713,7 @@ form_slider(
512
713
  #### Example
513
714
 
514
715
  ```python
515
- # Percentage slider
716
+ # Percentage slider with preset color
516
717
  threshold = form_slider(
517
718
  label="Upper Threshold",
518
719
  value=90,
@@ -533,20 +734,19 @@ hold_time = form_slider(
533
734
  color="blue"
534
735
  )
535
736
 
536
- # Batch size
537
- batch = form_slider(
538
- label="Batch Size",
539
- value=500,
540
- min_val=200,
541
- max_val=1000,
542
- step=25,
543
- color="green"
737
+ # Slider with hex color
738
+ custom_slider = form_slider(
739
+ label="Custom Color",
740
+ value=50,
741
+ min_val=0,
742
+ max_val=100,
743
+ color="#ff5733"
544
744
  )
545
745
  ```
546
746
 
547
747
  ---
548
748
 
549
- ### 11. Checkbox Group
749
+ ### 12. Checkbox Group
550
750
 
551
751
  A group of checkboxes.
552
752
 
@@ -1,6 +1,6 @@
1
1
  # Streamlit React Components
2
2
 
3
- A collection of 11 reusable React-based Streamlit components with Tailwind CSS styling. All components support custom inline styles and Tailwind class names.
3
+ A collection of 12 reusable React-based Streamlit components with Tailwind CSS styling. All components support custom inline styles and Tailwind class names.
4
4
 
5
5
  ## Installation
6
6
 
@@ -15,7 +15,7 @@ import streamlit as st
15
15
  from streamlit_react_components import (
16
16
  panel, section_header, stat_card, metric_row,
17
17
  data_table, step_indicator, button_group, chart_legend,
18
- form_select, form_slider, checkbox_group
18
+ plotly_chart, form_select, form_slider, checkbox_group
19
19
  )
20
20
  ```
21
21
 
@@ -104,11 +104,15 @@ actions = [
104
104
  | `id` | `str` | Unique identifier (returned on click) |
105
105
  | `label` | `str` | Button text (optional) |
106
106
  | `icon` | `str` | Emoji/icon (optional) |
107
- | `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"` |
107
+ | `color` | `str` | Preset (`"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"`) or hex (e.g., `"#94a3b8"`) |
108
+ | `style` | `dict` | Inline CSS styles for this button (optional) |
109
+ | `className` | `str` | Tailwind classes for this button (optional) |
110
+ | `href` | `str` | URL for link actions. External URLs (http/https) open in new tab (optional) |
108
111
 
109
112
  #### Example
110
113
 
111
114
  ```python
115
+ # Using preset colors
112
116
  clicked = section_header(
113
117
  title="Executive Summary",
114
118
  icon="📊",
@@ -118,8 +122,31 @@ clicked = section_header(
118
122
  ]
119
123
  )
120
124
 
121
- if clicked == "refresh":
122
- st.rerun()
125
+ # Using hex colors and custom styling
126
+ clicked = section_header(
127
+ title="Custom Actions",
128
+ actions=[
129
+ {"id": "custom", "label": "Custom", "color": "#ff5733"},
130
+ {"id": "styled", "label": "Styled", "style": {"padding": "12px", "borderRadius": "20px"}}
131
+ ]
132
+ )
133
+
134
+ # External link (opens in new tab)
135
+ section_header(
136
+ title="Resources",
137
+ actions=[
138
+ {"id": "docs", "label": "Documentation", "href": "https://docs.example.com", "icon": "📚"},
139
+ {"id": "github", "label": "GitHub", "href": "https://github.com", "color": "slate"}
140
+ ]
141
+ )
142
+
143
+ # Internal page navigation
144
+ clicked = section_header(
145
+ title="Settings",
146
+ actions=[{"id": "home", "label": "Home", "icon": "🏠"}]
147
+ )
148
+ if clicked == "home":
149
+ st.switch_page("pages/home.py")
123
150
  ```
124
151
 
125
152
  ---
@@ -142,13 +169,17 @@ stat_card(
142
169
 
143
170
  #### Colors
144
171
 
145
- | Color | Border | Text |
146
- |-------|--------|------|
172
+ Supports preset color names or hex values:
173
+
174
+ | Preset | Border | Text |
175
+ |--------|--------|------|
147
176
  | `"blue"` | `border-blue-500` | `text-blue-400` |
148
177
  | `"green"` | `border-green-500` | `text-green-400` |
149
178
  | `"red"` | `border-red-500` | `text-red-400` |
150
179
  | `"yellow"` | `border-yellow-500` | `text-yellow-400` |
151
180
  | `"purple"` | `border-purple-500` | `text-purple-400` |
181
+ | `"slate"` | `border-slate-500` | `text-slate-400` |
182
+ | `"#xxxxxx"` | Custom hex color | Custom hex color |
152
183
 
153
184
  #### Example
154
185
 
@@ -163,6 +194,9 @@ with col3:
163
194
  stat_card(label="Below (Underutil)", value="1", color="yellow")
164
195
  with col4:
165
196
  stat_card(label="Avg OEE", value="78.4%", color="blue")
197
+
198
+ # Using hex color
199
+ stat_card(label="Custom Color", value="42", color="#ff5733")
166
200
  ```
167
201
 
168
202
  ---
@@ -345,12 +379,15 @@ buttons = [
345
379
  | `id` | `str` | Unique identifier (returned on click) |
346
380
  | `label` | `str` | Button text (optional) |
347
381
  | `icon` | `str` | Emoji/icon (optional) |
348
- | `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"` |
382
+ | `color` | `str` | Preset (`"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"`) or hex (e.g., `"#94a3b8"`) |
349
383
  | `disabled` | `bool` | Disable the button |
384
+ | `style` | `dict` | Inline CSS styles for this button (optional) |
385
+ | `className` | `str` | Tailwind classes for this button (optional) |
350
386
 
351
387
  #### Example
352
388
 
353
389
  ```python
390
+ # Using preset colors
354
391
  clicked = button_group(
355
392
  buttons=[
356
393
  {"id": "view", "icon": "👁️", "label": "View"},
@@ -359,6 +396,14 @@ clicked = button_group(
359
396
  ]
360
397
  )
361
398
 
399
+ # Using hex colors and custom styling
400
+ clicked = button_group(
401
+ buttons=[
402
+ {"id": "custom", "icon": "🎨", "color": "#ff5733"},
403
+ {"id": "styled", "label": "Styled", "style": {"padding": "12px"}}
404
+ ]
405
+ )
406
+
362
407
  if clicked == "delete":
363
408
  st.warning("Delete clicked!")
364
409
  ```
@@ -408,7 +453,163 @@ chart_legend(
408
453
 
409
454
  ---
410
455
 
411
- ### 9. Form Select
456
+ ### 9. Plotly Chart
457
+
458
+ Render Plotly charts with full interactivity and event callbacks.
459
+
460
+ ```python
461
+ plotly_chart(
462
+ # Data source (one required)
463
+ figure: Any = None, # Plotly figure or dict
464
+ data: DataFrame = None, # pandas DataFrame
465
+
466
+ # DataFrame options (when using data=)
467
+ x: str = None, # Column name for x-axis
468
+ y: str | list = None, # Column name(s) for y-axis
469
+ color: str = None, # Column name for color grouping
470
+ chart_type: str = "line", # "line", "bar", "scatter", "area", "pie", "histogram"
471
+ title: str = None, # Chart title
472
+
473
+ # Plotly config
474
+ config: dict = None, # Plotly config options
475
+
476
+ # Event callbacks
477
+ on_click: bool = False, # Enable click events
478
+ on_select: bool = False, # Enable selection events
479
+ on_hover: bool = False, # Enable hover events
480
+ on_relayout: bool = False, # Enable zoom/pan events
481
+
482
+ # Expandable dialog
483
+ expandable: bool = False, # Show expand button
484
+ modal_title: str = "", # Dialog header title
485
+
486
+ # Styling
487
+ style: dict = None,
488
+ class_name: str = "",
489
+ key: str = None
490
+ ) -> dict | None # Returns event dict or None
491
+ ```
492
+
493
+ #### Using Plotly Figure
494
+
495
+ ```python
496
+ import plotly.graph_objects as go
497
+
498
+ fig = go.Figure(
499
+ data=[
500
+ go.Scatter(x=[1,2,3,4,5], y=[10,15,13,17,20], mode='lines+markers', name='Sales'),
501
+ go.Bar(x=[1,2,3,4,5], y=[5,8,6,9,12], name='Orders')
502
+ ],
503
+ layout=go.Layout(title='Sales Dashboard')
504
+ )
505
+
506
+ event = plotly_chart(
507
+ figure=fig,
508
+ on_click=True,
509
+ on_select=True,
510
+ style={"height": "400px"}
511
+ )
512
+
513
+ if event and event['type'] == 'click':
514
+ st.write(f"Clicked: {event['points']}")
515
+ ```
516
+
517
+ #### Using DataFrame
518
+
519
+ ```python
520
+ import pandas as pd
521
+
522
+ df = pd.DataFrame({
523
+ 'month': ['Jan', 'Feb', 'Mar', 'Apr'],
524
+ 'sales': [100, 150, 120, 180],
525
+ 'orders': [50, 75, 60, 90]
526
+ })
527
+
528
+ # Simple line chart
529
+ event = plotly_chart(
530
+ data=df,
531
+ x='month',
532
+ y='sales',
533
+ chart_type='line',
534
+ title='Monthly Sales'
535
+ )
536
+
537
+ # Multiple y columns as bar chart
538
+ event = plotly_chart(
539
+ data=df,
540
+ x='month',
541
+ y=['sales', 'orders'],
542
+ chart_type='bar',
543
+ title='Sales vs Orders'
544
+ )
545
+
546
+ # Scatter with color grouping
547
+ event = plotly_chart(
548
+ data=df,
549
+ x='sales',
550
+ y='orders',
551
+ color='month',
552
+ chart_type='scatter'
553
+ )
554
+ ```
555
+
556
+ #### Chart Types (DataFrame mode)
557
+
558
+ | Type | Description |
559
+ |------|-------------|
560
+ | `"line"` | Line chart with connected points |
561
+ | `"scatter"` | Scatter plot with markers only |
562
+ | `"bar"` | Vertical bar chart |
563
+ | `"area"` | Area chart (filled line) |
564
+ | `"pie"` | Pie chart (x=labels, y=values) |
565
+ | `"histogram"` | Histogram of x values |
566
+
567
+ #### Event Types
568
+
569
+ | Event | When Triggered | Data Returned |
570
+ |-------|----------------|---------------|
571
+ | `click` | User clicks a data point | `{type: 'click', points: [...]}` |
572
+ | `select` | User box/lasso selects points | `{type: 'select', points: [...]}` |
573
+ | `hover` | User hovers over a point | `{type: 'hover', points: [...]}` |
574
+ | `relayout` | User zooms/pans the chart | `{type: 'relayout', relayout: {...}}` |
575
+
576
+ #### Point Data Structure
577
+
578
+ Each point in the `points` array contains:
579
+
580
+ ```python
581
+ {
582
+ "curveNumber": 0, # Index of the trace
583
+ "pointNumber": 2, # Index of the point in the trace
584
+ "pointIndex": 2, # Same as pointNumber
585
+ "x": "Mar", # X value
586
+ "y": 120, # Y value
587
+ "customdata": None # Custom data if provided
588
+ }
589
+ ```
590
+
591
+ #### Expandable Dialog
592
+
593
+ Charts can be expanded into a full-page dialog using Streamlit's native `st.dialog()`:
594
+
595
+ ```python
596
+ event = plotly_chart(
597
+ figure=fig,
598
+ expandable=True, # Show expand button in corner
599
+ modal_title="Sales Dashboard", # Title in dialog header
600
+ style={"height": "300px"}
601
+ )
602
+ ```
603
+
604
+ **Dialog Features:**
605
+ - Click the expand icon (⛶) in the top-right corner to open
606
+ - Dialog uses Streamlit's native full-width dialog overlay
607
+ - Click outside the dialog or press Escape to close
608
+ - Chart renders at full dialog width for better visibility
609
+
610
+ ---
611
+
612
+ ### 10. Form Select
412
613
 
413
614
  A styled dropdown select input.
414
615
 
@@ -471,7 +672,7 @@ scenario = form_select(
471
672
 
472
673
  ---
473
674
 
474
- ### 10. Form Slider
675
+ ### 11. Form Slider
475
676
 
476
677
  A styled range slider input.
477
678
 
@@ -483,7 +684,7 @@ form_slider(
483
684
  max_val: float, # Maximum value
484
685
  step: float = 1, # Step increment
485
686
  unit: str = "", # Unit suffix (e.g., "%", "hrs")
486
- color: str = "blue", # Value display color
687
+ color: str = "blue", # Preset or hex color (e.g., "#94a3b8")
487
688
  style: dict = None,
488
689
  class_name: str = "",
489
690
  key: str = None
@@ -493,7 +694,7 @@ form_slider(
493
694
  #### Example
494
695
 
495
696
  ```python
496
- # Percentage slider
697
+ # Percentage slider with preset color
497
698
  threshold = form_slider(
498
699
  label="Upper Threshold",
499
700
  value=90,
@@ -514,20 +715,19 @@ hold_time = form_slider(
514
715
  color="blue"
515
716
  )
516
717
 
517
- # Batch size
518
- batch = form_slider(
519
- label="Batch Size",
520
- value=500,
521
- min_val=200,
522
- max_val=1000,
523
- step=25,
524
- color="green"
718
+ # Slider with hex color
719
+ custom_slider = form_slider(
720
+ label="Custom Color",
721
+ value=50,
722
+ min_val=0,
723
+ max_val=100,
724
+ color="#ff5733"
525
725
  )
526
726
  ```
527
727
 
528
728
  ---
529
729
 
530
- ### 11. Checkbox Group
730
+ ### 12. Checkbox Group
531
731
 
532
732
  A group of checkboxes.
533
733