streamlit-command-palette 0.1.0__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_command_palette-0.1.0/LICENSE +21 -0
- streamlit_command_palette-0.1.0/MANIFEST.in +11 -0
- streamlit_command_palette-0.1.0/PKG-INFO +257 -0
- streamlit_command_palette-0.1.0/README.md +224 -0
- streamlit_command_palette-0.1.0/examples/actions.py +43 -0
- streamlit_command_palette-0.1.0/examples/basic.py +43 -0
- streamlit_command_palette-0.1.0/examples/dataframe.py +53 -0
- streamlit_command_palette-0.1.0/examples/multipage/Home.py +8 -0
- streamlit_command_palette-0.1.0/examples/multipage/pages/1_Analytics.py +8 -0
- streamlit_command_palette-0.1.0/examples/multipage/pages/2_Settings.py +9 -0
- streamlit_command_palette-0.1.0/examples/multipage/palette.py +37 -0
- streamlit_command_palette-0.1.0/pyproject.toml +73 -0
- streamlit_command_palette-0.1.0/setup.cfg +4 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/__init__.py +24 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/_component.py +124 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/_schema.py +397 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/frontend/build/index.js +600 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/frontend/package.json +20 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/frontend/src/index.ts +1023 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/frontend/tsconfig.json +13 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/frontend/vite.config.ts +19 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette/pyproject.toml +7 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette.egg-info/PKG-INFO +257 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette.egg-info/SOURCES.txt +27 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette.egg-info/dependency_links.txt +1 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette.egg-info/requires.txt +8 -0
- streamlit_command_palette-0.1.0/src/streamlit_command_palette.egg-info/top_level.txt +1 -0
- streamlit_command_palette-0.1.0/tests/test_component.py +76 -0
- streamlit_command_palette-0.1.0/tests/test_schema.py +119 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 streamlit-command-palette contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
include src/streamlit_command_palette/frontend/package.json
|
|
4
|
+
include src/streamlit_command_palette/frontend/tsconfig.json
|
|
5
|
+
include src/streamlit_command_palette/frontend/vite.config.ts
|
|
6
|
+
recursive-include src/streamlit_command_palette/frontend/src *.ts
|
|
7
|
+
recursive-include src/streamlit_command_palette/frontend/build *.js
|
|
8
|
+
prune src/streamlit_command_palette/frontend/node_modules
|
|
9
|
+
recursive-include examples *.py
|
|
10
|
+
recursive-include tests *.py
|
|
11
|
+
global-exclude __pycache__ *.py[cod] .DS_Store
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamlit-command-palette
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Cmd/Ctrl-K command palette and global search overlay for Streamlit apps.
|
|
5
|
+
Author: streamlit-command-palette contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/huss22/streamlit-command-palette
|
|
8
|
+
Project-URL: Repository, https://github.com/huss22/streamlit-command-palette
|
|
9
|
+
Project-URL: Issues, https://github.com/huss22/streamlit-command-palette/issues
|
|
10
|
+
Keywords: streamlit,streamlit-component,command-palette,search,custom-component
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Web Environment
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: streamlit>=1.54.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
30
|
+
Requires-Dist: trove-classifiers>=2026.5.7.17; extra == "dev"
|
|
31
|
+
Requires-Dist: twine>=5.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# streamlit-command-palette
|
|
35
|
+
|
|
36
|
+
`streamlit-command-palette` adds a polished Cmd/Ctrl-K command palette and
|
|
37
|
+
global search overlay to Streamlit apps.
|
|
38
|
+
|
|
39
|
+
It is intentionally small for v1: local client-side fuzzy search, grouped
|
|
40
|
+
results, keyboard and mouse selection, and a simple Python API. It does not add
|
|
41
|
+
AI search, database search, auth, or server-side search.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install streamlit-command-palette
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Streamlit Custom Components v2 is required, so the package depends on
|
|
50
|
+
`streamlit>=1.54.0` and Python `>=3.10`.
|
|
51
|
+
|
|
52
|
+
## Quickstart
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
import streamlit as st
|
|
56
|
+
from streamlit_command_palette import action_item, command_palette, page_item
|
|
57
|
+
|
|
58
|
+
items = [
|
|
59
|
+
page_item("home", "Home", subtitle="Overview", target="Home.py"),
|
|
60
|
+
page_item("reports", "Reports", subtitle="Saved reporting views"),
|
|
61
|
+
action_item("refresh", "Refresh data", subtitle="Run the latest query"),
|
|
62
|
+
{
|
|
63
|
+
"id": "docs",
|
|
64
|
+
"title": "Open documentation",
|
|
65
|
+
"subtitle": "Project README and runbook",
|
|
66
|
+
"type": "link",
|
|
67
|
+
"group": "Resources",
|
|
68
|
+
"url": "https://example.com/docs",
|
|
69
|
+
"keywords": ["help", "manual", "reference"],
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
selected = command_palette(items, key="global_palette")
|
|
74
|
+
|
|
75
|
+
if selected:
|
|
76
|
+
st.write("Selected:", selected)
|
|
77
|
+
if selected["id"] == "refresh":
|
|
78
|
+
st.cache_data.clear()
|
|
79
|
+
st.rerun()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The component opens with `Cmd+K` on macOS and `Ctrl+K` elsewhere when using the
|
|
83
|
+
default `shortcut="mod+k"`.
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from streamlit_command_palette import (
|
|
89
|
+
action_item,
|
|
90
|
+
command_palette,
|
|
91
|
+
command_search,
|
|
92
|
+
dataframe_items,
|
|
93
|
+
page_item,
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
command_palette(
|
|
99
|
+
items,
|
|
100
|
+
placeholder="Search...",
|
|
101
|
+
shortcut="mod+k",
|
|
102
|
+
open=False,
|
|
103
|
+
groups=None,
|
|
104
|
+
max_results=10,
|
|
105
|
+
min_query_length=0,
|
|
106
|
+
search_fields=None,
|
|
107
|
+
show_shortcut_hint=True,
|
|
108
|
+
empty_state="No results found",
|
|
109
|
+
key=None,
|
|
110
|
+
height=None,
|
|
111
|
+
theme=None,
|
|
112
|
+
)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`command_palette` returns the selected item dictionary on the Streamlit rerun
|
|
116
|
+
caused by selection, or `None` when nothing was selected.
|
|
117
|
+
|
|
118
|
+
`command_search` remains available as an alias for compatibility.
|
|
119
|
+
|
|
120
|
+
## Item schema
|
|
121
|
+
|
|
122
|
+
Each item supports these fields:
|
|
123
|
+
|
|
124
|
+
| Field | Required | Description |
|
|
125
|
+
| --- | --- | --- |
|
|
126
|
+
| `id` | yes | Stable unique item id. |
|
|
127
|
+
| `title` | yes | Primary result label. |
|
|
128
|
+
| `subtitle` | no | Secondary text below the title. |
|
|
129
|
+
| `type` | no | Item type such as `page`, `action`, `dataframe`, or `link`. |
|
|
130
|
+
| `group` | no | Group heading for grouped results. |
|
|
131
|
+
| `target` | no | JSON-safe value returned to Python for your app logic. |
|
|
132
|
+
| `url` | no | URL metadata returned to Python. |
|
|
133
|
+
| `icon` | no | Short label or icon text. Built-ins: `page`, `action`, `dataframe`, `link`. |
|
|
134
|
+
| `keywords` | no | Extra searchable terms. |
|
|
135
|
+
| `metadata` | no | JSON-safe metadata, also searchable by default. |
|
|
136
|
+
| `disabled` | no | Disabled items are shown but cannot be selected. |
|
|
137
|
+
|
|
138
|
+
## Helpers
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
page_item("analytics", "Analytics", target="pages/1_Analytics.py")
|
|
142
|
+
action_item("clear-cache", "Clear cache", target="clear-cache")
|
|
143
|
+
|
|
144
|
+
items = dataframe_items(
|
|
145
|
+
df,
|
|
146
|
+
id_field="customer_id",
|
|
147
|
+
title_field="customer_name",
|
|
148
|
+
subtitle_fields=["segment", "region"],
|
|
149
|
+
group="Customers",
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Group ordering and labels
|
|
154
|
+
|
|
155
|
+
Pass `groups` to control display order and labels:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
selected = command_palette(
|
|
159
|
+
items,
|
|
160
|
+
groups={
|
|
161
|
+
"Pages": "Pages",
|
|
162
|
+
"Actions": "Actions",
|
|
163
|
+
"Customers": {"title": "Customers"},
|
|
164
|
+
},
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Search fields
|
|
169
|
+
|
|
170
|
+
By default, the frontend searches `title`, `subtitle`, `keywords`, and
|
|
171
|
+
`metadata`. You can override the fields:
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
command_palette(
|
|
175
|
+
items,
|
|
176
|
+
search_fields=["title", "keywords", "metadata.owner"],
|
|
177
|
+
min_query_length=1,
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Theming
|
|
182
|
+
|
|
183
|
+
The component uses Streamlit theme CSS variables automatically. You can pass a
|
|
184
|
+
small override mapping when needed:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
command_palette(
|
|
188
|
+
items,
|
|
189
|
+
theme={
|
|
190
|
+
"primaryColor": "#0f766e",
|
|
191
|
+
"borderColor": "rgba(148, 163, 184, 0.35)",
|
|
192
|
+
},
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Keyboard support
|
|
197
|
+
|
|
198
|
+
The overlay supports:
|
|
199
|
+
|
|
200
|
+
- `Cmd+K` on macOS and `Ctrl+K` elsewhere by default
|
|
201
|
+
- `Escape` to close
|
|
202
|
+
- `Enter` to select
|
|
203
|
+
- `ArrowUp` and `ArrowDown` to move
|
|
204
|
+
- `Home` and `End` to jump
|
|
205
|
+
|
|
206
|
+
## Examples
|
|
207
|
+
|
|
208
|
+
Run any example with Streamlit:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
streamlit run examples/basic.py
|
|
212
|
+
streamlit run examples/actions.py
|
|
213
|
+
streamlit run examples/dataframe.py
|
|
214
|
+
streamlit run examples/multipage/Home.py
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
python -m venv .venv
|
|
221
|
+
source .venv/bin/activate
|
|
222
|
+
pip install -e ".[dev]"
|
|
223
|
+
|
|
224
|
+
cd src/streamlit_command_palette/frontend
|
|
225
|
+
npm install
|
|
226
|
+
npm run build
|
|
227
|
+
|
|
228
|
+
cd ../../../..
|
|
229
|
+
pytest
|
|
230
|
+
python -m build
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The package includes a prebuilt `frontend/build/index.js` asset so users do not
|
|
234
|
+
need Node.js to install or run the component.
|
|
235
|
+
|
|
236
|
+
## Release checklist
|
|
237
|
+
|
|
238
|
+
1. Update the version in the root `pyproject.toml`, package
|
|
239
|
+
`__init__.py`, and component-level `pyproject.toml`.
|
|
240
|
+
2. Build the frontend from `src/streamlit_command_palette/frontend`.
|
|
241
|
+
3. Run `pytest`.
|
|
242
|
+
4. Run `python -m build`.
|
|
243
|
+
5. Run `python -m twine check dist/*`.
|
|
244
|
+
6. Publish from GitHub Actions using the included TestPyPI and PyPI workflows.
|
|
245
|
+
|
|
246
|
+
GitHub Actions workflows are included for pull request CI, manual TestPyPI
|
|
247
|
+
publishing, and PyPI publishing from GitHub releases.
|
|
248
|
+
|
|
249
|
+
## Contributing and security
|
|
250
|
+
|
|
251
|
+
See `CONTRIBUTING.md` for development setup and pull request expectations.
|
|
252
|
+
See `SECURITY.md` for vulnerability reporting.
|
|
253
|
+
See `CODE_OF_CONDUCT.md` for community expectations.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# streamlit-command-palette
|
|
2
|
+
|
|
3
|
+
`streamlit-command-palette` adds a polished Cmd/Ctrl-K command palette and
|
|
4
|
+
global search overlay to Streamlit apps.
|
|
5
|
+
|
|
6
|
+
It is intentionally small for v1: local client-side fuzzy search, grouped
|
|
7
|
+
results, keyboard and mouse selection, and a simple Python API. It does not add
|
|
8
|
+
AI search, database search, auth, or server-side search.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install streamlit-command-palette
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Streamlit Custom Components v2 is required, so the package depends on
|
|
17
|
+
`streamlit>=1.54.0` and Python `>=3.10`.
|
|
18
|
+
|
|
19
|
+
## Quickstart
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
import streamlit as st
|
|
23
|
+
from streamlit_command_palette import action_item, command_palette, page_item
|
|
24
|
+
|
|
25
|
+
items = [
|
|
26
|
+
page_item("home", "Home", subtitle="Overview", target="Home.py"),
|
|
27
|
+
page_item("reports", "Reports", subtitle="Saved reporting views"),
|
|
28
|
+
action_item("refresh", "Refresh data", subtitle="Run the latest query"),
|
|
29
|
+
{
|
|
30
|
+
"id": "docs",
|
|
31
|
+
"title": "Open documentation",
|
|
32
|
+
"subtitle": "Project README and runbook",
|
|
33
|
+
"type": "link",
|
|
34
|
+
"group": "Resources",
|
|
35
|
+
"url": "https://example.com/docs",
|
|
36
|
+
"keywords": ["help", "manual", "reference"],
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
selected = command_palette(items, key="global_palette")
|
|
41
|
+
|
|
42
|
+
if selected:
|
|
43
|
+
st.write("Selected:", selected)
|
|
44
|
+
if selected["id"] == "refresh":
|
|
45
|
+
st.cache_data.clear()
|
|
46
|
+
st.rerun()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The component opens with `Cmd+K` on macOS and `Ctrl+K` elsewhere when using the
|
|
50
|
+
default `shortcut="mod+k"`.
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from streamlit_command_palette import (
|
|
56
|
+
action_item,
|
|
57
|
+
command_palette,
|
|
58
|
+
command_search,
|
|
59
|
+
dataframe_items,
|
|
60
|
+
page_item,
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
command_palette(
|
|
66
|
+
items,
|
|
67
|
+
placeholder="Search...",
|
|
68
|
+
shortcut="mod+k",
|
|
69
|
+
open=False,
|
|
70
|
+
groups=None,
|
|
71
|
+
max_results=10,
|
|
72
|
+
min_query_length=0,
|
|
73
|
+
search_fields=None,
|
|
74
|
+
show_shortcut_hint=True,
|
|
75
|
+
empty_state="No results found",
|
|
76
|
+
key=None,
|
|
77
|
+
height=None,
|
|
78
|
+
theme=None,
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`command_palette` returns the selected item dictionary on the Streamlit rerun
|
|
83
|
+
caused by selection, or `None` when nothing was selected.
|
|
84
|
+
|
|
85
|
+
`command_search` remains available as an alias for compatibility.
|
|
86
|
+
|
|
87
|
+
## Item schema
|
|
88
|
+
|
|
89
|
+
Each item supports these fields:
|
|
90
|
+
|
|
91
|
+
| Field | Required | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `id` | yes | Stable unique item id. |
|
|
94
|
+
| `title` | yes | Primary result label. |
|
|
95
|
+
| `subtitle` | no | Secondary text below the title. |
|
|
96
|
+
| `type` | no | Item type such as `page`, `action`, `dataframe`, or `link`. |
|
|
97
|
+
| `group` | no | Group heading for grouped results. |
|
|
98
|
+
| `target` | no | JSON-safe value returned to Python for your app logic. |
|
|
99
|
+
| `url` | no | URL metadata returned to Python. |
|
|
100
|
+
| `icon` | no | Short label or icon text. Built-ins: `page`, `action`, `dataframe`, `link`. |
|
|
101
|
+
| `keywords` | no | Extra searchable terms. |
|
|
102
|
+
| `metadata` | no | JSON-safe metadata, also searchable by default. |
|
|
103
|
+
| `disabled` | no | Disabled items are shown but cannot be selected. |
|
|
104
|
+
|
|
105
|
+
## Helpers
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
page_item("analytics", "Analytics", target="pages/1_Analytics.py")
|
|
109
|
+
action_item("clear-cache", "Clear cache", target="clear-cache")
|
|
110
|
+
|
|
111
|
+
items = dataframe_items(
|
|
112
|
+
df,
|
|
113
|
+
id_field="customer_id",
|
|
114
|
+
title_field="customer_name",
|
|
115
|
+
subtitle_fields=["segment", "region"],
|
|
116
|
+
group="Customers",
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Group ordering and labels
|
|
121
|
+
|
|
122
|
+
Pass `groups` to control display order and labels:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
selected = command_palette(
|
|
126
|
+
items,
|
|
127
|
+
groups={
|
|
128
|
+
"Pages": "Pages",
|
|
129
|
+
"Actions": "Actions",
|
|
130
|
+
"Customers": {"title": "Customers"},
|
|
131
|
+
},
|
|
132
|
+
)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Search fields
|
|
136
|
+
|
|
137
|
+
By default, the frontend searches `title`, `subtitle`, `keywords`, and
|
|
138
|
+
`metadata`. You can override the fields:
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
command_palette(
|
|
142
|
+
items,
|
|
143
|
+
search_fields=["title", "keywords", "metadata.owner"],
|
|
144
|
+
min_query_length=1,
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Theming
|
|
149
|
+
|
|
150
|
+
The component uses Streamlit theme CSS variables automatically. You can pass a
|
|
151
|
+
small override mapping when needed:
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
command_palette(
|
|
155
|
+
items,
|
|
156
|
+
theme={
|
|
157
|
+
"primaryColor": "#0f766e",
|
|
158
|
+
"borderColor": "rgba(148, 163, 184, 0.35)",
|
|
159
|
+
},
|
|
160
|
+
)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Keyboard support
|
|
164
|
+
|
|
165
|
+
The overlay supports:
|
|
166
|
+
|
|
167
|
+
- `Cmd+K` on macOS and `Ctrl+K` elsewhere by default
|
|
168
|
+
- `Escape` to close
|
|
169
|
+
- `Enter` to select
|
|
170
|
+
- `ArrowUp` and `ArrowDown` to move
|
|
171
|
+
- `Home` and `End` to jump
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
Run any example with Streamlit:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
streamlit run examples/basic.py
|
|
179
|
+
streamlit run examples/actions.py
|
|
180
|
+
streamlit run examples/dataframe.py
|
|
181
|
+
streamlit run examples/multipage/Home.py
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Development
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
python -m venv .venv
|
|
188
|
+
source .venv/bin/activate
|
|
189
|
+
pip install -e ".[dev]"
|
|
190
|
+
|
|
191
|
+
cd src/streamlit_command_palette/frontend
|
|
192
|
+
npm install
|
|
193
|
+
npm run build
|
|
194
|
+
|
|
195
|
+
cd ../../../..
|
|
196
|
+
pytest
|
|
197
|
+
python -m build
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The package includes a prebuilt `frontend/build/index.js` asset so users do not
|
|
201
|
+
need Node.js to install or run the component.
|
|
202
|
+
|
|
203
|
+
## Release checklist
|
|
204
|
+
|
|
205
|
+
1. Update the version in the root `pyproject.toml`, package
|
|
206
|
+
`__init__.py`, and component-level `pyproject.toml`.
|
|
207
|
+
2. Build the frontend from `src/streamlit_command_palette/frontend`.
|
|
208
|
+
3. Run `pytest`.
|
|
209
|
+
4. Run `python -m build`.
|
|
210
|
+
5. Run `python -m twine check dist/*`.
|
|
211
|
+
6. Publish from GitHub Actions using the included TestPyPI and PyPI workflows.
|
|
212
|
+
|
|
213
|
+
GitHub Actions workflows are included for pull request CI, manual TestPyPI
|
|
214
|
+
publishing, and PyPI publishing from GitHub releases.
|
|
215
|
+
|
|
216
|
+
## Contributing and security
|
|
217
|
+
|
|
218
|
+
See `CONTRIBUTING.md` for development setup and pull request expectations.
|
|
219
|
+
See `SECURITY.md` for vulnerability reporting.
|
|
220
|
+
See `CODE_OF_CONDUCT.md` for community expectations.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import streamlit as st
|
|
2
|
+
|
|
3
|
+
from streamlit_command_palette import action_item, command_palette
|
|
4
|
+
|
|
5
|
+
st.set_page_config(page_title="Command Palette Actions", page_icon="K")
|
|
6
|
+
|
|
7
|
+
if "counter" not in st.session_state:
|
|
8
|
+
st.session_state.counter = 0
|
|
9
|
+
if "status" not in st.session_state:
|
|
10
|
+
st.session_state.status = "Ready"
|
|
11
|
+
|
|
12
|
+
items = [
|
|
13
|
+
action_item("increment", "Increment counter", subtitle="Add one to the demo value"),
|
|
14
|
+
action_item("reset", "Reset counter", subtitle="Set the demo value back to zero"),
|
|
15
|
+
action_item(
|
|
16
|
+
"clear-cache",
|
|
17
|
+
"Clear Streamlit cache",
|
|
18
|
+
subtitle="Call st.cache_data.clear",
|
|
19
|
+
),
|
|
20
|
+
action_item(
|
|
21
|
+
"disabled",
|
|
22
|
+
"Disabled action",
|
|
23
|
+
subtitle="This item is visible but cannot be selected",
|
|
24
|
+
disabled=True,
|
|
25
|
+
),
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
selected = command_palette(items, placeholder="Run an action...", key="actions_search")
|
|
29
|
+
|
|
30
|
+
if selected:
|
|
31
|
+
if selected["id"] == "increment":
|
|
32
|
+
st.session_state.counter += 1
|
|
33
|
+
st.session_state.status = "Counter incremented"
|
|
34
|
+
elif selected["id"] == "reset":
|
|
35
|
+
st.session_state.counter = 0
|
|
36
|
+
st.session_state.status = "Counter reset"
|
|
37
|
+
elif selected["id"] == "clear-cache":
|
|
38
|
+
st.cache_data.clear()
|
|
39
|
+
st.session_state.status = "Cache cleared"
|
|
40
|
+
|
|
41
|
+
st.title("Command actions")
|
|
42
|
+
st.metric("Counter", st.session_state.counter)
|
|
43
|
+
st.caption(st.session_state.status)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import streamlit as st
|
|
2
|
+
|
|
3
|
+
from streamlit_command_palette import action_item, command_palette, page_item
|
|
4
|
+
|
|
5
|
+
st.set_page_config(page_title="Command Palette Basic", page_icon="K", layout="wide")
|
|
6
|
+
|
|
7
|
+
st.title("Command palette basic example")
|
|
8
|
+
|
|
9
|
+
items = [
|
|
10
|
+
page_item("home", "Home", subtitle="Dashboard overview", target="home"),
|
|
11
|
+
page_item("reports", "Reports", subtitle="Saved report views", target="reports"),
|
|
12
|
+
page_item(
|
|
13
|
+
"settings",
|
|
14
|
+
"Settings",
|
|
15
|
+
subtitle="Workspace preferences",
|
|
16
|
+
target="settings",
|
|
17
|
+
),
|
|
18
|
+
action_item("refresh", "Refresh data", subtitle="Clear cache and rerun"),
|
|
19
|
+
action_item("download", "Download report", subtitle="Prepare latest CSV export"),
|
|
20
|
+
{
|
|
21
|
+
"id": "docs",
|
|
22
|
+
"title": "Open documentation",
|
|
23
|
+
"subtitle": "README and usage guide",
|
|
24
|
+
"type": "link",
|
|
25
|
+
"group": "Resources",
|
|
26
|
+
"url": "https://example.com/docs",
|
|
27
|
+
"icon": "link",
|
|
28
|
+
"keywords": ["help", "manual", "reference"],
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
selected = command_palette(
|
|
33
|
+
items,
|
|
34
|
+
placeholder="Search pages, actions, and resources...",
|
|
35
|
+
groups=["Pages", "Actions", "Resources"],
|
|
36
|
+
key="basic_command_search",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
if selected:
|
|
40
|
+
st.success(f"Selected {selected['title']} ({selected['id']})")
|
|
41
|
+
st.json(selected)
|
|
42
|
+
|
|
43
|
+
st.info("Use Cmd+K on macOS or Ctrl+K elsewhere.")
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import streamlit as st
|
|
2
|
+
|
|
3
|
+
from streamlit_command_palette import command_palette, dataframe_items
|
|
4
|
+
|
|
5
|
+
st.set_page_config(page_title="Command Palette DataFrame", page_icon="K", layout="wide")
|
|
6
|
+
|
|
7
|
+
rows = [
|
|
8
|
+
{
|
|
9
|
+
"customer_id": "C-1001",
|
|
10
|
+
"customer_name": "Northstar Labs",
|
|
11
|
+
"segment": "Enterprise",
|
|
12
|
+
"region": "North America",
|
|
13
|
+
"owner": "Priya",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"customer_id": "C-1002",
|
|
17
|
+
"customer_name": "Lumen Works",
|
|
18
|
+
"segment": "Mid-market",
|
|
19
|
+
"region": "Europe",
|
|
20
|
+
"owner": "Mateo",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"customer_id": "C-1003",
|
|
24
|
+
"customer_name": "Harbor Analytics",
|
|
25
|
+
"segment": "Startup",
|
|
26
|
+
"region": "Australia",
|
|
27
|
+
"owner": "Ava",
|
|
28
|
+
},
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
items = dataframe_items(
|
|
32
|
+
rows,
|
|
33
|
+
id_field="customer_id",
|
|
34
|
+
title_field="customer_name",
|
|
35
|
+
subtitle_fields=["segment", "region"],
|
|
36
|
+
group="Customers",
|
|
37
|
+
keywords_fields=["customer_name", "segment", "region", "owner"],
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
selected = command_palette(
|
|
41
|
+
items,
|
|
42
|
+
placeholder="Search customers...",
|
|
43
|
+
groups={"Customers": "Customers"},
|
|
44
|
+
search_fields=["title", "subtitle", "keywords", "metadata.owner"],
|
|
45
|
+
key="customer_search",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
st.title("DataFrame search")
|
|
49
|
+
st.dataframe(rows, use_container_width=True)
|
|
50
|
+
|
|
51
|
+
if selected:
|
|
52
|
+
st.subheader("Selected customer")
|
|
53
|
+
st.json(selected)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import streamlit as st
|
|
2
|
+
from palette import render_palette
|
|
3
|
+
|
|
4
|
+
st.set_page_config(page_title="Settings", page_icon="K")
|
|
5
|
+
render_palette()
|
|
6
|
+
|
|
7
|
+
st.title("Settings")
|
|
8
|
+
st.toggle("Enable compact results", value=True)
|
|
9
|
+
st.selectbox("Default group", ["Pages", "Actions", "Customers"])
|