Input Group
Add addons, buttons, and helper content to inputs.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
InputGroup,
InputGroupAddon,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupDemo() {
return (
<InputGroup class="max-w-xs">
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 text-muted-foreground"
>
<path d="m21 21-4.34-4.34" />
<circle cx="11" cy="11" r="8" />
</svg>
</InputGroupAddon>
<InputGroupAddon align="inline-end">12 results</InputGroupAddon>
</InputGroup>
)
}Installation
Install the required Solid UI dependencies:
Copy and paste the following code into your project.
import { type ComponentProps, type JSX } from "@solidjs/web"
import { cva, type VariantProps } from "class-variance-authority"
import { omit } from "solid-js"
import { cn } from "~/lib/utils"
import { Button, type ButtonProps } from "~/components/ui/button"
import { Input } from "~/components/ui/input"
import { Textarea } from "~/components/ui/textarea"
type InputGroupProps = ComponentProps<"div">
const InputGroup = (props: InputGroupProps) => (
<div
data-slot="input-group"
role="group"
{...props}
class={cn(
"h-8 rounded-lg border border-input transition-colors in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-ui=input-group-control]:focus-visible]:border-ring has-[[data-ui=input-group-control]:focus-visible]:ring-3 has-[[data-ui=input-group-control]:focus-visible]:ring-ring/50 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 group/input-group relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto",
props.class
)}
/>
)
const inputGroupAddonVariants = cva(
"h-auto gap-2 py-1.5 text-sm font-medium text-muted-foreground group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",
{
variants: {
align: {
"inline-start": "pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first",
"inline-end": "pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last",
"block-start":
"px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start",
"block-end":
"px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start"
}
},
defaultVariants: {
align: "inline-start"
}
}
)
type InputGroupAddonProps = ComponentProps<"div"> &
VariantProps<typeof inputGroupAddonVariants>
const handleInputGroupAddonClick: JSX.EventHandler<
HTMLDivElement,
MouseEvent
> = (event) => {
if ((event.target as HTMLElement).closest("button")) {
return
}
event.currentTarget.parentElement?.querySelector("input")?.focus()
}
const InputGroupAddon = (props: InputGroupAddonProps) => {
const others = omit(props, "class", "align")
const align = () => props.align ?? "inline-start"
return (
<div
role="group"
data-slot="input-group-addon"
data-align={align()}
class={cn(inputGroupAddonVariants({ align: align() }), props.class)}
onClick={handleInputGroupAddonClick}
{...others}
/>
)
}
const inputGroupButtonVariants = cva(
"gap-2 text-sm flex items-center shadow-none",
{
variants: {
size: {
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
sm: "",
"icon-xs": "size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0",
"icon-sm": "size-8 p-0 has-[>svg]:p-0"
}
},
defaultVariants: {
size: "xs"
}
}
)
type InputGroupButtonProps = Omit<ButtonProps, "size"> &
VariantProps<typeof inputGroupButtonVariants> & {
type?: "button" | "submit" | "reset"
}
const InputGroupButton = (props: InputGroupButtonProps) => {
const others = omit(props, "class", "type", "variant", "size")
const size = () => props.size ?? "xs"
const variant = () => props.variant ?? "ghost"
const type = () => props.type ?? "button"
return (
<Button
type={type()}
data-size={size()}
variant={variant()}
class={cn(inputGroupButtonVariants({ size: size() }), props.class)}
{...others}
/>
)
}
type InputGroupTextProps = ComponentProps<"span">
const InputGroupText = (props: InputGroupTextProps) => (
<span
{...props}
class={cn(
"gap-2 text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
props.class
)}
/>
)
type InputGroupInputProps = ComponentProps<"input">
const InputGroupInput = (props: InputGroupInputProps) => (
<Input
data-slot="input-group-control"
data-ui="input-group-control"
{...props}
class={cn("rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent flex-1", props.class)}
/>
)
type InputGroupTextareaProps = ComponentProps<"textarea">
const InputGroupTextarea = (props: InputGroupTextareaProps) => (
<Textarea
data-slot="input-group-control"
data-ui="input-group-control"
{...props}
class={cn("rounded-none border-0 bg-transparent py-2 shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent flex-1 resize-none", props.class)}
/>
)
export {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea,
type InputGroupAddonProps,
type InputGroupButtonProps,
type InputGroupInputProps,
type InputGroupProps,
type InputGroupTextareaProps,
type InputGroupTextProps
}Update the import paths to match your project setup.
Usage
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupText
} from "~/components/ui/input-group"<InputGroup>
<InputGroupInput aria-label="Website" placeholder="example.com" />
<InputGroupAddon>
<InputGroupText>https://</InputGroupText>
</InputGroupAddon>
</InputGroup>Composition
Use the following composition to build an InputGroup:
InputGroup
โโโ InputGroupInput / InputGroupTextarea
โโโ InputGroupAddon
โโโ InputGroupText
โโโ InputGroupButton
โโโ Custom contentAlign
Use the align prop on InputGroupAddon to position the addon relative to the control.
For proper focus management, InputGroupAddon should be placed after
InputGroupInput or InputGroupTextarea in the DOM. Use the align prop to
visually position the addon.
inline-start
Use align="inline-start" to position the addon at the start of the input. This is the default.
Icon positioned at the start.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { Field, FieldDescription, FieldLabel } from "~/components/ui/field"
import {
InputGroup,
InputGroupAddon,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupInlineStart() {
return (
<Field class="w-full max-w-sm">
<FieldLabel for="inline-start-input">Input</FieldLabel>
<InputGroup>
<InputGroupInput id="inline-start-input" placeholder="Search..." />
<InputGroupAddon align="inline-start">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 text-muted-foreground"
>
<path d="m21 21-4.34-4.34" />
<circle cx="11" cy="11" r="8" />
</svg>
</InputGroupAddon>
</InputGroup>
<FieldDescription>Icon positioned at the start.</FieldDescription>
</Field>
)
}inline-end
Use align="inline-end" to position the addon at the end of the input.
Icon positioned at the end.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { Field, FieldDescription, FieldLabel } from "~/components/ui/field"
import {
InputGroup,
InputGroupAddon,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupInlineEnd() {
return (
<Field class="w-full max-w-sm">
<FieldLabel for="inline-end-input">Input</FieldLabel>
<InputGroup>
<InputGroupInput
id="inline-end-input"
placeholder="Enter password"
type="password"
/>
<InputGroupAddon align="inline-end">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49" />
<path d="M14.084 14.158a3 3 0 0 1-4.242-4.242" />
<path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143" />
<path d="m2 2 20 20" />
</svg>
</InputGroupAddon>
</InputGroup>
<FieldDescription>Icon positioned at the end.</FieldDescription>
</Field>
)
}block-start
Use align="block-start" to position the addon above the input.
Header positioned above the input.
Header positioned above the textarea.
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel
} from "~/components/ui/field"
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea
} from "~/components/ui/input-group"
export default function InputGroupBlockStart() {
return (
<FieldGroup class="w-full max-w-sm">
<Field>
<FieldLabel for="block-start-input">Input</FieldLabel>
<InputGroup class="h-auto">
<InputGroupInput
id="block-start-input"
placeholder="Enter your name"
/>
<InputGroupAddon align="block-start">
<InputGroupText>Full Name</InputGroupText>
</InputGroupAddon>
</InputGroup>
<FieldDescription>Header positioned above the input.</FieldDescription>
</Field>
<Field>
<FieldLabel for="block-start-textarea">Textarea</FieldLabel>
<InputGroup>
<InputGroupTextarea
class="font-mono text-sm"
id="block-start-textarea"
placeholder="console.log('Hello, world!');"
/>
<InputGroupAddon align="block-start">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 text-muted-foreground"
>
<path d="m16 18 6-6-6-6" />
<path d="m8 6-6 6 6 6" />
</svg>
<InputGroupText class="font-mono">script.js</InputGroupText>
<InputGroupButton aria-label="Copy" class="ml-auto" size="icon-xs">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
</svg>
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
<FieldDescription>
Header positioned above the textarea.
</FieldDescription>
</Field>
</FieldGroup>
)
}block-end
Use align="block-end" to position the addon below the input.
Footer positioned below the input.
Footer positioned below the textarea.
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel
} from "~/components/ui/field"
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
InputGroupTextarea
} from "~/components/ui/input-group"
export default function InputGroupBlockEnd() {
return (
<FieldGroup class="w-full max-w-sm">
<Field>
<FieldLabel for="block-end-input">Input</FieldLabel>
<InputGroup class="h-auto">
<InputGroupInput id="block-end-input" placeholder="Enter amount" />
<InputGroupAddon align="block-end">
<InputGroupText>USD</InputGroupText>
</InputGroupAddon>
</InputGroup>
<FieldDescription>Footer positioned below the input.</FieldDescription>
</Field>
<Field>
<FieldLabel for="block-end-textarea">Textarea</FieldLabel>
<InputGroup>
<InputGroupTextarea
id="block-end-textarea"
placeholder="Write a comment..."
/>
<InputGroupAddon align="block-end">
<InputGroupText>0/280</InputGroupText>
<InputGroupButton class="ml-auto" size="sm" variant="default">
Post
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
<FieldDescription>
Footer positioned below the textarea.
</FieldDescription>
</Field>
</FieldGroup>
)
}Icon
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
InputGroup,
InputGroupAddon,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupIcon() {
return (
<div class="grid w-full max-w-sm gap-6">
<InputGroup>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m21 21-4.34-4.34" />
<circle cx="11" cy="11" r="8" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Enter your email" type="email" />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
<rect x="2" y="4" width="20" height="16" rx="2" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Card number" />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<rect width="20" height="14" x="2" y="5" rx="2" />
<line x1="2" x2="22" y1="10" y2="10" />
</svg>
</InputGroupAddon>
<InputGroupAddon align="inline-end">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M20 6 9 17l-5-5" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Card number" />
<InputGroupAddon align="inline-end">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" />
</svg>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<circle cx="12" cy="12" r="10" />
<path d="M12 16v-4" />
<path d="M12 8h.01" />
</svg>
</InputGroupAddon>
</InputGroup>
</div>
)
}Text
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupText,
InputGroupTextarea
} from "~/components/ui/input-group"
export default function InputGroupTextExample() {
return (
<div class="grid w-full max-w-sm gap-6">
<InputGroup>
<InputGroupAddon>
<InputGroupText>$</InputGroupText>
</InputGroupAddon>
<InputGroupInput placeholder="0.00" />
<InputGroupAddon align="inline-end">
<InputGroupText>USD</InputGroupText>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupAddon>
<InputGroupText>https://</InputGroupText>
</InputGroupAddon>
<InputGroupInput placeholder="example.com" />
<InputGroupAddon align="inline-end">
<InputGroupText>.com</InputGroupText>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Enter your username" />
<InputGroupAddon align="inline-end">
<InputGroupText>@company.com</InputGroupText>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupTextarea placeholder="Enter your message" />
<InputGroupAddon align="block-end">
<InputGroupText class="text-xs text-muted-foreground">
120 characters left
</InputGroupText>
</InputGroupAddon>
</InputGroup>
</div>
)
}Button
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { createSignal } from "solid-js"
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput
} from "~/components/ui/input-group"
import {
Popover,
PopoverContent,
PopoverDescription,
PopoverTitle,
PopoverTrigger
} from "~/components/ui/popover"
export default function InputGroupButtonExample() {
const [isCopied, setIsCopied] = createSignal(false)
const [isFavorite, setIsFavorite] = createSignal(false)
let resetCopyTimeout: ReturnType<typeof setTimeout> | undefined
const handleCopy = async () => {
await navigator.clipboard?.writeText(
"https://github.com/stefan-karger/solid-ui"
)
setIsCopied(true)
if (resetCopyTimeout) {
clearTimeout(resetCopyTimeout)
}
resetCopyTimeout = setTimeout(() => {
setIsCopied(false)
}, 1200)
}
return (
<div class="grid w-full max-w-sm gap-6">
<InputGroup>
<InputGroupInput
placeholder="https://github.com/stefan-karger/solid-ui"
readonly
/>
<InputGroupAddon align="inline-end">
<InputGroupButton
aria-label="Copy"
onClick={handleCopy}
size="icon-xs"
title="Copy"
>
{isCopied() ? (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M20 6 9 17l-5-5" />
</svg>
) : (
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
</svg>
)}
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
<InputGroup class="[--radius:9999px]">
<InputGroupAddon>
<Popover>
<PopoverTrigger
render={(partProps) => (
<InputGroupButton
{...partProps}
size="icon-xs"
variant="secondary"
/>
)}
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<circle cx="12" cy="12" r="10" />
<path d="M12 16v-4" />
<path d="M12 8h.01" />
</svg>
</PopoverTrigger>
<PopoverContent class="rounded-xl text-sm">
<PopoverTitle class="text-sm">
Your connection is not secure.
</PopoverTitle>
<PopoverDescription>
You should not enter any sensitive information on this site.
</PopoverDescription>
</PopoverContent>
</Popover>
</InputGroupAddon>
<InputGroupAddon class="pl-1.5 text-muted-foreground">
https://
</InputGroupAddon>
<InputGroupInput />
<InputGroupAddon align="inline-end">
<InputGroupButton
onClick={() => {
setIsFavorite((value) => !value)
}}
size="icon-xs"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
style={
isFavorite() ? { color: "var(--color-primary)" } : undefined
}
>
<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" />
</svg>
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Type to search..." />
<InputGroupAddon align="inline-end">
<InputGroupButton variant="secondary">Search</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</div>
)
}Kbd
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
InputGroup,
InputGroupAddon,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupKbd() {
return (
<InputGroup class="max-w-sm">
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 text-muted-foreground"
>
<path d="m21 21-4.34-4.34" />
<circle cx="11" cy="11" r="8" />
</svg>
</InputGroupAddon>
<InputGroupAddon align="inline-end">
<kbd class="rounded-md border px-1.5 py-0.5 text-xs text-muted-foreground">
Ctrl
</kbd>
<kbd class="rounded-md border px-1.5 py-0.5 text-xs text-muted-foreground">
K
</kbd>
</InputGroupAddon>
</InputGroup>
)
}Dropdown
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import { createSignal } from "solid-js"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuTrigger
} from "~/components/ui/dropdown-menu"
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput
} from "~/components/ui/input-group"
export default function InputGroupDropdown() {
const [scope, setScope] = createSignal("Documentation")
return (
<div class="grid w-full max-w-sm gap-4">
<InputGroup>
<InputGroupInput placeholder="Enter file name" />
<InputGroupAddon align="inline-end">
<DropdownMenu>
<DropdownMenuTrigger
render={(partProps) => (
<InputGroupButton
{...partProps}
size="icon-xs"
variant="ghost"
/>
)}
aria-label="More"
>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<circle cx="12" cy="12" r="1" />
<circle cx="19" cy="12" r="1" />
<circle cx="5" cy="12" r="1" />
</svg>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuGroup>
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>Copy path</DropdownMenuItem>
<DropdownMenuItem>Open location</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</InputGroupAddon>
</InputGroup>
<InputGroup class="[--radius:1rem]">
<InputGroupInput placeholder="Enter search query" />
<InputGroupAddon align="inline-end">
<DropdownMenu>
<DropdownMenuTrigger
render={(partProps) => (
<InputGroupButton {...partProps} variant="ghost" />
)}
class="pr-1.5 text-xs"
>
{scope()}
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-3"
>
<path d="m6 9 6 6 6-6" />
</svg>
</DropdownMenuTrigger>
<DropdownMenuContent class="[--radius:0.95rem]">
<DropdownMenuGroup>
<DropdownMenuItem onSelect={() => setScope("Documentation")}>
Documentation
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setScope("Blog Posts")}>
Blog Posts
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => setScope("Changelog")}>
Changelog
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</InputGroupAddon>
</InputGroup>
</div>
)
}Spinner
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
InputGroupText
} from "~/components/ui/input-group"
export default function InputGroupSpinner() {
return (
<div class="grid w-full max-w-sm gap-4">
<InputGroup>
<InputGroupInput placeholder="Searching..." />
<InputGroupAddon align="inline-end">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 animate-spin"
>
<path d="M12 2v4" />
<path d="m16.2 7.8 2.9-2.9" />
<path d="M18 12h4" />
<path d="m16.2 16.2 2.9 2.9" />
<path d="M12 18v4" />
<path d="m4.9 19.1 2.9-2.9" />
<path d="M2 12h4" />
<path d="m4.9 4.9 2.9 2.9" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Processing..." />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 animate-spin"
>
<path d="M21 12a9 9 0 1 1-6.219-8.56" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Saving changes..." />
<InputGroupAddon align="inline-end">
<InputGroupText>Saving...</InputGroupText>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 animate-spin"
>
<path d="M12 2v4" />
<path d="m16.2 7.8 2.9-2.9" />
<path d="M18 12h4" />
<path d="m16.2 16.2 2.9 2.9" />
<path d="M12 18v4" />
<path d="m4.9 19.1 2.9-2.9" />
<path d="M2 12h4" />
<path d="m4.9 4.9 2.9 2.9" />
</svg>
</InputGroupAddon>
</InputGroup>
<InputGroup>
<InputGroupInput placeholder="Refreshing data..." />
<InputGroupAddon>
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4 animate-spin"
>
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
<path d="M21 3v5h-5" />
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
<path d="M8 16H3v5" />
</svg>
</InputGroupAddon>
<InputGroupAddon align="inline-end">
<InputGroupText class="text-muted-foreground">
Please wait...
</InputGroupText>
</InputGroupAddon>
</InputGroup>
</div>
)
}Textarea
// Inline SVG icons from Lucide (https://lucide.dev), ISC License, Copyright (c) Lucide Icons and Contributors.
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupText,
InputGroupTextarea
} from "~/components/ui/input-group"
export default function InputGroupTextareaExample() {
return (
<div class="grid w-full max-w-md gap-4">
<InputGroup>
<InputGroupTextarea
class="min-h-[200px]"
id="textarea-code-32"
placeholder="console.log('Hello, world!');"
/>
<InputGroupAddon align="block-end" class="border-t">
<InputGroupText>Line 1, Column 1</InputGroupText>
<InputGroupButton class="ml-auto" size="sm" variant="default">
Run
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M20 4v7a4 4 0 0 1-4 4H4" />
<path d="m9 10-5 5 5 5" />
</svg>
</InputGroupButton>
</InputGroupAddon>
<InputGroupAddon align="block-start" class="border-b">
<InputGroupText class="font-mono font-medium">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="m16 18 6-6-6-6" />
<path d="m8 6-6 6 6 6" />
</svg>
script.js
</InputGroupText>
<InputGroupButton class="ml-auto" size="icon-xs">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" />
<path d="M21 3v5h-5" />
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" />
<path d="M8 16H3v5" />
</svg>
</InputGroupButton>
<InputGroupButton size="icon-xs" variant="ghost">
<svg
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
class="size-4"
>
<rect width="14" height="14" x="8" y="8" rx="2" ry="2" />
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />
</svg>
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</div>
)
}Custom Input
Add data-slot="input-group-control" to a custom input so InputGroup can style its focus state. This example uses a custom textarea.
import {
InputGroup,
InputGroupAddon,
InputGroupButton
} from "~/components/ui/input-group"
export default function InputGroupCustom() {
return (
<div class="grid w-full max-w-sm gap-6">
<InputGroup>
<textarea
class="min-h-16 w-full flex-1 resize-none border-0 bg-transparent px-3 py-2.5 text-sm outline-none placeholder:text-muted-foreground"
data-slot="input-group-control"
placeholder="Autoresize-style custom control..."
rows={3}
/>
<InputGroupAddon align="block-end">
<InputGroupButton class="ml-auto" size="sm" variant="default">
Submit
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</div>
)
}API Reference
InputGroup
The main container that wraps inputs and addons.
<InputGroup>
<InputGroupInput />
<InputGroupAddon />
</InputGroup>InputGroupAddon
Displays icons, text, buttons, or helper content alongside controls.
<InputGroupAddon align="inline-end">
<SearchIcon />
</InputGroupAddon>For <InputGroupInput />, use inline-start or inline-end.
For <InputGroupTextarea />, use block-start or block-end.
InputGroupAddon can render multiple buttons and icons.
<InputGroupAddon>
<InputGroupButton>One</InputGroupButton>
<InputGroupButton>Two</InputGroupButton>
</InputGroupAddon>InputGroupButton
Renders compact button actions inside addons.
<InputGroupButton>Send</InputGroupButton>
<InputGroupButton size="icon-xs" aria-label="Copy">
<CopyIcon />
</InputGroupButton>InputGroupInput
Input variant with data-slot="input-group-control" and input-group styles applied.
All other props are forwarded to the underlying <Input />.
<InputGroup>
<InputGroupInput placeholder="Search..." />
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
</InputGroup>InputGroupTextarea
Textarea variant with data-slot="input-group-control" and input-group styles applied.
All other props are forwarded to the underlying <Textarea />.
<InputGroup>
<InputGroupTextarea placeholder="Enter message..." />
<InputGroupAddon align="block-end">
<InputGroupButton>Send</InputGroupButton>
</InputGroupAddon>
</InputGroup>