streamlit-react-components 0.1.1__py3-none-any.whl → 1.0.1__py3-none-any.whl

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.
@@ -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
 
@@ -0,0 +1,22 @@
1
+ streamlit_react_components/__init__.py,sha256=-m5OJx0vsfzD6k2m_2X8eMQXi9pgkreAuDZJoVWbdJ0,673
2
+ streamlit_react_components/_frontend/index.css,sha256=vW-yXHEFGLJUbWgkRewomPA8R3Um6h8kADSJqzEHxIc,26376
3
+ streamlit_react_components/_frontend/index.html,sha256=CjBEtVYlgT_q06BE16EHFrUrJZ6z0MCprrTg7qgAWzw,381
4
+ streamlit_react_components/_frontend/index.js,sha256=slhaVPHpVSgP6b7yYt43p5_hFEtNAEl2_DhrUnH6stM,5215495
5
+ streamlit_react_components/common/__init__.py,sha256=xUKaw_X2B2xd6AqW8oLzHupGp-TX3Fij0FjhMNwd-vs,550
6
+ streamlit_react_components/common/button_group.py,sha256=g38gpR62dQ8KLd3JyANvGonT6tf-tyooIjC6t3O4iH0,2225
7
+ streamlit_react_components/common/chart_legend.py,sha256=So703OO-sI6SWrSVGKH0OTiI-smr4luqgBtXQ9GwIlI,1377
8
+ streamlit_react_components/common/data_table.py,sha256=dEvRxCBejvoye7jsqGcdsh_Ox-VeRpWMHgaAi-qv5HM,2142
9
+ streamlit_react_components/common/metric_row.py,sha256=abDfSrLvZO8MK2gglvE98L5U0Fx2NfNHGF5bBnfqR5I,1257
10
+ streamlit_react_components/common/panel.py,sha256=O4URjnK8u9_byFzDO9RAFdpXjzNdxpXY1CX8gEEK1pY,1094
11
+ streamlit_react_components/common/plotly_chart.py,sha256=px1pITa8GSYl_TTg4KzX81nQy_F-9XwUV_91fR7d0po,9368
12
+ streamlit_react_components/common/section_header.py,sha256=2sVLWHjHx2WdhbVVLBgs5shwUUbw6lbAKbsAwiwIWpg,2983
13
+ streamlit_react_components/common/stat_card.py,sha256=PimCX6Dd18DyfJn6tk0YmrA1zKvAiqeKXdHAKXhxiRQ,1674
14
+ streamlit_react_components/common/step_indicator.py,sha256=araovSL_c5h66PawZBf5IlQbVoxXwE9kD0H10ZopVoU,1370
15
+ streamlit_react_components/form/__init__.py,sha256=XP9oBEHSwLTNqu88sYm0F_n828yzPStDJl3N62HxVvc,222
16
+ streamlit_react_components/form/checkbox_group.py,sha256=NLNJW1Ql60PnFj0FdH6Q0gUAGx2NOVNI9geIG-NG8G4,1779
17
+ streamlit_react_components/form/form_select.py,sha256=KILKVUO-Elb0nqbTEImxyoGQQrnZ_jft30iJSbY5ksk,1946
18
+ streamlit_react_components/form/form_slider.py,sha256=4w9h-d-9yAHg3ZqUHCZGzsfUG3lP5OTwVrDo5sZAnfQ,2032
19
+ streamlit_react_components-1.0.1.dist-info/METADATA,sha256=VYZrioH2thbXYa6VWW1A2DTDGqmsddFeYUJeQZXlRuU,21677
20
+ streamlit_react_components-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ streamlit_react_components-1.0.1.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
22
+ streamlit_react_components-1.0.1.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- streamlit_react_components/__init__.py,sha256=UFqSg3IlXb1-E_PgJQFEUh-MWjoooGz1Gyq_kVlibBk,635
2
- streamlit_react_components/_frontend/index.css,sha256=bGjKlFP0M9oZjCZxs5LhgGVI9XaWBJw9CIuvuR8G48E,26096
3
- streamlit_react_components/_frontend/index.html,sha256=CjBEtVYlgT_q06BE16EHFrUrJZ6z0MCprrTg7qgAWzw,381
4
- streamlit_react_components/_frontend/index.js,sha256=nXjpPEeTg84ip8r1yLUa9m5402XqPV93UBas4rnYrvk,328827
5
- streamlit_react_components/common/__init__.py,sha256=WEyVUIRkwspYAyll6fhuoBGD5HKVQpBLR9CjYEQqyu8,491
6
- streamlit_react_components/common/button_group.py,sha256=8g8L79i-tjFuheAqJUe46mRzEFlcDfbjMpYNF8Hui58,1698
7
- streamlit_react_components/common/chart_legend.py,sha256=So703OO-sI6SWrSVGKH0OTiI-smr4luqgBtXQ9GwIlI,1377
8
- streamlit_react_components/common/data_table.py,sha256=dEvRxCBejvoye7jsqGcdsh_Ox-VeRpWMHgaAi-qv5HM,2142
9
- streamlit_react_components/common/metric_row.py,sha256=abDfSrLvZO8MK2gglvE98L5U0Fx2NfNHGF5bBnfqR5I,1257
10
- streamlit_react_components/common/panel.py,sha256=O4URjnK8u9_byFzDO9RAFdpXjzNdxpXY1CX8gEEK1pY,1094
11
- streamlit_react_components/common/section_header.py,sha256=HaochqnbSI2lAIU8zXzqMYRIofqGMRbumQOmBMxQle4,1762
12
- streamlit_react_components/common/stat_card.py,sha256=l3amtS0JpRqoiZSqdcS2HfE3FxFlzOlIgR8aPX0fnOo,1433
13
- streamlit_react_components/common/step_indicator.py,sha256=araovSL_c5h66PawZBf5IlQbVoxXwE9kD0H10ZopVoU,1370
14
- streamlit_react_components/form/__init__.py,sha256=XP9oBEHSwLTNqu88sYm0F_n828yzPStDJl3N62HxVvc,222
15
- streamlit_react_components/form/checkbox_group.py,sha256=NLNJW1Ql60PnFj0FdH6Q0gUAGx2NOVNI9geIG-NG8G4,1779
16
- streamlit_react_components/form/form_select.py,sha256=KILKVUO-Elb0nqbTEImxyoGQQrnZ_jft30iJSbY5ksk,1946
17
- streamlit_react_components/form/form_slider.py,sha256=iRkPr4hg1vpsNjFF8paZ3jRb3hA1iU3Jp7WairZD_t4,1730
18
- streamlit_react_components-0.1.1.dist-info/METADATA,sha256=Z7-lMK1ICGUSwjVgnWdTEYNM_uPDrzYR6iM2rudP3q0,15815
19
- streamlit_react_components-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- streamlit_react_components-0.1.1.dist-info/top_level.txt,sha256=3JFrl15-Uewx3BFMSzqrBufF9GmTS1LDKfShmg0R9VE,27
21
- streamlit_react_components-0.1.1.dist-info/RECORD,,