Skip to content

Input Group

Download .md

An input group attaches an icon, text or a small button to an input, inside one border.

  • Search: a search icon before the input.
  • Password: a button after the input that shows or hides the password. This is the Sosialoka password field; there is no separate password component.
  • Units and prefixes: text such as Rp or .id before or after the value.
  • Don’t put the main action of a form inside the group; it goes in the form footer.
React
Vue
123
  1. 1Leading icon
  2. 2Input
  3. 3Attached button
  1. Group (InputGroup): one input border on radius-md, h-9 tall. Focus on the input rings the whole group.
  2. Addon (InputGroupAddon): an icon, text or button, at inline-start (before) or inline-end (after).
  3. Control (InputGroupInput or InputGroupTextarea): the field itself, without its own border.
Addon position Use it for
inline-start A search icon, a currency such as Rp.
inline-end The show-password button, a unit, a clear button.
block-start / block-end A label or actions above or below an InputGroupTextarea.
React Vue Flutter Type Default Use
InputGroupAddon align InputGroupAddon align leading / trailing on ShadInput inline-start, inline-end, block-start, block-end inline-start Where the addon sits.
InputGroupButton size InputGroupButton size ShadIconButton in trailing xs, sm, icon-xs, icon-sm xs A small button inside the group.
type on InputGroupInput type on InputGroupInput obscureText text text password hides the text; search makes a search field.
import { useId, useState } from "react"
import { EyeIcon, EyeOffIcon, SearchIcon } from "lucide-react"
import { Field, FieldLabel } from "@/components/ui/field"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@/components/ui/input-group"
export default function InputGroupDemo() {
const id = useId()
const [visible, setVisible] = useState(false)
return (
<div className="grid w-full max-w-sm gap-6">
<InputGroup>
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<InputGroupInput type="search" placeholder="Cari rilis" aria-label="Cari rilis" />
</InputGroup>
<Field>
<FieldLabel htmlFor={`${id}-password`}>Kata sandi</FieldLabel>
<InputGroup>
<InputGroupInput id={`${id}-password`} type={visible ? "text" : "password"} autoComplete="current-password" />
<InputGroupAddon align="inline-end">
<InputGroupButton
size="icon-xs"
aria-label={visible ? "Sembunyikan kata sandi" : "Tampilkan kata sandi"}
aria-pressed={visible}
onClick={() => setVisible((v) => !v)}
>
{visible ? <EyeOffIcon /> : <EyeIcon />}
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</Field>
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/input-group.json
  • The input keeps its own label: a visible label in a Field, or an aria-label such as “Cari rilis” for a search field with only an icon.
  • The show-password button says what it does: aria-label “Tampilkan kata sandi” / “Sembunyikan kata sandi”, with aria-pressed while the password shows.
  • Icons in addons are decorative and need no label.