streamlit-react-components 0.1.0__tar.gz → 0.1.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.
- streamlit_react_components-0.1.1/PKG-INFO +677 -0
- streamlit_react_components-0.1.1/README.md +658 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/pyproject.toml +1 -1
- streamlit_react_components-0.1.1/src/streamlit_react_components/_frontend/index.css +1 -0
- streamlit_react_components-0.1.1/src/streamlit_react_components.egg-info/PKG-INFO +677 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components.egg-info/SOURCES.txt +1 -0
- streamlit_react_components-0.1.0/PKG-INFO +0 -18
- streamlit_react_components-0.1.0/src/streamlit_react_components/_frontend/index.css +0 -1
- streamlit_react_components-0.1.0/src/streamlit_react_components.egg-info/PKG-INFO +0 -18
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/MANIFEST.in +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/setup.cfg +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/__init__.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/_frontend/index.html +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/_frontend/index.js +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/__init__.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/button_group.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/chart_legend.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/data_table.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/metric_row.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/panel.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/section_header.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/stat_card.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/common/step_indicator.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/form/__init__.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/form/checkbox_group.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/form/form_select.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components/form/form_slider.py +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components.egg-info/dependency_links.txt +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components.egg-info/requires.txt +0 -0
- {streamlit_react_components-0.1.0 → streamlit_react_components-0.1.1}/src/streamlit_react_components.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamlit-react-components
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Reusable React-based Streamlit components with Tailwind CSS styling
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/your-org/streamlit-react-components
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Requires-Python: >=3.8
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
Requires-Dist: streamlit>=1.24.0
|
|
19
|
+
|
|
20
|
+
# Streamlit React Components
|
|
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.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install streamlit-react-components
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import streamlit as st
|
|
34
|
+
from streamlit_react_components import (
|
|
35
|
+
panel, section_header, stat_card, metric_row,
|
|
36
|
+
data_table, step_indicator, button_group, chart_legend,
|
|
37
|
+
form_select, form_slider, checkbox_group
|
|
38
|
+
)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Styling
|
|
44
|
+
|
|
45
|
+
All components accept two styling parameters:
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Description |
|
|
48
|
+
|-----------|------|-------------|
|
|
49
|
+
| `style` | `dict` | Inline CSS as Python dict (e.g., `{"background": "#1e293b", "padding": "16px"}`) |
|
|
50
|
+
| `class_name` | `str` | Tailwind CSS classes (e.g., `"bg-slate-900 p-4 rounded-lg"`) |
|
|
51
|
+
|
|
52
|
+
### Example
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
stat_card(
|
|
56
|
+
label="Revenue",
|
|
57
|
+
value="$50K",
|
|
58
|
+
color="blue",
|
|
59
|
+
style={"minWidth": "200px", "boxShadow": "0 4px 6px rgba(0,0,0,0.3)"},
|
|
60
|
+
class_name="border border-blue-500"
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Components
|
|
67
|
+
|
|
68
|
+
### 1. Panel
|
|
69
|
+
|
|
70
|
+
A styled container/card wrapper.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
panel(
|
|
74
|
+
children: str = "", # HTML content
|
|
75
|
+
style: dict = None,
|
|
76
|
+
class_name: str = "",
|
|
77
|
+
key: str = None
|
|
78
|
+
) -> None
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Example
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
panel(
|
|
85
|
+
children="<h3 style='color: white;'>Title</h3><p style='color: #94a3b8;'>Content here</p>",
|
|
86
|
+
class_name="border border-blue-500"
|
|
87
|
+
)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Default Styling
|
|
91
|
+
- Background: `bg-slate-900`
|
|
92
|
+
- Border radius: `rounded-lg`
|
|
93
|
+
- Padding: `p-4`
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
### 2. Section Header
|
|
98
|
+
|
|
99
|
+
A section title with optional action buttons.
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
section_header(
|
|
103
|
+
title: str, # Header text
|
|
104
|
+
icon: str = "", # Emoji or icon prefix
|
|
105
|
+
actions: list = None, # List of action buttons
|
|
106
|
+
style: dict = None,
|
|
107
|
+
class_name: str = "",
|
|
108
|
+
key: str = None
|
|
109
|
+
) -> str | None # Returns clicked action ID
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Actions Format
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
actions = [
|
|
116
|
+
{"id": "refresh", "label": "Refresh", "color": "blue"},
|
|
117
|
+
{"id": "export", "icon": "📥", "label": "Export", "color": "green"}
|
|
118
|
+
]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
| Action Key | Type | Description |
|
|
122
|
+
|------------|------|-------------|
|
|
123
|
+
| `id` | `str` | Unique identifier (returned on click) |
|
|
124
|
+
| `label` | `str` | Button text (optional) |
|
|
125
|
+
| `icon` | `str` | Emoji/icon (optional) |
|
|
126
|
+
| `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"` |
|
|
127
|
+
|
|
128
|
+
#### Example
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
clicked = section_header(
|
|
132
|
+
title="Executive Summary",
|
|
133
|
+
icon="📊",
|
|
134
|
+
actions=[
|
|
135
|
+
{"id": "refresh", "label": "Refresh", "color": "blue"},
|
|
136
|
+
{"id": "settings", "icon": "⚙️", "color": "slate"}
|
|
137
|
+
]
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
if clicked == "refresh":
|
|
141
|
+
st.rerun()
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### 3. Stat Card
|
|
147
|
+
|
|
148
|
+
A statistics display card with colored accent.
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
stat_card(
|
|
152
|
+
label: str, # Description text
|
|
153
|
+
value: str | int | float, # The statistic value
|
|
154
|
+
color: str = "blue", # Accent color
|
|
155
|
+
icon: str = "", # Optional icon
|
|
156
|
+
style: dict = None,
|
|
157
|
+
class_name: str = "",
|
|
158
|
+
key: str = None
|
|
159
|
+
) -> None
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### Colors
|
|
163
|
+
|
|
164
|
+
| Color | Border | Text |
|
|
165
|
+
|-------|--------|------|
|
|
166
|
+
| `"blue"` | `border-blue-500` | `text-blue-400` |
|
|
167
|
+
| `"green"` | `border-green-500` | `text-green-400` |
|
|
168
|
+
| `"red"` | `border-red-500` | `text-red-400` |
|
|
169
|
+
| `"yellow"` | `border-yellow-500` | `text-yellow-400` |
|
|
170
|
+
| `"purple"` | `border-purple-500` | `text-purple-400` |
|
|
171
|
+
|
|
172
|
+
#### Example
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
col1, col2, col3, col4 = st.columns(4)
|
|
176
|
+
|
|
177
|
+
with col1:
|
|
178
|
+
stat_card(label="Within Threshold", value="4", color="green")
|
|
179
|
+
with col2:
|
|
180
|
+
stat_card(label="Above (Risk)", value="2", color="red")
|
|
181
|
+
with col3:
|
|
182
|
+
stat_card(label="Below (Underutil)", value="1", color="yellow")
|
|
183
|
+
with col4:
|
|
184
|
+
stat_card(label="Avg OEE", value="78.4%", color="blue")
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
### 4. Metric Row
|
|
190
|
+
|
|
191
|
+
A key-value display row.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
metric_row(
|
|
195
|
+
label: str, # Left-side label
|
|
196
|
+
value: str, # Right-side value
|
|
197
|
+
value_color: str = "", # Tailwind text color class
|
|
198
|
+
style: dict = None,
|
|
199
|
+
class_name: str = "",
|
|
200
|
+
key: str = None
|
|
201
|
+
) -> None
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Example
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
metric_row(label="Mean", value="78.4%")
|
|
208
|
+
metric_row(label="Median", value="79.0%")
|
|
209
|
+
metric_row(label="Outliers", value="3", value_color="text-red-400")
|
|
210
|
+
metric_row(label="Trend", value="↑ +0.4%/mo", value_color="text-green-400")
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
#### Common Value Colors
|
|
214
|
+
|
|
215
|
+
| Color | Class |
|
|
216
|
+
|-------|-------|
|
|
217
|
+
| Green | `text-green-400` |
|
|
218
|
+
| Red | `text-red-400` |
|
|
219
|
+
| Yellow | `text-yellow-400` |
|
|
220
|
+
| Blue | `text-blue-400` |
|
|
221
|
+
| Gray | `text-slate-400` |
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### 5. Data Table
|
|
226
|
+
|
|
227
|
+
A styled data table with row click support.
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
data_table(
|
|
231
|
+
columns: list, # Column definitions
|
|
232
|
+
rows: list, # Row data
|
|
233
|
+
show_header: bool = True,
|
|
234
|
+
style: dict = None,
|
|
235
|
+
class_name: str = "",
|
|
236
|
+
key: str = None
|
|
237
|
+
) -> dict | None # Returns {rowIndex, rowData} on click
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
#### Column Definition
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
columns = [
|
|
244
|
+
{"key": "name", "label": "Name"},
|
|
245
|
+
{"key": "value", "label": "Value", "align": "right", "format": "number"},
|
|
246
|
+
{"key": "percent", "label": "%", "align": "center", "format": "percent"},
|
|
247
|
+
{"key": "status", "label": "Status", "colorByValue": True}
|
|
248
|
+
]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
| Column Key | Type | Description |
|
|
252
|
+
|------------|------|-------------|
|
|
253
|
+
| `key` | `str` | Data key in row dict |
|
|
254
|
+
| `label` | `str` | Column header text |
|
|
255
|
+
| `align` | `str` | `"left"`, `"center"`, `"right"` |
|
|
256
|
+
| `format` | `str` | `"number"` (adds commas), `"percent"` (adds %) |
|
|
257
|
+
| `colorByValue` | `bool` | Color based on status values |
|
|
258
|
+
|
|
259
|
+
#### Auto-Colored Values
|
|
260
|
+
|
|
261
|
+
When `colorByValue: True`, these values get automatic colors:
|
|
262
|
+
|
|
263
|
+
| Value | Color |
|
|
264
|
+
|-------|-------|
|
|
265
|
+
| `"above"` | Red |
|
|
266
|
+
| `"below"` | Yellow |
|
|
267
|
+
| `"within"` | Green |
|
|
268
|
+
| `"approved"` | Green |
|
|
269
|
+
| `"rejected"` | Red |
|
|
270
|
+
| `"submitted"` | Yellow |
|
|
271
|
+
| `"draft"` | Gray |
|
|
272
|
+
|
|
273
|
+
#### Example
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
columns = [
|
|
277
|
+
{"key": "site", "label": "Site"},
|
|
278
|
+
{"key": "line", "label": "Line"},
|
|
279
|
+
{"key": "util", "label": "Utilization", "align": "right", "format": "percent"},
|
|
280
|
+
{"key": "volume", "label": "Volume", "align": "right", "format": "number"},
|
|
281
|
+
{"key": "status", "label": "Status", "align": "center", "colorByValue": True}
|
|
282
|
+
]
|
|
283
|
+
|
|
284
|
+
rows = [
|
|
285
|
+
{"site": "AML_14", "line": "L1", "util": 94, "volume": 125000, "status": "above"},
|
|
286
|
+
{"site": "ADL", "line": "L2", "util": 72, "volume": 98000, "status": "within"},
|
|
287
|
+
{"site": "Devens", "line": "L3", "util": 58, "volume": 45000, "status": "below"}
|
|
288
|
+
]
|
|
289
|
+
|
|
290
|
+
clicked = data_table(columns=columns, rows=rows)
|
|
291
|
+
|
|
292
|
+
if clicked:
|
|
293
|
+
st.write(f"Selected row {clicked['rowIndex']}: {clicked['rowData']}")
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
### 6. Step Indicator
|
|
299
|
+
|
|
300
|
+
A multi-step wizard progress indicator.
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
step_indicator(
|
|
304
|
+
steps: list, # List of step labels
|
|
305
|
+
current_step: int, # Current step (1-indexed)
|
|
306
|
+
style: dict = None,
|
|
307
|
+
class_name: str = "",
|
|
308
|
+
key: str = None
|
|
309
|
+
) -> int | None # Returns clicked step number
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### Example
|
|
313
|
+
|
|
314
|
+
```python
|
|
315
|
+
if "step" not in st.session_state:
|
|
316
|
+
st.session_state.step = 1
|
|
317
|
+
|
|
318
|
+
clicked = step_indicator(
|
|
319
|
+
steps=["Supply Plan", "Configure Levers", "Review & Submit"],
|
|
320
|
+
current_step=st.session_state.step
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
if clicked:
|
|
324
|
+
st.session_state.step = clicked
|
|
325
|
+
st.rerun()
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
#### Visual States
|
|
329
|
+
|
|
330
|
+
| State | Appearance |
|
|
331
|
+
|-------|------------|
|
|
332
|
+
| Completed (< current) | Green circle with ✓ |
|
|
333
|
+
| Current | Blue circle with number |
|
|
334
|
+
| Future (> current) | Gray circle with number |
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### 7. Button Group
|
|
339
|
+
|
|
340
|
+
A group of action buttons.
|
|
341
|
+
|
|
342
|
+
```python
|
|
343
|
+
button_group(
|
|
344
|
+
buttons: list, # List of button configs
|
|
345
|
+
style: dict = None,
|
|
346
|
+
class_name: str = "",
|
|
347
|
+
key: str = None
|
|
348
|
+
) -> str | None # Returns clicked button ID
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### Button Definition
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
buttons = [
|
|
355
|
+
{"id": "view", "icon": "👁️"},
|
|
356
|
+
{"id": "edit", "icon": "✏️", "label": "Edit"},
|
|
357
|
+
{"id": "approve", "icon": "✓", "color": "green"},
|
|
358
|
+
{"id": "reject", "icon": "✕", "color": "red", "disabled": True}
|
|
359
|
+
]
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
| Button Key | Type | Description |
|
|
363
|
+
|------------|------|-------------|
|
|
364
|
+
| `id` | `str` | Unique identifier (returned on click) |
|
|
365
|
+
| `label` | `str` | Button text (optional) |
|
|
366
|
+
| `icon` | `str` | Emoji/icon (optional) |
|
|
367
|
+
| `color` | `str` | `"blue"`, `"green"`, `"red"`, `"yellow"`, `"purple"`, `"slate"` |
|
|
368
|
+
| `disabled` | `bool` | Disable the button |
|
|
369
|
+
|
|
370
|
+
#### Example
|
|
371
|
+
|
|
372
|
+
```python
|
|
373
|
+
clicked = button_group(
|
|
374
|
+
buttons=[
|
|
375
|
+
{"id": "view", "icon": "👁️", "label": "View"},
|
|
376
|
+
{"id": "edit", "icon": "✏️", "label": "Edit"},
|
|
377
|
+
{"id": "delete", "icon": "🗑️", "color": "red"}
|
|
378
|
+
]
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
if clicked == "delete":
|
|
382
|
+
st.warning("Delete clicked!")
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
### 8. Chart Legend
|
|
388
|
+
|
|
389
|
+
A legend for charts with colored indicators.
|
|
390
|
+
|
|
391
|
+
```python
|
|
392
|
+
chart_legend(
|
|
393
|
+
items: list, # List of legend items
|
|
394
|
+
style: dict = None,
|
|
395
|
+
class_name: str = "",
|
|
396
|
+
key: str = None
|
|
397
|
+
) -> None
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
#### Items Format
|
|
401
|
+
|
|
402
|
+
```python
|
|
403
|
+
items = [
|
|
404
|
+
{"color": "#94a3b8", "label": "Historical"},
|
|
405
|
+
{"color": "#ef4444", "label": "Outlier"},
|
|
406
|
+
{"color": "#8b5cf6", "label": "Prophet"},
|
|
407
|
+
{"color": "#10b981", "label": "ARIMA"}
|
|
408
|
+
]
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### Example
|
|
412
|
+
|
|
413
|
+
```python
|
|
414
|
+
# Display a chart (using st.line_chart, plotly, etc.)
|
|
415
|
+
st.line_chart(data)
|
|
416
|
+
|
|
417
|
+
# Add legend below
|
|
418
|
+
chart_legend(
|
|
419
|
+
items=[
|
|
420
|
+
{"color": "#3b82f6", "label": "Actual"},
|
|
421
|
+
{"color": "#ef4444", "label": "Upper Threshold"},
|
|
422
|
+
{"color": "#eab308", "label": "Lower Threshold"},
|
|
423
|
+
{"color": "#8b5cf6", "label": "Forecast"}
|
|
424
|
+
]
|
|
425
|
+
)
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
---
|
|
429
|
+
|
|
430
|
+
### 9. Form Select
|
|
431
|
+
|
|
432
|
+
A styled dropdown select input.
|
|
433
|
+
|
|
434
|
+
```python
|
|
435
|
+
form_select(
|
|
436
|
+
label: str, # Label text
|
|
437
|
+
options: list, # Options list
|
|
438
|
+
value: str = "", # Selected value
|
|
439
|
+
groups: list = None, # Option groups (for optgroup)
|
|
440
|
+
style: dict = None,
|
|
441
|
+
class_name: str = "",
|
|
442
|
+
key: str = None
|
|
443
|
+
) -> str # Returns selected value
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
#### Simple Options
|
|
447
|
+
|
|
448
|
+
```python
|
|
449
|
+
options = ["Option A", "Option B", "Option C"]
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
#### Options with Labels
|
|
453
|
+
|
|
454
|
+
```python
|
|
455
|
+
options = [
|
|
456
|
+
{"value": "a", "label": "Option A"},
|
|
457
|
+
{"value": "b", "label": "Option B"}
|
|
458
|
+
]
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
#### Grouped Options
|
|
462
|
+
|
|
463
|
+
```python
|
|
464
|
+
groups = [
|
|
465
|
+
{"label": "Baselines", "options": ["Baseline v7", "Baseline v6"]},
|
|
466
|
+
{"label": "Scenarios", "options": ["Q2 Demand Surge", "OEE Initiative"]}
|
|
467
|
+
]
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
#### Example
|
|
471
|
+
|
|
472
|
+
```python
|
|
473
|
+
# Simple
|
|
474
|
+
site = form_select(
|
|
475
|
+
label="Site",
|
|
476
|
+
options=["AML_14", "ADL", "Devens"],
|
|
477
|
+
value="AML_14"
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
# With groups
|
|
481
|
+
scenario = form_select(
|
|
482
|
+
label="Base On",
|
|
483
|
+
groups=[
|
|
484
|
+
{"label": "Baselines", "options": ["Baseline v7 (Current)", "Baseline v6"]},
|
|
485
|
+
{"label": "Scenarios", "options": ["Q2 Demand Surge", "OEE Initiative"]}
|
|
486
|
+
],
|
|
487
|
+
class_name="max-w-xs"
|
|
488
|
+
)
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
### 10. Form Slider
|
|
494
|
+
|
|
495
|
+
A styled range slider input.
|
|
496
|
+
|
|
497
|
+
```python
|
|
498
|
+
form_slider(
|
|
499
|
+
label: str, # Label text
|
|
500
|
+
value: float, # Current value
|
|
501
|
+
min_val: float, # Minimum value
|
|
502
|
+
max_val: float, # Maximum value
|
|
503
|
+
step: float = 1, # Step increment
|
|
504
|
+
unit: str = "", # Unit suffix (e.g., "%", "hrs")
|
|
505
|
+
color: str = "blue", # Value display color
|
|
506
|
+
style: dict = None,
|
|
507
|
+
class_name: str = "",
|
|
508
|
+
key: str = None
|
|
509
|
+
) -> float # Returns current value
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
#### Example
|
|
513
|
+
|
|
514
|
+
```python
|
|
515
|
+
# Percentage slider
|
|
516
|
+
threshold = form_slider(
|
|
517
|
+
label="Upper Threshold",
|
|
518
|
+
value=90,
|
|
519
|
+
min_val=75,
|
|
520
|
+
max_val=100,
|
|
521
|
+
unit="%",
|
|
522
|
+
color="red"
|
|
523
|
+
)
|
|
524
|
+
|
|
525
|
+
# Time slider
|
|
526
|
+
hold_time = form_slider(
|
|
527
|
+
label="VPHP Hold Time",
|
|
528
|
+
value=5.0,
|
|
529
|
+
min_val=2.0,
|
|
530
|
+
max_val=8.0,
|
|
531
|
+
step=0.5,
|
|
532
|
+
unit=" hrs",
|
|
533
|
+
color="blue"
|
|
534
|
+
)
|
|
535
|
+
|
|
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"
|
|
544
|
+
)
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
---
|
|
548
|
+
|
|
549
|
+
### 11. Checkbox Group
|
|
550
|
+
|
|
551
|
+
A group of checkboxes.
|
|
552
|
+
|
|
553
|
+
```python
|
|
554
|
+
checkbox_group(
|
|
555
|
+
items: list, # List of checkbox items
|
|
556
|
+
label: str = "", # Optional group label
|
|
557
|
+
style: dict = None,
|
|
558
|
+
class_name: str = "",
|
|
559
|
+
key: str = None
|
|
560
|
+
) -> list # Returns list of checked item IDs
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
#### Items Format
|
|
564
|
+
|
|
565
|
+
```python
|
|
566
|
+
items = [
|
|
567
|
+
{"id": "opt1", "label": "Option 1", "checked": True},
|
|
568
|
+
{"id": "opt2", "label": "Option 2", "checked": True},
|
|
569
|
+
{"id": "opt3", "label": "Option 3"} # checked defaults to False
|
|
570
|
+
]
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
#### Example
|
|
574
|
+
|
|
575
|
+
```python
|
|
576
|
+
selected = checkbox_group(
|
|
577
|
+
label="Parameters to Optimize",
|
|
578
|
+
items=[
|
|
579
|
+
{"id": "vphp", "label": "VPHP Hold Time", "checked": True},
|
|
580
|
+
{"id": "lot_co", "label": "Lot Changeover", "checked": True},
|
|
581
|
+
{"id": "campaign_co", "label": "Campaign Changeover"},
|
|
582
|
+
{"id": "batch", "label": "Batch Size"}
|
|
583
|
+
]
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
st.write(f"Selected parameters: {selected}")
|
|
587
|
+
# Output: ['vphp', 'lot_co']
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
---
|
|
591
|
+
|
|
592
|
+
## Complete Example App
|
|
593
|
+
|
|
594
|
+
```python
|
|
595
|
+
import streamlit as st
|
|
596
|
+
from streamlit_react_components import (
|
|
597
|
+
section_header, stat_card, data_table,
|
|
598
|
+
form_select, form_slider, checkbox_group
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
st.set_page_config(page_title="Dashboard", layout="wide")
|
|
602
|
+
|
|
603
|
+
# Header
|
|
604
|
+
action = section_header(
|
|
605
|
+
title="Production Dashboard",
|
|
606
|
+
icon="🏭",
|
|
607
|
+
actions=[{"id": "refresh", "label": "Refresh", "color": "blue"}]
|
|
608
|
+
)
|
|
609
|
+
|
|
610
|
+
# Stats row
|
|
611
|
+
col1, col2, col3 = st.columns(3)
|
|
612
|
+
with col1:
|
|
613
|
+
stat_card(label="Lines Active", value="12", color="green")
|
|
614
|
+
with col2:
|
|
615
|
+
stat_card(label="At Risk", value="3", color="red")
|
|
616
|
+
with col3:
|
|
617
|
+
stat_card(label="Avg Utilization", value="82%", color="blue")
|
|
618
|
+
|
|
619
|
+
# Filters
|
|
620
|
+
st.markdown("### Filters")
|
|
621
|
+
col1, col2 = st.columns(2)
|
|
622
|
+
with col1:
|
|
623
|
+
site = form_select(label="Site", options=["All", "AML", "ADL", "Devens"])
|
|
624
|
+
with col2:
|
|
625
|
+
threshold = form_slider(label="Risk Threshold", value=90, min_val=80, max_val=100, unit="%")
|
|
626
|
+
|
|
627
|
+
# Data table
|
|
628
|
+
st.markdown("### Lines Overview")
|
|
629
|
+
clicked = data_table(
|
|
630
|
+
columns=[
|
|
631
|
+
{"key": "line", "label": "Line"},
|
|
632
|
+
{"key": "util", "label": "Utilization", "format": "percent", "align": "right"},
|
|
633
|
+
{"key": "status", "label": "Status", "colorByValue": True}
|
|
634
|
+
],
|
|
635
|
+
rows=[
|
|
636
|
+
{"line": "L1", "util": 94, "status": "above"},
|
|
637
|
+
{"line": "L2", "util": 82, "status": "within"},
|
|
638
|
+
{"line": "L3", "util": 65, "status": "below"}
|
|
639
|
+
]
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
if clicked:
|
|
643
|
+
st.info(f"Selected: {clicked['rowData']['line']}")
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
## Tailwind CSS Classes Reference
|
|
649
|
+
|
|
650
|
+
Since components use Tailwind CSS, here are commonly used classes:
|
|
651
|
+
|
|
652
|
+
### Spacing
|
|
653
|
+
- `p-1` to `p-8`: Padding
|
|
654
|
+
- `m-1` to `m-8`: Margin
|
|
655
|
+
- `mt-4`, `mb-4`, `ml-4`, `mr-4`: Directional margin
|
|
656
|
+
|
|
657
|
+
### Layout
|
|
658
|
+
- `w-full`: Full width
|
|
659
|
+
- `max-w-xs`, `max-w-sm`, `max-w-md`: Max width
|
|
660
|
+
- `flex`, `grid`: Display types
|
|
661
|
+
- `gap-2`, `gap-4`: Gap between items
|
|
662
|
+
|
|
663
|
+
### Colors (Dark Theme)
|
|
664
|
+
- `bg-slate-900`, `bg-slate-800`: Backgrounds
|
|
665
|
+
- `text-white`, `text-slate-400`: Text colors
|
|
666
|
+
- `border-slate-700`: Border colors
|
|
667
|
+
|
|
668
|
+
### Effects
|
|
669
|
+
- `rounded`, `rounded-lg`: Border radius
|
|
670
|
+
- `shadow`, `shadow-lg`: Box shadows
|
|
671
|
+
- `opacity-50`: Transparency
|
|
672
|
+
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
## License
|
|
676
|
+
|
|
677
|
+
MIT
|