Skip to main content

Starwind UI v3.0 is now available! Migration guide

Input Group

Installation

Usage

---
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
} from "@/components/starwind/input-group";
import Search from "@tabler/icons/outline/search.svg";
---
<InputGroup>
<InputGroupInput aria-label="Search" placeholder="Search..." />
<InputGroupAddon>
<Search />
</InputGroupAddon>
</InputGroup>

Composition

Combine an input or textarea with the supporting parts you need:

InputGroup
├── InputGroupInput or InputGroupTextarea
└── InputGroupAddon
├── InputGroupButton
└── InputGroupText

Control and Addon Order

InputGroupText and InputGroupButton are helper components for metadata and actions. Addons are presentational; associate a field with an external Label or an aria-label on the control.

Keep InputGroupAddon after InputGroupInput or InputGroupTextarea in the DOM. Use align to control visual placement.

Alignment

inline-start

Use align="inline-start" to place content at the start of the field. This is the default alignment.

inline-end

Use align="inline-end" to place content at the end of the field.

block-start

Use align="block-start" to place a header row above the control.

Full Name
script.js

block-end

Use align="block-end" to place a footer row below the control.

USD
0/280

Examples

Icon

Text

$
USD
https://
.com
@company.com
120 characters left

Button

https://

Kbd

Ctrl+K

Spinner

Saving…

Textarea

Line 1, Column 1

script.js

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Input Group Addon

Inherits div attributes.

Contains the following additional props:

Prop Type Default Toggle details
align "inline-start" | "inline-end" | "block-start" | "block-end" "inline-start"
Description
Aligns the component within its available axis.
Classification
Styled variant

Input Group Button

Inherits Button props. Omits `size`.

Contains the following additional props:

Prop Type Default Toggle details
size "sm" | "icon-sm" "sm"
Description
Selects the component's visual size.
Classification
Styled variant

Changelog

View version history v1.2.0 7 releases

v1.2.0

  • In Astro, an attribute that you set on InputGroup and its parts now wins over the component’s own default for the same attribute, such as role or aria-label.
  • In Astro, InputGroupTextarea now shows defaultValue and value as the text in the field. A form reset puts this text back.
  • In Vue, v-model now works on InputGroupTextarea, and it keeps its value after a form reset. In Svelte, InputGroupTextarea keeps your value after a form reset.
  • In Svelte, a defined value that you pass when InputGroupInput mounts now stays under your control, as in React and Vue. To change it, use bind: or update your state in the change callback. A form reset keeps it. If you pass undefined at mount, InputGroupInput keeps its own state.

v1.1.3

  • Internal maintenance. No change to how the component behaves.

v1.1.2

  • The default export in index.ts now has a name, InputGroupParts, so framework tools show a clear name.

v1.1.1

  • In Astro, a data-slot that you set on InputGroup now replaces its default data-slot, as it does in React.

v1.1.0

  • The component is now available for React as well as Astro. Its props and styles stay the same.
  • InputGroupAddon is now for display only. It no longer focuses the control when you click it. Give the control its own accessible name, and use InputGroupButton when the addon itself does an action.

v1.0.1

  • The Tailwind variants now live in their own variants.ts file in the component folder.

v1.0.0

  • Initial release with starwind v1.16.0