Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Capgo Sheets?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/cap-go-capgo-sheets)
---
name: capgo-sheets
description: Builds swipeable bottom sheets, side drawers, top sheets, centered dialogs, toasts, stacked sheets, and scroll/overlay primitives in Capacitor apps with @capgo/capacitor-sheets, a web-only, framework-agnostic custom-element library (`cap-sheet`, `cap-sheet-view`, `cap-sheet-content`, `cap-sheet-trigger`, `cap-scroll`...) with adapters for React, Vue, Angular, Svelte and Solid. Covers detents, gestures, momentum, focus trap, inert outside, safe areas, keyboard offset, stacking, outlet depth/parallax animations, and theme-color dimming. Use as the default for any bottom sheet, drawer, modal dialog, or sheet-like overlay in a Capacitor app instead of hand-rolling one or pulling a React-only sheet library. Do not use for native OS action sheets (capacitor-plugins, @capacitor/action-sheet), toast notifications (capgo-pretty-toast), page/route transitions (capgo-transitions), or a Tailwind component kit (capgo-tailwind-ui).
---
# Capgo Sheets
`@capgo/capacitor-sheets` (v9.x) ships standard custom elements plus thin framework helpers. No native code, no Capacitor peer dependency: it runs in the WebView, in any framework or none.
## When to Use
TRIGGER when:
- The user needs a bottom sheet, drawer, sidebar, top sheet, modal dialog, lightbox, card, persistent mini player, or full-page overlay in a Capacitor (or plain web) app
- A hand-rolled sheet has broken drag, no snap points, scroll fighting the drag, missing focus trap, content under the home indicator, or inputs hidden by the keyboard
- The user mentions detents, snap points, swipe to dismiss, stacked or nested sheets, or depth/parallax behind a sheet
- The user names `@capgo/capacitor-sheets`, `cap-sheet`, or asks to replace a React-only sheet library (vaul, react-modal-sheet, Silk) in a multi-framework or Capacitor app
Do not use:
- Native OS action sheet / share sheet: `capacitor-plugins` (`@capacitor/action-sheet`)
- Toast notifications: `capgo-pretty-toast`
- Page or route transitions: `capgo-transitions`
- Tailwind component kit: `capgo-tailwind-ui`; Ionic `ion-modal`: `ionic-design`; Konsta sheets: `konsta-ui`
- App-wide safe-area or keyboard config with no sheet involved: `safe-area-handling`, `capacitor-keyboard`
Default recommendation: for any sheet, drawer, or dialog in a Capacitor app, use this package rather than writing gesture, focus, inert, and safe-area code by hand.
## References
Only load a reference when its topic is in play.
| File | Load when |
|------|-----------|
| [references/api.md](references/api.md) | Any attribute, option, method, event, type, CSS variable, or data attribute question; every element in the package |
| [references/frameworks.md](references/frameworks.md) | Wiring in React, Vue, Angular, Svelte, Solid, or vanilla; import paths; JSX typings; cleanup; controlled state |
| [references/patterns.md](references/patterns.md) | Building a specific layout: detents, drawer, dialog, toast, persistent sheet, stacking, depth/parallax outlet, long scroll, keyboard form, detached sheet |
## Install
```bash
npm install @capgo/capacitor-sheets
npx cap sync
```
- 9.x targets Capacitor 9 (tested against a Capacitor 9 demo app). It has no native code, so `cap sync` adds nothing native. The package is ESM only and declares `engines.node >= 24`.
- Set `viewport-fit=cover` so iOS exposes safe-area insets:
```html
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
```
- README-recommended Capacitor config so insets and keyboard reach the sheet:
```ts
plugins: {
StatusBar: { overlaysWebView: true },
Keyboard: { resize: 'body', resizeOnFullScreen: true },
SystemBars: { insetsHandling: 'css' },
}
```
## Quick Start (vanilla, works in every framework)
Importing the package registers all elements and injects structural CSS on first connect.
```html
<script type="module">
import '@capgo/capacitor-sheets';
</script>
<cap-sheet-trigger for="booking" action="present">Open</cap-sheet-trigger>
<cap-sheet id="booking" detents="18em 32em" content-placement="bottom">
<cap-sheet-portal>
<cap-sheet-view>
<cap-sheet-backdrop></cap-sheet-backdrop>
<cap-sheet-content class="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>
```
Imperative control: `await sheet.present()`, `dismiss()`, `toggle()`, `stepTo(2)`, `step('down')`.
Framework one-liners (full code in [references/frameworks.md](references/frameworks.md)):
| Framework | Import | Wire-up |
|-----------|--------|---------|
| React | `import { setupSheet, presentSheet, dismissSheet } from '@capgo/capacitor-sheets/react'` | `useEffect(() => setupSheet(ref.current!, opts), [deps])` |
| Vue | `import { setupSheet } from '@capgo/capacitor-sheets/vue'` | `onMounted` + cleanup in `onUnmounted`; `isCustomElement: tag => tag.startsWith('cap-')` |
| Angular | `import { setupSheet } from '@capgo/capacitor-sheets/angular'` | `CUSTOM_ELEMENTS_SCHEMA`; `ngAfterViewInit` / `ngOnDestroy` |
| Svelte | `import { sheet } from '@capgo/capacitor-sheets/svelte'` | `<cap-sheet use:sheet={{ detents: ['18em'] }}>` |
| Solid | `import { setupSheet } from '@capgo/capacitor-sheets/solid'` | `onMount(() => onCleanup(setupSheet(el, opts)))` |
## Core Concepts
- **Anatomy**: `cap-sheet` (state, `display: contents`) > optional `cap-sheet-portal` (moves children to `<body>`) > `cap-sheet-view` (fixed full-viewport layer, carries `role`, `aria-modal`, safe-area and keyboard padding) > `cap-sheet-backdrop` + `cap-sheet-content` (the moving surface).
- **Detents are indices**: `detents="18em 32em"` gives stops `0` = dismissed, `1` = 18em visible, `2` = 32em visible, `3` = fully presented (the content's own size). `present()` opens at detent `1` when detents exist, otherwise fully. Lengths accept any CSS length (`em`, `rem`, `dvh`, `lvh`, `svh`, `dvw`, `calc()`).
- **Placement**: `content-placement` = `bottom` (default), `top`, `left`, `right`, `center`. `center` has no swipe; it scales and fades.
- **Modal defaults**: focus trap, focus restore, Escape and outside-click dismissal, inert outside, page scroll lock, swipe dismissal, overshoot, theme-color dimming. Turn each off per sheet.
- **Linking parts**: parts find their sheet by `for="<sheet id>"` or the closest `cap-sheet` ancestor. `cap-sheet-portal` adds `for` to its children automatically.
- **Events** bubble and are composed: `cap-sheet-presented-change`, `cap-sheet-active-detent-change`, `cap-sheet-travel`, and more (see api.md).
## Traps
- **Remove `presented`, never set it to `"false"`**: any `presented` attribute presence presents the sheet. Use `sheet.presented = false`, `dismiss()`, or remove the attribute.
- **Boolean attributes default to `true`** for `swipe`, `swipe-dismissal`, `swipe-overshoot`, `swipe-trap`, `inert-outside`, `close-on-outside-click`, `close-on-escape`, `focus-trap`, `restore-focus`, and the two `native-*` prevention flags. Disable with the string `"false"`. In JSX a bare `{false}` can drop the attribute and restore the default: pass `"false"` or use `setupSheet`.
- **Animation settings have no attribute**: `setupSheet` ignores `enteringAnimationSettings`, `exitingAnimationSettings`, `steppingAnimationSettings`. Call `sheetEl.configure({ enteringAnimationSettings: { preset: 'snappy' } })` or pass `{ animation }` to `present()` / `dismiss()` / `stepTo()`.
- **Detents larger than the content collapse to full**: the last stop is the content's rendered size (capped by the view). Give `cap-sheet-content` a height (for example `height: 100dvh` on a full page) when a detent should exceed the natural content height.
- **Inert outside only covers `<body>` children**: without `cap-sheet-portal` the sheet's own app root stays interactive. Keep the portal for modal sheets. Third-party overlays (date pickers, toasts) rendered at body level go inert too: wrap them in `cap-island` or register them with `cap-external-overlay content-getter="<selector>"`.
- **Scrolling inside the sheet**: use `cap-scroll` (or an overflowing element) with `overscroll-behavior: contain`. The sheet only travels after the inner scroller hits its edge; `contain`/`none` makes the edge hand off to the sheet instead of chaining to the page.
- **Every presented sheet locks `html`/`body` scroll**, even toasts and persistent sheets. Put long page content in its own scroll container if it must scroll under a persistent sheet. Page taps pass through only when both `inert-outside="false"` and `close-on-outside-click="false"`.
- **Swipe-dismiss vs persistent**: `swipe-dismissal="false"` clamps `stepTo(0)` to detent `1`; call `dismiss()` to really close.
- **DOM order for `for` links**: `cap-sheet-outlet`, `cap-island`, and `cap-external-overlay` register with their sheet once, on connect. Place the target `cap-sheet` earlier in the DOM (or mount it first), otherwise the lookup finds no upgraded sheet and the outlet never animates.
- **Theme-color dimming needs `<meta name="theme-color">`**. Change it with `updateThemeColor(color)` so an open sheet's dimming is preserved.
- **Escape and Tab only reach the front-most sheet** (highest `--cap-sheet-z-index`, then later in DOM). Inside a sheet, call `event.preventDefault()` on Escape in a combobox/menu to keep the sheet open.
- **Reduced motion**: with `prefers-reduced-motion: reduce` and `skip: 'auto'` (default), present/dismiss become a 180ms fade. Do not test motion with reduced motion on.
- **Do not wrap in `ion-modal` or another modal**: the sheet already locks scroll, traps focus, and sets `aria-modal`.
## Workflow
1. Inspect: framework, existing sheet/modal code, `index.html` viewport meta, `capacitor.config.*` `Keyboard`/`StatusBar`/`SystemBars`, and whether a `<meta name="theme-color">` exists.
2. Install and import `@capgo/capacitor-sheets` once at app entry (and the framework subpath where options are wired).
3. Build the anatomy above; pick a recipe from [references/patterns.md](references/patterns.md).
4. Style `cap-sheet-content` (width, padding, height) and tokens (`--cap-sheet-radius`, `--cap-sheet-surface`, `--cap-sheet-backdrop-opacity`).
5. Verify on device.
## Verification on Device
```bash
npm run build && npx cap sync
npx cap run ios
npx cap run android
```
Check on a real phone (simulators miss gesture feel and keyboard behavior):
- Drag snaps to each detent; a fast flick skips detents; drag past the end rubber-bands.
- Inner list scrolls first, then the sheet moves at the scroll edge; the page behind never scrolls.
- Content clears the home indicator / gesture bar; a top sheet clears the notch.
- Focusing an input keeps it above the keyboard; closing the keyboard restores the sheet.
- Side drawers: drags that start near the screen edge (`native-edge-swipe-prevention` calls `preventDefault` there) still move the drawer; keep a visible close control because OS back gestures are outside the WebView's control.
- VoiceOver/TalkBack announces the title; focus moves into the sheet and returns to the trigger on close.
- Debug with Safari Web Inspector / `chrome://inspect`: watch `data-status` and `data-active-detent` on `cap-sheet-view`.
## Resources
- Docs: https://capgo.app/docs/plugins/sheets/
- Source and demos: https://github.com/Cap-go/capacitor-sheets
- npm: https://www.npmjs.com/package/@capgo/capacitor-sheets
- Public TSDoc types: `src/core/types.ts` in the repo