Skip to content

Commit

Permalink
fix: checkbox defualt checked now working
Browse files Browse the repository at this point in the history
  • Loading branch information
ObservedObserver committed Nov 30, 2023
1 parent ab59549 commit 360b496
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "streamlit-shadcn-ui"
version = "0.1.16"
version = "0.1.17"
readme = "README.md"
keywords = ["streamlit", "shadcn", "ui", "components"]
description = "Using shadcn components in Streamlit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { Streamlit } from "streamlit-component-lib";

interface StSwitchProps {
label?: string;
checked?: boolean;
defaultChecked?: boolean;
}
export const StSwitch = forwardRef<HTMLDivElement, StSwitchProps>(
(props: StSwitchProps, ref) => {
const { label, checked } = props;
const [checkedStatus, setCheckedStatus] = useState(checked);
useEffect(() => {
setCheckedStatus(checked);
}, [checked]);
const { label, defaultChecked } = props;
const [checkedStatus, setCheckedStatus] = useState(defaultChecked);

return (
<div ref={ref} className="flex items-center space-x-2 m-1">
<Switch
Expand Down
2 changes: 1 addition & 1 deletion streamlit_shadcn_ui/py_components/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
_component_func = declare_component("checkbox")

def checkbox(default_checked=False, label=None, key=None):
props = {"default_checked": default_checked, "label": label}
props = {"defaultChecked": default_checked, "label": label}
component_value = _component_func(comp="checkbox", props=props, key=key, default=default_checked)
return component_value
2 changes: 1 addition & 1 deletion streamlit_shadcn_ui/py_components/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def switch(default_checked=False, label=None, key=None):
props = {
"default_checked": default_checked,
"defaultChecked": default_checked,
"label": label
}
component_value = _component_func(comp="switch", props=props, key=key, default=default_checked)
Expand Down

0 comments on commit 360b496

Please sign in to comment.