Switch
The toggle: sliding thumb, accent when on, animated on the shared clock.
A rounded track with a sliding thumb. Clicking flips Value; the thumb
animates on the shared animation clock so every toggle in an app moves identically.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add switch
Usage
var notify lotusui.Switch
notify.Layout(th, gtx)
if notify.Value { /* … */ }
Sizes
All seven shared Size presets.
sw.Size = lotusui.Size2XS // … through lotusui.Size2XL
Disabled
On and off, both facts — dimmed, unclickable.
included.Value, included.Disabled = true, true
Invalid
mustEnable.Invalid = true
Choice card
Settings rows — title, caption, switch at the end — inside a Card: pure composition.
lotusui.Card(th, lotusui.CardOpts{}, lotusui.VStack(th.Space.MD,
settingRow(&marketing, "Marketing emails", "Receive emails about new products and more."),
lotusui.Hairline(th),
settingRow(&security, "Security emails", "Receive emails about your account security."),
))
API
| Option | Type | Description |
|---|---|---|
Value | bool | The state; clicking flips it. |
Size | Size | The shared size presets (Size2XS–Size2XL). |
Invalid | bool | Danger chrome. |
Disabled | bool | Dimmed, unclickable. |