Ship faster with goilerplate templUI Pro

Switch

Two-state button that can be switched on or off. Requires an alias import.

Source Tailwind CSS

Receive emails about new products, features, and more.

Installation

templui add switch

Since switch is a reserved Go keyword, use an alias import:

import switchcomp "your-project/components/switch"

Examples

Form

Manage your devices connectivity options.

Please configure your connectivity settings.

API Reference

Required parameter
Hover for description

Switch

Two-state button component that can be switched on or off.

Name Type Default
ID

Unique identifier for the switch element.

string
-
Class

Additional CSS classes to apply to the switch.

string
-
Attributes

Additional HTML attributes to apply to the switch element.

templ.Attributes
-
Name

Name attribute for form submission.

string
-
Value

Value sent when the switch is checked.

string
on
Checked

Whether the switch is initially checked.

bool
false
Disabled

Whether the switch is disabled and non-interactive.

bool
false