A customized Streamlit toggle switch component with customizable labels, colors, and border radius
Project description
streamlit_toggle_switch_diy
Creates a toggle switch with color and placement customizations, and you can change the label's color and radius.
Function
- Customize label background color
- Customize the background color near the button
- Custom rounded corners
- Support multiple layout methods
Installation
pip install streamlit-toggle-switch-diy
Usage
import streamlit as st
import streamlit_toggle_diy as tog
tog.st_toggle_switch(
key=None,
label_start="111",
label_end="",
justify='flex-start',
default_value=False,
inactive_color='#D3D3D3',
active_color="#11567f",
track_color="#29B5E8",
label_bg_color_start=None,
label_bg_color_end=None,
background_color_near_button_start=None,
background_color_near_button_end=None,
border_radius=None,
)
Parameter
| Parameter Name | Type | Description |
|---|---|---|
label |
str |
The main label of the component, used to identify the function of the switch. |
key |
str |
The unique identifier for each component instance. Used to distinguish different component instances in the Streamlit application. |
default_value |
bool |
The initial state of the toggle switch.Trueindicates on,Falseindicates off. |
label_start |
str |
The text content of the label before the switch. If a preceding label is not needed, an empty string""can be passed. |
label_end |
str |
The text content of the label after the switch. If a following label is not needed, an empty string""can be passed. |
justify |
str |
Controls the alignment of labels and switches within the container. Optional values include'flex-start'(left-aligned),'center'(center-aligned),'flex-end'(right-aligned). |
inactive_color |
str |
The color of the slider when the switch is inactive (off). |
active_color |
str |
The color of the slider when the switch is active (on). |
track_color |
str |
The color of the switch track (background). |
label_bg_color_start |
str |
The starting value of the label background color, used to create a gradient effect. |
label_bg_color_end |
str |
The ending value of the label background color, used to create a gradient effect. |
background_color_near_button_start |
str |
The starting value of the background color near the switch, used to create a gradient effect. |
background_color_near_button_end |
str |
The ending value of the background color near the switch, used to create a gradient effect. |
border_radius |
str |
The border radius value of the component, such as'4px','8px','50%', etc. |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_toggle_switch_diy-1.0.5.tar.gz.
File metadata
- Download URL: streamlit_toggle_switch_diy-1.0.5.tar.gz
- Upload date:
- Size: 709.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0222f02686407e624c2ffa9d34507c3f6ba29f5fb251bce30f72e054ab2cba2d
|
|
| MD5 |
55a503d98b7a035ad207584808b98c21
|
|
| BLAKE2b-256 |
6f1e914db483e5b2514c84aa130d534f629f5a73be15c8c0a4d23c789aff37b6
|
File details
Details for the file streamlit_toggle_switch_diy-1.0.5-py3-none-any.whl.
File metadata
- Download URL: streamlit_toggle_switch_diy-1.0.5-py3-none-any.whl
- Upload date:
- Size: 718.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad70711a4ce4e5e18acf1c9c5a285cc323f35b9cf8a41586760a0d21ba23fd3c
|
|
| MD5 |
812c9ade04ac591349a81cf753bfa279
|
|
| BLAKE2b-256 |
dbb31ed90b2aa0ac84c467ecf9903037d2d4fb08ed01d07cbd5761d315da894e
|