Switch

En/ Ru

Switch

Toggle с ARIA role switch и aria-checked.

github.com/fastygo/templ/ui

Switch рендерит toggle с ARIA-семантикой switch. aria-checked отражает prop Checked при рендере.

Выключен

import "github.com/fastygo/templ/ui"

templ Example() {
	@ui.Switch(ui.SwitchProps{
		Name:      "notifications",
		ID:        "notifications",
		AriaLabel: "Уведомления",
	})
}

Включён

import "github.com/fastygo/templ/ui"

templ Example() {
	@ui.Switch(ui.SwitchProps{
		Name:      "notifications",
		ID:        "notifications",
		Checked:   true,
		AriaLabel: "Уведомления",
	})
}

Неактивный

import "github.com/fastygo/templ/ui"

templ Example() {
	@ui.Switch(ui.SwitchProps{
		Name:      "locked",
		Disabled:  true,
		Checked:   true,
		AriaLabel: "Заблокированная настройка",
	})
}

API

Name · string — Имя поля формы

Checked · bool — Включённое состояние

Disabled · bool — Неактивное состояние

AriaLabel · string — Доступное имя переключателя