Input 38

PreviousNext

Search input field with search icon and microphone button for voice input

Docs
shadcn-studiocomponent

Preview

Loading preview…
registry/new-york/components/input/input-38.tsx
import { useId } from 'react'

import { MicIcon, SearchIcon } from 'lucide-react'

import { Button } from '@/registry/new-york/ui/button'
import { Input } from '@/registry/new-york/ui/input'
import { Label } from '@/registry/new-york/ui/label'

const InputSearchIconDemo = () => {
  const id = useId()

  return (
    <div className='w-full max-w-xs space-y-2'>
      <Label htmlFor={id}>Search input with icon and button</Label>
      <div className='relative'>
        <div className='text-muted-foreground pointer-events-none absolute inset-y-0 left-0 flex items-center justify-center pl-3 peer-disabled:opacity-50'>
          <SearchIcon className='size-4' />
          <span className='sr-only'>Search</span>
        </div>
        <Input
          id={id}
          type='search'
          placeholder='Search...'
          className='peer px-9 [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none'
        />
        <Button
          variant='ghost'
          size='icon'
          className='text-muted-foreground focus-visible:ring-ring/50 absolute inset-y-0 right-0 rounded-l-none hover:bg-transparent'
        >
          <MicIcon />
          <span className='sr-only'>Press to speak</span>
        </Button>
      </div>
    </div>
  )
}

export default InputSearchIconDemo

Installation

npx shadcn@latest add @shadcn-studio/input-38

Usage

import { Input38 } from "@/components/input-38"
<Input38 />