Swap
Clicky clicky
Class Reference Basic
Fundamental swap patterns using checkbox controls
Label(
# <!-- this hidden checkbox controls the state -->
Input(type='checkbox'),
Div('ON', cls='swap-on'),
Div('OFF', cls='swap-off'),
cls='swap'
)
Auto-import documentation coming soon...
Label(
# <!-- this hidden checkbox controls the state -->
Input(type='checkbox'),
# <!-- volume on icon -->
Icon.volume_on(cls="swap-on"),
# <!-- volume off icon -->
Icon.volume_off(cls="swap-off"),
cls='swap'
)
Auto-import documentation coming soon...
Advanced
Complex swap patterns and alternative activation methods
Label(
Input(type='checkbox'),
Div('😈', cls='swap-on'),
Div('😇', cls='swap-off'),
cls='swap swap-flip text-9xl'
)
Auto-import documentation coming soon...
Div(
Label(
Div('🥵', cls='swap-on'),
Div('🥶', cls='swap-off'),
cls='swap text-6xl js-swap-demo'
),
Label(
Div('🥳', cls='swap-on'),
Div('😭', cls='swap-off'),
cls='swap text-6xl js-swap-demo'
),
Script("""
// Auto toggle every second for all demo elements
const elements = document.querySelectorAll('.js-swap-demo');
setInterval(() => {
elements.forEach(el => {
el.classList.toggle('swap-active');
});
}, 1000);
""")
)
Auto-import documentation coming soon...
Class Reference
Class | Type | Description |
---|---|---|
swap | Component | Base container for swap elements |
swap-on | Part | Visible when active |
swap-off | Part | Visible when inactive |
swap-indeterminate | Part | Visible when indeterminate |
swap-active | Modifier | Force active state |
swap-rotate | Style | Add rotation effect |
swap-flip | Style | Add flip effect |
Do you have a question? ask the community
Do you see a bug? open an issue on GitHub
LLMs Context: Full Markdown | This Component