clear button on input #3274
Replies: 3 comments 2 replies
-
yeah, this is built-in behavior for inputs. type="search" should have an X in the right side by default. Shadcn should not be removing default web behavior like this without a way to add it back. |
Beta Was this translation helpful? Give feedback.
-
how are people doing this now?? |
Beta Was this translation helpful? Give feedback.
-
The button has an The input box has an <div className="relative w-full max-w-sm">
<Input
placeholder="Filter..."
value={globalFilter ?? ''}
onChange={(event) =>
// table.getColumn("email")?.setFilterValue(event.target.value)
setGlobalFilter(String(event.target.value))
}
className="max-w-sm"
/>
<Button
type="button"
variant="ghost"
size="icon"
className="absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100"
onClick={() => {
setGlobalFilter('')
}}
>
<XIcon className="h-4 w-4"/>
<span className="sr-only">Clear</span>
</Button>
</div> |
Beta Was this translation helpful? Give feedback.
-
pretty self explanatory, but it would be nice for a prop to exist to add a clear button for input fields
Beta Was this translation helpful? Give feedback.
All reactions