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!")