-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jingting Feng
authored and
Jingting Feng
committed
Feb 8, 2025
1 parent
77905e0
commit ca0e0fd
Showing
10 changed files
with
126 additions
and
485 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
### Basic usage | ||
|
||
```py | ||
import streamlit as st | ||
|
||
import streamlit_shadcn_ui as ui | ||
|
||
ui.checkbox(checked=True, label="I am a Checkbox 1") | ||
ui.checkbox(checked=False, label="I am a Checkbox 2") | ||
ui.checkbox(checked=False, label="I am a Checkbox 3") | ||
st.subheader("Single Choice") | ||
checkbox_options = [ | ||
{"label": "I am a Checkbox 1", "id": "s1", "default_checked": True}, | ||
{"label": "I am a Checkbox 2", "id": "s2", "default_checked": False}, | ||
{"label": "I am a Checkbox 3", "id": "s3", "default_checked": False}, | ||
] | ||
|
||
checkbox_values = [option["default_checked"] for option in checkbox_options] | ||
|
||
checkbox_values[0] = ui.checkbox(mode="single", options=[checkbox_options[0]], key="cb1") | ||
checkbox_values[1] = ui.checkbox(mode="single", options=[checkbox_options[1]], key="cb2") | ||
checkbox_values[2] = ui.checkbox(mode="single", options=[checkbox_options[2]], key="cb3") | ||
|
||
st.markdown(f""" | ||
+ checkbox 1 value: {checkbox_values[0]} | ||
+ checkbox 2 value: {checkbox_values[1]} | ||
+ checkbox 3 value: {checkbox_values[2]} | ||
""") | ||
|
||
st.subheader("Multiple Choices") | ||
checkbox_options_multiple = [ | ||
{"label": "Option A", "id": "m1", "default_checked":False}, | ||
{"label": "Option B", "id": "m2", "default_checked":False}, | ||
{"label": "Option C", "id": "m3", "default_checked":False}, | ||
{"label": "Option D", "id": "m4", "default_checked":False} | ||
] | ||
radio_value_1 = ui.checkbox(mode="multiple", options=checkbox_options_multiple, key="cb4") | ||
st.write("Selected Option:", radio_value_1) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 42 additions & 21 deletions
63
streamlit_shadcn_ui/components/packages/frontend/src/components/streamlit/checkbox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.