Skip to Content

Input Group

An input joined with icons, text, buttons or a footer in one bordered field.

import { SearchIcon } from "lucide-react"
import { InputGroup, InputGroupAddon, InputGroupInput } from "@dapplelight/signet-ui/components/input-group"

export function Demo() {
  return (
    <InputGroup className="max-w-sm">
      <InputGroupAddon>
        <SearchIcon />
      </InputGroupAddon>
      <InputGroupInput placeholder="Search invoices" aria-label="Search invoices" />
    </InputGroup>
  )
}

Installation

npm i @dapplelight/signet-ui

Usage

import {
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
} from "@dapplelight/signet-ui/components/input-group"
import { SearchIcon } from "lucide-react"

<InputGroup>
  <InputGroupAddon>
    <SearchIcon />
  </InputGroupAddon>
  <InputGroupInput placeholder="Search" />
</InputGroup>

Examples

Text addons

$
USD
https://
.signet.app
import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from "@dapplelight/signet-ui/components/input-group"

export function Demo() {
  return (
    <div className="grid w-full max-w-sm gap-3">
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>$</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="0.00" inputMode="decimal" aria-label="Amount" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>USD</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
      <InputGroup>
        <InputGroupAddon>
          <InputGroupText>https://</InputGroupText>
        </InputGroupAddon>
        <InputGroupInput placeholder="acme" aria-label="Subdomain" />
        <InputGroupAddon align="inline-end">
          <InputGroupText>.signet.app</InputGroupText>
        </InputGroupAddon>
      </InputGroup>
    </div>
  )
}

Button

import { useState } from "react"
import { EyeIcon, EyeOffIcon } from "lucide-react"
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@dapplelight/signet-ui/components/input-group"

export function Demo() {
  const [show, setShow] = useState(false)
  return (
    <InputGroup className="max-w-sm">
      <InputGroupInput
        type={show ? "text" : "password"}
        defaultValue="hunter2-hunter2"
        aria-label="API secret"
      />
      <InputGroupAddon align="inline-end">
        <InputGroupButton
          size="icon-xs"
          aria-label={show ? "Hide secret" : "Show secret"}
          onClick={() => setShow((s) => !s)}
        >
          {show ? <EyeOffIcon /> : <EyeIcon />}
        </InputGroupButton>
      </InputGroupAddon>
    </InputGroup>
  )
}

Textarea

0 / 280
import { InputGroup, InputGroupAddon, InputGroupText, InputGroupTextarea } from "@dapplelight/signet-ui/components/input-group"

export function Demo() {
  return (
    <InputGroup className="max-w-sm">
      <InputGroupTextarea placeholder="Add a note to this invoice" aria-label="Invoice note" />
      <InputGroupAddon align="block-end">
        <InputGroupText>0 / 280</InputGroupText>
      </InputGroupAddon>
    </InputGroup>
  )
}

API Reference

InputGroup

The bordered wrapper, role="group". Takes div props.

InputGroupAddon

PropTypeDefaultDescription
align"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"Where the addon sits. Block values stack it above or below the control.

Clicking an addon focuses the input.

InputGroupButton

A Button with compact sizes.

PropTypeDefaultDescription
size"xs" | "sm" | "icon-xs" | "icon-sm""xs"Size.
variantButton variants"ghost"Button variant.
type"button" | "submit" | "reset""button"Button type.

InputGroupInput, InputGroupTextarea, InputGroupText

InputGroupInput and InputGroupTextarea take input and textarea props. InputGroupText is a span for static text or an icon.