コンポーネント詳細

Switch

Toggle-style boolean switch control

サンプル

参照情報

テンプレート
templates/components/switch.html
ゴールデン
testdata/golden/switch.golden.html

Go(Marionette)サンプル

この実装例は Go の Marionette を使っています。ソース: docs/site-astro/public/examples/go/switch.go

package goexamples

import (
	mb "github.com/YoshihideShirai/marionette/backend"
	mf "github.com/YoshihideShirai/marionette/frontend"
)

func RegisterSwitchExample(app *mb.App) {
	app.Page("/switch", func(ctx *mb.Context) mf.Node {
		return mf.Switch(mf.SwitchComponentProps{
			Name:    "notifications",
			Value:   "enabled",
			Label:   "Enable notifications",
			Checked: true,
		})
	})
}