Skip to main content

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.

Operation

streamlit.gif

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_toggle_switch_diy-1.0.6.tar.gz (709.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_toggle_switch_diy-1.0.6-py3-none-any.whl (718.4 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_toggle_switch_diy-1.0.6.tar.gz.

File metadata

File hashes

Hashes for streamlit_toggle_switch_diy-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d1f60bfd4bdba0fb238f7d1aee557862f8795b15071086ae342f74276d4fb816
MD5 0c227c23bab0583d24a1e456d08752b9
BLAKE2b-256 01aab1698dbcc7f19b84ce41217b51381c80e33f5ac3931cca08e347df359f0f

See more details on using hashes here.

File details

Details for the file streamlit_toggle_switch_diy-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_toggle_switch_diy-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 55ce2040c868b37878618ef309bc85286c0c5ac855e3dfc8a757e3c0b2a05378
MD5 46e235648fb2836ceaf5c392855c80d7
BLAKE2b-256 1d5dd5d802dd4bdf2f43d60326f59548fc384e8f7f28a330346df1660bfe1bd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page