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

Input Group

Display additional information or actions to an input or textarea.

12 results
package examples import (

Installation

shadcn-templ add input-group

Usage

import "github.com/axadrn/shadcn-templ/v2/components/inputgroup"
@inputgroup.InputGroup() {	@inputgroup.Input(inputgroup.InputProps{Placeholder: "Search..."})	@inputgroup.Addon() {		@icon.Search()	}}

Composition

Use the following composition to build an InputGroup:

inputgroup.InputGroup├── inputgroup.Input or inputgroup.Textarea├── inputgroup.Addon├── inputgroup.Button└── inputgroup.Text

Align

Use the Align prop on inputgroup.Addon to position the addon relative to the input.

For proper focus management, inputgroup.Addon should always be placed after inputgroup.Input or inputgroup.Textarea in the DOM. Use the Align prop to visually position the addon.

inline-start

Use Align: inputgroup.AlignInlineStart to position the addon at the start of the input. This is the default.

Icon positioned at the start.

package examples import (

inline-end

Use Align: inputgroup.AlignInlineEnd to position the addon at the end of the input.

Icon positioned at the end.

package examples import (

block-start

Use Align: inputgroup.AlignBlockStart to position the addon above the input.

Full Name

Header positioned above the input.

script.js

Header positioned above the textarea.

package examples import (

block-end

Use Align: inputgroup.AlignBlockEnd to position the addon below the input.

USD

Footer positioned below the input.

0/280

Footer positioned below the textarea.

package examples import (

Icon

package examples import (

Text

$
USD
https://
.com
@company.com
120 characters left
package examples import "github.com/axadrn/shadcn-templ/v2/components/inputgroup"

Button

https://
package examples import (

Kbd

⌘K
package examples import (
package examples import (

Spinner

Saving...
Please wait...
package examples import (

Textarea

Line 1, Column 1
script.js
package examples import (

Custom Input

Add the data-slot="input-group-control" attribute to your custom input for automatic focus state handling.

Here’s an example of a custom resizable textarea.

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

API Reference

InputGroup

The main component that wraps inputs and addons.

Prop Type Default
Class string -
@inputgroup.InputGroup() {	@inputgroup.Input()	@inputgroup.Addon()}

InputGroupAddon

Displays icons, text, buttons, or other content alongside inputs.

For proper focus navigation, the inputgroup.Addon component should be placed after the input. Set the Align prop to position the addon.

Prop Type Default
Align AlignInlineStart | AlignInlineEnd | AlignBlockStart | AlignBlockEnd AlignInlineStart
Class string -
@inputgroup.Addon(inputgroup.AddonProps{Align: inputgroup.AlignInlineEnd}) {	@icon.Search()}

For inputgroup.Input, use the inline-start or inline-end alignment. For inputgroup.Textarea, use the block-start or block-end alignment.

The inputgroup.Addon component can have multiple inputgroup.Button components and icons.

@inputgroup.Addon() {	@inputgroup.Button() {		Button	}	@inputgroup.Button() {		Button	}}

InputGroupButton

Displays buttons within input groups.

Prop Type Default
Size ButtonSizeXs | ButtonSizeSm | ButtonSizeIconXs | ButtonSizeIconSm ButtonSizeXs
Variant button.Variant VariantGhost
Type button.Type TypeButton
Disabled bool false
Class string -
@inputgroup.Button() {	Button}@inputgroup.Button(inputgroup.ButtonProps{Size: inputgroup.ButtonSizeIconXs, Attributes: templ.Attributes{"aria-label": "Copy"}}) {	@icon.Copy()}

InputGroupInput

Replacement for input.Input when building input groups. This component has the input group styles pre-applied and uses the unified data-slot="input-group-control" for focus state handling.

Prop Type Default
Placeholder string -
Value string -
Class string -
@inputgroup.InputGroup() {	@inputgroup.Input(inputgroup.InputProps{Placeholder: "Enter text..."})	@inputgroup.Addon() {		@icon.Search()	}}

InputGroupTextarea

Replacement for textarea.Textarea when building input groups. This component has the textarea group styles pre-applied and uses the unified data-slot="input-group-control" for focus state handling.

Prop Type Default
Placeholder string -
Class string -
@inputgroup.InputGroup() {	@inputgroup.Textarea(inputgroup.TextareaProps{Placeholder: "Enter message..."})	@inputgroup.Addon(inputgroup.AddonProps{Align: inputgroup.AlignBlockEnd}) {		@inputgroup.Button() {			Send		}	}}

InputGroupText

The inputgroup.Text component displays muted text inside the group.

Prop Type Default
Class string -