Input 28

PreviousNext

A URL input field with a protocol selector dropdown at the start

Docs
shadcn-studiocomponent

Preview

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

import { Input } from '@/registry/new-york/ui/input'
import { Label } from '@/registry/new-york/ui/label'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/registry/new-york/ui/select'

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

  return (
    <div className='w-full max-w-xs space-y-2'>
      <Label htmlFor={id}>Input with start select</Label>
      <div className='flex rounded-md shadow-xs'>
        <Select defaultValue='https://'>
          <SelectTrigger id={id} className='rounded-r-none shadow-none focus-visible:z-1'>
            <SelectValue />
          </SelectTrigger>
          <SelectContent>
            <SelectItem value='https://' className='pr-2 [&_svg]:hidden'>
              https://
            </SelectItem>
            <SelectItem value='http://' className='pr-2 [&_svg]:hidden'>
              http://
            </SelectItem>
            <SelectItem value='ftp://' className='pr-2 [&_svg]:hidden'>
              ftp://
            </SelectItem>
            <SelectItem value='sftp://' className='pr-2 [&_svg]:hidden'>
              sftp://
            </SelectItem>
            <SelectItem value='ws://' className='pr-2 [&_svg]:hidden'>
              ws://
            </SelectItem>
            <SelectItem value='wss://' className='pr-2 [&_svg]:hidden'>
              wss://
            </SelectItem>
          </SelectContent>
        </Select>
        <Input id={id} type='text' placeholder='shadcnstudio.com' className='-ms-px rounded-l-none shadow-none' />
      </div>
    </div>
  )
}

export default InputStartSelectDemo

Installation

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

Usage

import { Input28 } from "@/components/input-28"
<Input28 />