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.
-
パッケージをインストールしてください
ターミナルウィンドウ 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 Safe Areas
セクションのタイトルは “Capacitor Safe Areas”セーフエリアはデフォルトで有効になっています。 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>命令的制御
「命令的制御」のセクションすべてのフレームワークヘルパーは同じ下位のカスタム要素を構成します。直接シートを制御することもできます:
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>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
Section titled “Components”| 要素 | 目的 |
|---|---|
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 | シート、カード、ライトボックスの分離されたシート、カード、ライトボックスのコンポジションフック |
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 | モーダル時にはWebViewのテーマカラーを減らす |
Available Entrypoints
「Available Entrypoints」@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を使用している場合 Getting Started ネイティブ プラグインの作業を計画するには、接続する Capgo プラグイン ディレクトリ Capgo プラグイン ディレクトリの製品ワークフローについて Capacitor プラグインは Capgo によって提供されます for the implementation detail in Capacitor Plugins by Capgo, プラグインを追加または更新する プラグインを追加または更新するの実装詳細について Ionic Enterprise プラグインの代替 Ionic Enterprise プラグインの代替の製品ワークフローについて Capgo ネイティブ ビルド Capgo ネイティブ ビルドの製品ワークフローについて