Then to activate the default light theme, you can wrap your component with the light theme, inside your index.tsx file for example so your component renders correctly :
import React from "react"
import ReactDOM from "react-dom"
import CustomSlider from "./CustomSlider"
// Lots of import to define a Styletron engine and load the light theme of baseui
import {Client as Styletron} from 'styletron-engine-atomic';
import {Provider as StyletronProvider} from 'styletron-react';
import {ThemeProvider, LightTheme} from 'baseui';
const engine = new Styletron();
// Wrap your CustomCheckbox with the baseui them
ReactDOM.render(
<React.StrictMode>
<StyletronProvider value={engine}>
<ThemeProvider theme={LightTheme}>
<CustomCheckbox/>
</ThemeProvider>
</StyletronProvider>
</React.StrictMode>,
document.getElementById("root")
)
Hi, thanks for your experiment. It looks very cool. I’m not sure it’s still relevant to you, however rewriting onChange as follows seems like it’s doing the trick (at least, in my case)
However, I can’t seem to display the toggle in my app.
I pasted all the files from your github and I’ve added the code below:
import streamlit as st
from streamlit_toggle import st_toggleswitch
awesomeness_enabled = st_toggleswitch("Enable awesomeness", key = 1 )
if awesomeness_enabled:
st.write("Awesomeness has been enabled!")
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.