checkbox

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package checkbox implements checkbox fields.

templ: version: v0.2.793

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func C

func C(def D) templ.Component

Types

type D

type D struct {
	// ID is the input id (Name if not set).
	ID string
	// Name is the input name.
	Name string
	// Label is the input label (either a string, a label.D or a templ.Component).
	//playground:edit:input
	Label any
	// Value is the input value.
	Value   string
	Checked bool
	// Disabled disables the input.
	Disabled bool
	// CustomStyle defines a custom style.
	// 	style.Custom{
	// 		"checkbox":       style.D{style.Add("...")},
	// 		"checkbox/input": style.D{style.Add("...")},
	// 		"checkbox/label": style.D{style.Add("...")},
	//	}
	CustomStyle style.Custom
	Attributes  templ.Attributes
}

D is the definition for checkbox fields.

Example
package main

import (
	"context"
	"os"

	"github.com/jfbus/templui/components/checkbox"
	"github.com/jfbus/templui/components/style"
	"github.com/jfbus/templui/skin"
)

func main() {
	style.SetSkin(skin.Default)
	c := checkbox.C(checkbox.D{
		Name:  "accept",
		Label: "Title",
	})
	_ = c.Render(context.TODO(), os.Stdout)
}
Output:
<div class="flex items-center"><input type="checkbox" id="accept" name="accept" class="ms-2 w-4 h-4 focus:ring-2 rounded text-blue-600 bg-gray-100 border-gray-300 focus:ring-blue-500 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600"><label for="accept" class="ms-2 text-sm font-medium" :class="hasError(&#39;&#39;) &amp;&amp; &#39;text-red-700 dark:text-red-500&#39;">Title</label></div>

Jump to

Keyboard shortcuts

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