> ## Documentation Index
> Fetch the complete documentation index at: https://auth0.generaltranslation.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ACUL とカスタムコンポーネントライブラリの統合方法を学ぶ

# カスタムコンポーネントライブラリを統合する

<Card title="開始する前に">
  次のものが必要です:

  * Auth0 開発用テナント（[Universal Login](/docs/ja-JP/authenticate/login/auth0-universal-login) と [カスタムドメイン](/docs/ja-JP/customize/custom-domains) を設定済み）。
  * Auth0 の [First Party Application](/docs/ja-JP/get-started/auth0-overview/create-applications#create-applications)。
  * Auth0 テナントで [Identifier First Authentication](/docs/ja-JP/authenticate/login/auth0-universal-login/identifier-first) を有効化していること。
  * [Node.js](http://Node.js) V22+
  * [Auth0 CLI ツール](https://github.com/auth0/auth0-cli)（[既存のテナントに対して認証済み](https://github.com/auth0/auth0-cli?tab=readme-ov-file#authenticating-to-your-tenant)であること）。
  * [ACUL クイックスタートガイド](/docs/ja-JP/customize/login-pages/advanced-customizations/quickstart)に目を通しておくこと。
</Card>

ACUL を使用すると、お好みのコンポーネントライブラリを使って Universal Login のプロンプト画面をカスタマイズできます。次の例では、再利用可能なコンポーネントライブラリである [Shadcn](https://ui.shadcn.com/docs) と Auth0 の `login-passwordless-email-code` 画面を使用します。この例では、デフォルトの One-Time Password（OTP）用入力フィールドを、Shadcn の [InputOTP](https://ui.shadcn.com/docs/components/input-otp) コンポーネントに置き換えます。

1. Auth0 CLI ツールを使用して ACUL プロジェクトを作成します。

```bash theme={null}
auth0 acul init <Your-App-Name>
```

`login-passwordless-email-code` 画面を選択します。

2. 画面の変更を編集・確認できるように、ACUL のローカル開発サーバーを起動します。

```bash theme={null}
auth0 acul dev
```

3. プロジェクトのルートで Shadcn を初期化します。

```bash theme={null}
npx shadcn-ui@latest init
```

4. CLI のプロンプトに従って、プロジェクト用の設定を格納する `components.json` ファイルと、`src/lib/utils.ts` ファイルを作成します。

5. コンポーネントファイルを `src/components/ui/input-otp.tsx` に追加します。

```bash theme={null}
npx shadcn-ui@latest add input-otp
```

6. コンポーネントを組み込みます:
   a. `src/screens/login-passwordless-email-code/components/IdentifierForm.tsx` に移動し、ファイルを開きます。
   b. InputOTP コンポーネントをインポートし、既存の入力フィールドを置き換えます。OTP コードの state を管理し、適切なソフトウェア開発キット (SDK) のフックを使用します。

```bash theme={null}
// In IdentifierForm.tsx
import { useState } from 'react';
import { useEmailOtpChallenge } from '@auth0/auth0-acul-react'; 
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
} from '@/components/ui/input-otp'; // Import from ShadCN

// ... inside your component
const { submit } = useEmailOtpChallenge(); 
const [otp, setOtp] = useState('');

const handleSubmit = (e) => {
  e.preventDefault();
  submit({ code: otp }); // コードを指定して submit メソッドを呼び出す
};

return (
  <form onSubmit={handleSubmit}>
    {/* ... other UI elements ... */}
    <InputOTP maxLength={6} value={otp} onChange={setOtp}>
      <InputOTPGroup>
        <InputOTPSlot index={0} />
        <InputOTPSlot index={1} />
        <InputOTPSlot index={2} />
        <InputOTPSlot index={3} />
        <InputOTPSlot index={4} />
        <InputOTPSlot index={5} />
      </InputOTPGroup>
    </InputOTP>
    <Button type="submit">Verify Code</Button>
  </form>
);
```

7. ACUL Context Inspector を使用して画面をローカルで実行し、新しいコンポーネントを確認します。

```bash theme={null}
auth0 acul dev -s  login-passwordless-email-code
```

8. ローカルの開発環境をテストテナントに接続し、新しい画面を実際の認証フローで試します:

```bash theme={null}
auth0 acul dev --connected --screen login-passwordless-email-code
```

9. 画面の指示に従ってローカルアセットをビルドし、ローカル開発サーバーを起動し、テナント上の ACUL 設定を更新します。

10. パスワードレス認証フローをテストします。

```bash theme={null}
auth0 test login
```
