Input Group
InputGroupInput または InputGroupTextarea に、前後の addon、補足テキスト、button を組み合わせます。root の focus-within 状態により、group 全体に一貫した focus 表現を適用します。
@neumorphism-ui/input-groupプレビュー
https://
インストール
インストール: input-group
npx shadcn@latest add @neumorphism-ui/input-groupCLI が npm 依存関係、base token、utils、コンポーネントソースを順番に処理します。
この Registry を初めて使う場合は、先に namespace の設定 を完了してください。
使い方
使い方: インストール
npx shadcn@latest add @neumorphism-ui/input-group @neumorphism-ui/labelImport
Input Group の import コード
import {
InputGroup,
InputGroupAddon,
InputGroupButton,
InputGroupInput,
InputGroupText,
} from "@/components/ui/input-group"
import { Label } from "@/components/ui/label"Example
Input Group の使用コード
<div className="grid gap-2">
<Label htmlFor="workspace">ワークスペース</Label>
<InputGroup>
<InputGroupAddon aria-hidden="true"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round"><circle cx="11" cy="11" r="7" /><path d="m20 20-4-4" /></svg></InputGroupAddon>
<InputGroupInput id="workspace" defaultValue="soft-interface" />
<InputGroupButton type="button">検索</InputGroupButton>
</InputGroup>
</div>API リファレンス
| コンポーネント | プロパティ | 型 | デフォルト | 説明 |
|---|---|---|---|---|
InputGroup | children必須 | React.ReactNode | — | control、addon、text、button を順番に配置します。 |
InputGroup | aria-label / aria-labelledby | string | — | 必要に応じて role=group 全体にアクセシブルな名前を指定します。 |
InputGroupInput | native input props | React.ComponentProps<"input"> | — | id、name、type、value、onChange などの native 属性です。 |
InputGroupTextarea | native textarea props | React.ComponentProps<"textarea"> | — | 複数行 control の native 属性です。 |
InputGroupButton | type | "button" | "submit" | "reset" | "button" | group action に使用する button type です。 |
アクセシビリティ
- 01
root の role=group は input 自体の名前にはならないため、control を Label と直接関連付けてください。
- 02
装飾だけの addon は aria-hidden=true で隠し、意味のある単位や prefix は支援技術から利用できる状態にしてください。
- 03
アイコンのみの InputGroupButton には aria-label を指定してください。