スタートガイド
インストール手順と、このプラグインの完全なMarkdownガイドを含むセットアッププロンプトをコピーします。
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-sheets`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/sheets/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
インストール
「インストール」セクションAIアシストによるセットアップでプラグインをインストールできます。以下のコマンドを使用して、お使いのAIツールに Capgo のスキルを追加してください:
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins次に、以下のプロンプトを使用します:
Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-sheets` plugin in my project.手動セットアップを希望する場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム別の手順に従ってください:
-
パッケージをインストール
ターミナル bun add @capgo/capacitor-sheets -
Webコンポーネントを登録する
import '@capgo/capacitor-sheets'; -
セーフエリア用の viewport 設定を追加する
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> -
シートをレンダリングする
<cap-sheet-trigger for="booking-sheet" action="present">Open route</cap-sheet-trigger><cap-sheet id="booking-sheet" detents="18em 32em" content-placement="bottom"><cap-sheet-portal><cap-sheet-view><cap-sheet-backdrop></cap-sheet-backdrop><cap-sheet-content class="route-sheet"><cap-sheet-bleeding-background></cap-sheet-bleeding-background><cap-sheet-handle></cap-sheet-handle><cap-sheet-title>Evening route</cap-sheet-title><cap-sheet-description>Choose a route and confirm pickup.</cap-sheet-description><cap-sheet-trigger action="dismiss">Done</cap-sheet-trigger></cap-sheet-content></cap-sheet-view></cap-sheet-portal></cap-sheet>.route-sheet {width: min(100%, 34em);padding: 0 1.25em 1.25em;}
よくある落とし穴
「よくある落とし穴」セクション- コンポーネントを登録: import
@capgo/capacitor-sheetsをブートストラップ時に一度だけ行ってください。そうしないと要素はアップグレードされません。 - ビューポートフィット:未設定
viewport-fit=coverノッチ付きスマホでセーフエリアのpaddingが壊れます。 - キーボード:入力欄がボトムシート内にある場合、ドキュメントに記載されているフォーカス時のスクロール防止を有効にします。
Capacitor 安全領域
セクション「Capacitor セーフエリア」セーフエリアはデフォルトで有効化されています safe-area="auto"。シートビューポートは、ブラウザ環境の値とCapacitorのフォールバック変数の両方を参照します:
env(safe-area-inset-top)env(safe-area-inset-bottom)env(safe-area-inset-left)env(safe-area-inset-right)var(--safe-area-inset-top)var(--safe-area-inset-bottom)var(--safe-area-inset-left)var(--safe-area-inset-right)シートごとに保護するエッジを選択します:
<cap-sheet safe-area="auto"></cap-sheet><cap-sheet safe-area="bottom left right"></cap-sheet><cap-sheet safe-area="none"></cap-sheet>オーバーレイのステータスバーやシステムバーを持つアプリでは、正しいインセット値を公開する責任を持つネイティブプラグインを維持してください:
import type { CapacitorConfig } from '@capacitor/cli';
const config: CapacitorConfig = { plugins: { StatusBar: { overlaysWebView: true, }, Keyboard: { resize: 'body', resizeOnFullScreen: true, }, SystemBars: { insetsHandling: 'css', }, },};
export default config;キーボードの処理は native-focus-scroll-preventionによって制御され、デフォルトでは trueです。アプリ側でキーボード回避を既に実装している場合のみ無効化してください:
<cap-sheet native-focus-scroll-prevention="false"></cap-sheet>命令型コントロール
「Imperative Control」セクションすべてのフレームワークヘルパーは、同じ基盤となるカスタム要素を設定します。シートを直接制御することもできます:
const sheet = document.querySelector('cap-sheet');
await sheet?.present();await sheet?.stepTo(2);await sheet?.step('down');await sheet?.dismiss();状態管理、分析、または連携アニメーションのためにイベントを監視します:
sheet?.addEventListener('cap-sheet-presented-change', (event) => { console.log(event.detail.presented);});
sheet?.addEventListener('cap-sheet-active-detent-change', (event) => { console.log(event.detail.activeDetent);});
sheet?.addEventListener('cap-sheet-travel', (event) => { console.log(event.detail.progress);});React
「React」セクションimport { useEffect, useRef } from 'react';import { setupSheet } from '@capgo/capacitor-sheets/react';import '@capgo/capacitor-sheets';
export function BookingSheet() { const sheetRef = useRef<HTMLElement>(null);
useEffect(() => { if (!sheetRef.current) return;
return setupSheet(sheetRef.current, { detents: ['18em', '32em'], contentPlacement: 'bottom', onPresentedChange: ({ presented }) => console.log({ presented }), }); }, []);
return ( <cap-sheet id="booking-sheet" ref={sheetRef}> <cap-sheet-trigger action="present">Open</cap-sheet-trigger> <cap-sheet-view> <cap-sheet-backdrop /> <cap-sheet-content> <cap-sheet-handle /> <cap-sheet-title>React sheet</cap-sheet-title> </cap-sheet-content> </cap-sheet-view> </cap-sheet> );}インポート元 @capgo/capacitor-sheets/react カスタム要素の JSX 型定義も登録されます。TypeScript が未定義のタグを報告し続ける場合は、ソースツリー内に宣言ファイルを追加してください:
import '@capgo/capacitor-sheets/react';Vue
「Vue」セクション<script setup lang="ts">import { onMounted, onUnmounted, ref } from 'vue';import { setupSheet } from '@capgo/capacitor-sheets/vue';import '@capgo/capacitor-sheets';
const sheetRef = ref<HTMLElement | null>(null);let cleanup: (() => void) | undefined;
onMounted(() => { if (sheetRef.value) { cleanup = setupSheet(sheetRef.value, { detents: ['18em', '32em'], contentPlacement: 'bottom', }); }});
onUnmounted(() => cleanup?.());</script>
<template> <cap-sheet id="booking-sheet" ref="sheetRef"> <cap-sheet-trigger action="present">Open</cap-sheet-trigger> <cap-sheet-view> <cap-sheet-backdrop /> <cap-sheet-content> <cap-sheet-handle /> <cap-sheet-title>Vue sheet</cap-sheet-title> </cap-sheet-content> </cap-sheet-view> </cap-sheet></template>Angular
「Angular」セクションimport { AfterViewInit, Component, CUSTOM_ELEMENTS_SCHEMA, ElementRef, ViewChild } from '@angular/core';import { setupSheet } from '@capgo/capacitor-sheets/angular';import '@capgo/capacitor-sheets';
@Component({ selector: 'app-root', standalone: true, schemas: [CUSTOM_ELEMENTS_SCHEMA], template: ` <cap-sheet id="booking-sheet" #sheet> <cap-sheet-trigger action="present">Open</cap-sheet-trigger> <cap-sheet-view> <cap-sheet-backdrop></cap-sheet-backdrop> <cap-sheet-content> <cap-sheet-handle></cap-sheet-handle> <cap-sheet-title>Angular sheet</cap-sheet-title> </cap-sheet-content> </cap-sheet-view> </cap-sheet> `,})export class AppComponent implements AfterViewInit { @ViewChild('sheet', { static: true }) sheet?: ElementRef<HTMLElement>;
ngAfterViewInit(): void { if (this.sheet?.nativeElement) { setupSheet(this.sheet.nativeElement, { detents: ['18em', '32em'], contentPlacement: 'bottom', }); } }}Svelte
「Svelte」セクション<script lang="ts"> import { sheet } from '@capgo/capacitor-sheets/svelte'; import '@capgo/capacitor-sheets';</script>
<cap-sheet id="booking-sheet" use:sheet={{ detents: ['18em', '32em'], contentPlacement: 'bottom' }}> <cap-sheet-trigger action="present">Open</cap-sheet-trigger> <cap-sheet-view> <cap-sheet-backdrop /> <cap-sheet-content> <cap-sheet-handle /> <cap-sheet-title>Svelte sheet</cap-sheet-title> </cap-sheet-content> </cap-sheet-view></cap-sheet>Solid
「Solid」セクションimport { onCleanup, onMount } from 'solid-js';import { setupSheet } from '@capgo/capacitor-sheets/solid';import '@capgo/capacitor-sheets';
export function BookingSheet() { let sheetEl!: HTMLElement;
onMount(() => { const cleanup = setupSheet(sheetEl, { detents: ['18em', '32em'], contentPlacement: 'bottom', });
onCleanup(cleanup); });
return ( <cap-sheet id="booking-sheet" ref={sheetEl}> <cap-sheet-trigger action="present">Open</cap-sheet-trigger> <cap-sheet-view> <cap-sheet-backdrop /> <cap-sheet-content> <cap-sheet-handle /> <cap-sheet-title>Solid sheet</cap-sheet-title> </cap-sheet-content> </cap-sheet-view> </cap-sheet> );}コンポーネント
「Components」セクション| 要素 | 目的 |
|---|---|
cap-sheet | シートの状態、デテント、ジェスチャー、モーダル動作、イベント |
cap-sheet-trigger | 宣言的な present、dismiss、toggle、step アクション |
cap-sheet-portal | オーバーレイのレイヤリング用の任意のボディポータル |
cap-sheet-view | セーフエリアとキーボードパディング付きの固定ビューポートホスト |
cap-sheet-backdrop | 進捗に同期したバックドロップ |
cap-sheet-content | アクセシブルなシートサーフェス |
cap-sheet-bleeding-background | 角丸エッジのシート用背景拡張 |
cap-sheet-handle | ドラッグ可能でキーボード操作可能なデテントハンドル |
cap-sheet-title | アクセシブルなタイトル |
cap-sheet-description | アクセシブルな説明 |
cap-sheet-special-wrapper | デタッチドシート、カード、ライトボックス用のコンポジションフック |
cap-sheet-stack | スタックされたシートのグループ化 |
cap-sheet-outlet | 深度、パララックス、ページエフェクト用の進捗アウトレット |
cap-scroll | スクロール進捗ヘルパー |
cap-fixed | 固定レイヤーヘルパー |
cap-island | 関連するフローティングアイランドコンテンツ |
cap-external-overlay | シートツリー外で管理されるオーバーレイコンテンツ |
主なオプション
「Main Options」セクション| オプション | 属性 | デフォルト | 説明 |
|---|---|---|---|
contentPlacement | content-placement | bottom | top, bottom, left, right、または center |
detents | detents | なし | スペース区切りのCSS長さ(例: 18em 32em |
safeArea | safe-area | auto | 保護されたセーフエリアの端 |
swipe | swipe | true | ポインター、タッチ、トラックパッド、ホイールジェスチャーを有効化 |
swipeDismissal | swipe-dismissal | true | ジェスチャーでデテントまで閉じることを許可 0 |
inertOutside | inert-outside | true | モーダルシートの背後での操作を防止 |
focusTrap | focus-trap | true | キーボードフォーカスをシート内に保持 |
closeOnOutsideClick | close-on-outside-click | true | バックドロップまたはビューをクリックして閉じる |
closeOnEscape | close-on-escape | true | Escapeキーを押して閉じる |
nativeFocusScrollPrevention | native-focus-scroll-prevention | true | フォーカスされた入力欄をキーボードの上に表示し続ける |
themeColorDimming | theme-color-dimming | auto | モーダル表示時にWebViewのテーマカラーを暗くする |
利用可能なエントリポイント
「利用可能なエントリポイント」セクション@capgo/capacitor-sheets@capgo/capacitor-sheets/react@capgo/capacitor-sheets/vue@capgo/capacitor-sheets/angular@capgo/capacitor-sheets/svelte@capgo/capacitor-sheets/solid
Getting Startedの続きを進める
「Getting Started からの続き」セクション使用している場合 スタートガイド ネイティブプラグインの作業を計画するには、次と連携してください: Capgo プラグインディレクトリ Capgo プラグインディレクトリのプロダクトワークフローについては、 Capgo による Capacitor プラグイン Capgo による Capacitor プラグインの実装詳細については、 プラグインの追加または更新 プラグインの追加または更新に関する実装詳細については、 Ionic Enterprise プラグインの代替案 Ionic Enterprise Plugin Alternatives のプロダクトワークフロー、および Capgo Native Build Capgo Native Builds のプロダクトワークフローについては、