summaryrefslogtreecommitdiffhomepage
path: root/client/web/src/ui/search-input.tsx
blob: 9b99984acc01476db57cef11f41a026a58c5e65e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause

import cx from "classnames"
import React, { forwardRef, InputHTMLAttributes } from "react"
import Search from "src/assets/icons/search.svg?react"

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)}>
      <Search className="absolute text-gray-400 w-[1.25em] h-full ml-2" />
      <input
        type="text"
        className={cx("input pl-9 pr-8", inputClassName)}
        ref={ref}
        {...rest}
      />
    </div>
  )
})
SearchInput.displayName = "SearchInput"
export default SearchInput