shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Button

Displays a button or a component that looks like a button.

package examples import (

Installation

shadcn-templ add button

Usage

import "github.com/axadrn/shadcn-templ/v2/components/button"
@button.Button(button.Props{Variant: button.VariantOutline}) {	Button}

Cursor

Tailwind v4 switched from cursor: pointer to cursor: default for the button component.

If you want to keep the cursor: pointer behavior, add the following code to your CSS file:

globals.css
@layer base {  button:not(:disabled),  [role="button"]:not(:disabled) {    cursor: pointer;  }}

Size

Use the Size prop to change the size of the button.

package examples import (

Default

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

Outline

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

Secondary

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

Ghost

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

Destructive

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"
package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

Icon

package examples import (

With Icon

Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the icon for the correct spacing.

package examples import (

Rounded

Use the rounded-full class to make the button rounded.

package examples import (

Spinner

Render a spinner component inside the button to show a loading state. Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the spinner for the correct spacing.

package examples import (

Button Group

To create a button group, use the buttongroup component. See the Button Group documentation for more details.

package examples import (

Set the Href prop to render the button as a semantic link that looks like a button.

package examples import "github.com/axadrn/shadcn-templ/v2/components/button"

API Reference

Button

The Button component is a wrapper around the button element that adds a variety of styles and functionality.

Prop Type Default
Variant VariantDefault | VariantSecondary | VariantOutline | VariantGhost | VariantDestructive | VariantLink VariantDefault
Size SizeDefault | SizeXs | SizeSm | SizeLg | SizeIcon | SizeIconXs | SizeIconSm | SizeIconLg SizeDefault
Type TypeButton | TypeSubmit | TypeReset TypeButton
Href string -
Target string -
Disabled bool false
Form string -
Class string -