Button

En/ Ru

Button

Действие по клику или навигация при заданном Href.

github.com/fastygo/templ/ui

Кнопка запускает действие по клику. При заданном Href рендерится как ссылка.

Основная

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

templ Example() {
	@ui.Button(ui.ButtonProps{Variant: "default"}) {
		Основная
	}
}

Деструктивная

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

templ Example() {
	@ui.Button(ui.ButtonProps{Variant: "destructive"}) {
		Удалить
	}
}

Ссылка

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

templ Example() {
	@ui.Button(ui.ButtonProps{Variant: "link", Href: "/docs"}) {
		Подробнее
	}
}

Отправка формы

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

templ Example() {
	@ui.Button(ui.ButtonProps{Type: "submit"}) {
		Отправить
	}
}

Неактивная

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

templ Example() {
	@ui.Button(ui.ButtonProps{Disabled: true}) {
		Недоступно
	}
}

API

Variant · string — default | secondary | destructive | outline | ghost | link | unstyled

Size · string — default | sm | lg | icon

Type · string — button | submit | reset

Href · string — URL для ссылки вместо button

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