About
A small square icon button meant to sit inside a text field's own box, for actions like showing/hiding a password, clearing a search field, or copying a value.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Input Button to your project and fits it to your theme.
Code
How Input Button is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import * as React from "react";
import InputButton from "@/components/ui/input-button";
import { Cancel01Icon } from "@hugeicons/core-free-icons";
export default function InputButtonClearDemo() {
const [value, setValue] = React.useState("Book of Optics");
const inputRef = React.useRef<HTMLInputElement>(null);
const id = React.useId();
function clear() {
setValue("");
inputRef.current?.focus();
}
return (
<div className="flex min-h-[260px] w-full items-center justify-center p-8">
<div className="ib-demo-field">
<label htmlFor={id}>Search the catalog</label>
<div className="ib-demo-control">
<input
id={id}
ref={inputRef}
type="search"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Title or author"
autoComplete="off"
/>
<span className="ib-demo-addon">
<span
className={["ib-demo-clear", value && "ib-demo-shown"]
.filter(Boolean)
.join(" ")}
>
<InputButton
icon={Cancel01Icon}
aria-label="Clear search"
tabIndex={value ? 0 : -1}
onClick={clear}
/>
</span>
</span>
</div>
</div>
</div>
);
}
















