2023-11-28 13:15:19 -05:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2023-11-15 15:23:15 -05:00
|
|
|
import cx from "classnames"
|
|
|
|
import React, { forwardRef, InputHTMLAttributes } from "react"
|
2024-02-22 13:16:44 -07:00
|
|
|
import Search from "src/assets/icons/search.svg?react"
|
2023-11-15 15:23:15 -05:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
className?: string
|
|
|
|
inputClassName?: string
|
|
|
|
} & InputHTMLAttributes<HTMLInputElement>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SearchInput is a standard input with a search icon.
|
|
|
|
*/
|
|
|
|
const SearchInput = forwardRef<HTMLInputElement, Props>((props, ref) => {
|
|
|
|
const { className, inputClassName, ...rest } = props
|
|
|
|
return (
|
|
|
|
<div className={cx("relative", className)}>
|
2023-12-06 16:11:00 -05:00
|
|
|
<Search className="absolute text-gray-400 w-[1.25em] h-full ml-2" />
|
2023-11-15 15:23:15 -05:00
|
|
|
<input
|
|
|
|
type="text"
|
2023-12-06 16:11:00 -05:00
|
|
|
className={cx("input pl-9 pr-8", inputClassName)}
|
2023-11-15 15:23:15 -05:00
|
|
|
ref={ref}
|
|
|
|
{...rest}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
})
|
|
|
|
SearchInput.displayName = "SearchInput"
|
|
|
|
export default SearchInput
|