Create a checkbox component with consistent ID based on label.
(label: str, default: bool = False, size: float = 1.0, component_id: str | None = None, **kwargs)
| 171 | |
| 172 | @with_render_tracking("checkbox") |
| 173 | def checkbox(label: str, default: bool = False, size: float = 1.0, component_id: str | None = None, **kwargs) -> ComponentReturn: |
| 174 | """Create a checkbox component with consistent ID based on label.""" |
| 175 | service = PreswaldService.get_instance() |
| 176 | |
| 177 | # Get current state or use default |
| 178 | current_value = service.get_component_state(component_id) |
| 179 | if current_value is None: |
| 180 | current_value = default |
| 181 | |
| 182 | logger.debug(f"Creating checkbox component with id {component_id}, label: {label}") |
| 183 | component = { |
| 184 | "type": "checkbox", |
| 185 | "id": component_id, |
| 186 | "label": label, |
| 187 | "value": current_value, |
| 188 | "size": size, |
| 189 | } |
| 190 | |
| 191 | return ComponentReturn(current_value, component) |
| 192 | |
| 193 | |
| 194 | # def fastplotlib(fig: "fplt.Figure", size: float = 1.0) -> str: |
no test coverage detected