switcher

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package switcher provides a shadcn/ui-style switch with a label, from the Switch of MyGo. The package is named switcher because switch is a Go keyword.

switcher.Switch(c, switcher.Props{
	On:    &dark,
	Label: "Dark mode",
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Switch

func Switch(c *ui.Context, p Props) ui.Element

Switch draws a row with the switch and its label, and returns it. The switch itself is clickable; the label is not.

Types

type Props

type Props struct {
	// On is the bool the switch toggles.
	On *bool
	// Label is the text beside the switch. It also names the switch for
	// tests: Click("Dark mode") toggles it.
	Label string
	// Disabled keeps the switch from being toggled.
	Disabled bool
	// Changed reports the new On, when the user toggled the switch.
	Changed func(on bool)
}

Props describes the switch to draw.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL