Caroa UI

Input

テキスト入力フィールドコンポーネント。

インポート

import { Input } from '@caroainc/ui-components'

基本的な使い方

Loading...
<Input placeholder="テキストを入力..." />

タイプ別

Loading...
<Input type="text" placeholder="テキスト" />
<Input type="email" placeholder="メールアドレス" />
<Input type="password" placeholder="パスワード" />
<Input type="number" placeholder="数値" />
<Input type="search" placeholder="検索..." />

無効状態

Loading...
<Input disabled placeholder="無効な入力" />

Labelと組み合わせ

Loading...
<Label htmlFor="email">メールアドレス</Label>
<Input id="email" type="email" placeholder="[email protected]" />

アイコン付き入力

InputGroupコンポーネントを使用してアイコンを追加できます。

Loading...
import { InputGroup, InputGroupAddon, InputGroupInput } from '@caroainc/ui-components/client'
 
<InputGroup>
  <InputGroupAddon align="inline-start">
    <Icon name="Search" size="sm" />
  </InputGroupAddon>
  <InputGroupInput placeholder="検索..." />
</InputGroup>

エラー状態

Loading...
<div className="flex flex-col gap-2">
  <Label htmlFor="email">メールアドレス</Label>
  <Input
    id="email"
    className="border-destructive focus-visible:ring-destructive"
  />
  <p className="text-sm text-destructive">有効なメールアドレスを入力してください</p>
</div>

ボタン付き入力

Loading...
<div className="flex">
  <Input placeholder="メールアドレス" className="rounded-r-none" />
  <Button variant="primary" className="rounded-l-none">購読</Button>
</div>

実際の使用例

検索フォーム

Loading...
<div className="flex gap-2">
  <InputGroup className="flex-1">
    <InputGroupAddon align="inline-start">
      <Icon name="Search" size="sm" />
    </InputGroupAddon>
    <InputGroupInput placeholder="キーワードを入力..." />
  </InputGroup>
  <Button>検索</Button>
</div>

パスワード確認フォーム

Loading...
<div className="space-y-4">
  <div className="space-y-2">
    <Label htmlFor="new-password">新しいパスワード</Label>
    <Input id="new-password" type="password" />
  </div>
  <div className="space-y-2">
    <Label htmlFor="confirm-password">パスワード(確認)</Label>
    <Input id="confirm-password" type="password" />
  </div>
  <Button variant="primary" className="w-full">パスワードを変更</Button>
</div>

Props

PropTypeDefaultDescription
type'text' | 'email' | 'password' | 'number' | 'search' | ...'text'入力タイプ
placeholderstring-プレースホルダーテキスト
disabledbooleanfalse無効状態
classNamestring-追加のCSSクラス

On this page