Drawer
スワイプで閉じられる Sheet:下端または任意の端から現れるパネルで、ドラッグハンドル、スワイプで閉じる操作、任意のスナップポイントを備え、Sheet のフォーカストラップ・Esc キー・スクリムをそのまま使います。
Angular: 対応 Vue: 対応 React: 対応 React Native: 対応
使い方
<div class="demo-row">
<button soneBtn variant="outline" type="button" (click)="open.set(true)">Open drawer</button>
<button soneBtn variant="outline" type="button" (click)="snapped.set(true)">Open with snap points</button>
</div>
<sone-drawer [(open)]="open">
<header soneDrawerHeader>
<h2 soneDrawerTitle>Move goal</h2>
<p soneDrawerDescription>Set your daily activity goal.</p>
</header>
<div class="demo-row" style="justify-content: center">
<button soneBtn variant="outline" size="icon" type="button" aria-label="Decrease" (click)="goal.set(goal() - 10)">−</button>
<strong style="font-size: var(--font-size-3xl); min-width: 6ch; text-align: center">{{ goal() }}</strong>
<button soneBtn variant="outline" size="icon" type="button" aria-label="Increase" (click)="goal.set(goal() + 10)">+</button>
</div>
<footer soneDrawerFooter>
<button soneBtn type="button" (click)="open.set(false)">Submit</button>
<button soneBtn variant="outline" type="button" (click)="open.set(false)">Cancel</button>
</footer>
</sone-drawer>
<sone-drawer [(open)]="snapped" [snapPoints]="[0.4, 1]" [(activeSnapPoint)]="snap">
<header soneDrawerHeader>
<h2 soneDrawerTitle>Activity</h2>
<p soneDrawerDescription>Drag the handle up for the whole week, down to close.</p>
</header>
<ul style="margin: 0; padding-inline: var(--space-6)">
@for (day of days; track day) {
<li>{{ day }}: 30 minutes</li>
}
</ul>
</sone-drawer>インポート
import {
SoneDrawerComponent,
} from "@surface-one/angular/drawer";API リファレンス
SoneDrawerComponentコンポーネント
`sone-drawer` — a sheet you can swipe away (shadcn/ui Drawer on Vaul, spartan/ui Sheet): a modal panel from the `bottom` (or another `side`) with a drag handle. It is the sheet's overlay — focus moves in and is trapped, Escape and the scrim dismiss it, focus returns to the opener, `[(open)]` or `@if` + `(dismiss)` show it — plus a pointer swipe toward its edge that dismisses it past a quarter of its size or on a flick. `snapPoints` (visible fractions of the drawer, ascending, e.g. `[0.5, 1]`) let it rest part-open, two-way as `[(activeSnapPoint)]`; the handle cycles them and keyboard focus inside opens it fully. Under reduced motion it moves without animating. Use the `soneDrawerHeader` / `soneDrawerTitle` / `soneDrawerDescription` / `soneDrawerFooter` / `soneDrawerClose` parts (`SONE_DIALOG_PARTS`).
| 名前 | 型 | デフォルト |
|---|---|---|
open双方向Shown or not, two-way: `[(open)]`. Leave it unbound to show the overlay while it is mounted (render it with `@if` and close it on `(dismiss)`). | boolean | undefined | undefined |
dismissible | boolean | true |
closeLabel | — | $localize`:verb|Closes a dialog or sheet:Close` |
ariaLabel | string | null | null |
side | DrawerSide | "bottom" |
scrimCloses | boolean | true |
showCloseThe corner close button (off: a drawer closes by swipe, Escape, the scrim or a `soneDrawerClose`). | boolean | false |
handleThe drag handle at the inner edge (shown for `bottom` and `top`). | boolean | true |
snapPointsVisible fractions it rests at, ascending (e.g. `[0.5, 1]`); empty: open or dismissed. | readonly number[] | [] |
activeSnapPoint双方向The snap point it rests at, two-way: `[(activeSnapPoint)]` (default: the first). | number | null | null |
| 名前 | 型 |
|---|---|
dismiss | void |