Getting Started
このプラグインのインストール手順と完全なマークダウンガイドを含むセットアップコマンドをコピーしてください。
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-Assisted セットアップを使用してプラグインをインストールできます。次のコマンドを使用して、Capgo スキルをAIツールに追加します。
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.Manual セットアップを使用する場合は、次のコマンドを実行してプラグインをインストールし、以下のプラットフォーム固有の指示に従ってください。
-
パッケージをインストール
ターミナル画面 npm install @capgo/capacitor-sheets -
ウェブコンポーネントを登録
import '@capgo/capacitor-sheets'; -
安全なエリア用ビューポート設定を追加
<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;}
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>overlay status barsまたはsystem barsを持つアプリの場合、nativeプラグインを使用して正しいInset値を表示する責任を負ってください:
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>セクションのタイトル: “イマペラティブコントロール”
すべてのフレームワークヘルパーは同じ下位互換性のカスタム要素を構成します。シートを直接制御することもできます:__CAPGO_KEEP_0__
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';<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> );}コンポーネント
「コンポーネント」セクション| 要素 | 目的 |
|---|---|
cap-sheet | シートの状態、デンテント、ジェスチャー、モーダル動作、およびイベント |
cap-sheet-trigger | 宣言的プレゼント、閉じる、切り替え、ステップアクション |
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 | Composition hook for detached sheets, cards, and lightboxes |
cap-sheet-stack | カードやライトボックスなどの分離されたシートのグループ化 |
cap-sheet-outlet | 深度、パララックス、ページ効果のための進捗表示 |
cap-scroll | スクロール進捗のヘルパー |
cap-fixed | 固定レイヤーのヘルパー |
cap-island | 関連する浮遊島のコンテンツ |
cap-external-overlay | シートツリー外のオーバーレイコンテンツの管理 |
メインオプション
メインオプション| オプション | 属性 | デフォルト | 説明 |
|---|---|---|---|
contentPlacement | content-placement | bottom | top, bottom, left, right, または center |
detents | detents | none | スペース区切りの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 | エスケープキーを押すと閉じる |
nativeFocusScrollPrevention | native-focus-scroll-prevention | true | キーボードの下でフォーカスされた入力を表示する |
themeColorDimming | theme-color-dimming | auto | モーダル時ウェブビューのテーマカラーを暗くする |
エントリポイント
「エントリポイント」@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」から続けてあなたが「 「Getting Started」 native プラグインの作業を計画する場合、 Capgo プラグインディレクトリ Capgo プラグイン Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, プラグインの追加または更新 __CAPGO_KEEP_0__プラグインの追加または更新の実装詳細について Ionic Enterprise プラグインの代替 __CAPGO_KEEP_0__ Ionic Enterprise プラグインの代替の製品ワークフローについて Capgoネイティブビルド Capgoネイティブビルドの製品ワークフローについて