Input 37

PreviousNext

Search input field with keyboard shortcut indicator (⌘K) for enhanced UX

Docs
shadcn-studiocomponent

Preview

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

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

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

  return (
    <div className='w-full max-w-xs space-y-2'>
      <Label htmlFor={id}>Search input with &lt;kbd&gt;</Label>
      <div className='relative'>
        <Input
          id={id}
          type='search'
          placeholder='Search...'
          className='peer pr-11 [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none'
        />
        <div className='pointer-events-none absolute inset-y-0 right-0 flex items-center justify-center pr-3 peer-disabled:opacity-50'>
          <kbd className='text-muted-foreground bg-accent inline-flex h-5 max-h-full items-center rounded border px-1 font-[inherit] text-[0.625rem] font-medium'>
            ⌘k
          </kbd>
        </div>
      </div>
    </div>
  )
}

export default InputSearchDemo

Installation

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

Usage

import { Input37 } from "@/components/input-37"
<Input37 />