Skip to content
项目

关于

Native-like swipeable sheets for React: bottom sheets, sidebars, dialogs, toasts, lightboxes and pages that swipe and snap like native ones. Unstyled, accessible, zero dependencies. Examples, issues and discussions.

网站与应用开发

这些数字如何统计

可以做什么

  • Swipes that feel native: the swipe is built on CSS Scroll Snap, so the sheet has the device's real momentum and overscroll.
  • Spring animations at full frame rate: opening, stepping between detents and dismissing use spring physics (presets like "snappy" and "bouncy", or your own), run off the main thread.
  • Swipe gestures everywhere: touch, trackpad and mouse wheel, on mobile, tablet and desktop.
  • Detents (snap points): rest a sheet at one or more heights and step between them.

实测星标增长

24小时
0
7天
+1
15天
+2
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

Silk

Native-like swipeable sheets for React

Website · Documentation · Live examples · Pricing · npm

Silk is a React library to build bottom sheets, sidebars, dialogs, toasts, lightboxes and pages that swipe and snap like native ones. One Sheet component covers them all, with swipe gestures, detents (snap points), stacking and on-screen keyboard handling built in. Unstyled, accessible, zero dependencies.

It's also fast where most sheet libraries aren't. The swipe is the browser's own scrolling, and the spring animations run off the main thread too, so both keep your screen's full refresh rate (up to 120 fps, iOS Safari included) and stay smooth while your app is busy.

Used in production by OpenAI, Lovable, Mysten Labs, Owner.com, Tjek, BookRetreats and many others.

This repository holds Silk's public examples, its issue tracker and its discussions. The library itself is distributed on npm as @silk-hq/components.

Quick start

npm install @silk-hq/components

Import the styles once:

@import "@silk-hq/components/unlayered-styles.css";

Then build a bottom sheet:

import { Sheet } from "@silk-hq/components";

export function BottomSheet() {
  return (
    <Sheet.Root license="commercial">
      <Sheet.Trigger>Open</Sheet.Trigger>
      <Sheet.Portal>
        <Sheet.View detents="60lvh" nativeEdgeSwipePrevention={true}>
          <Sheet.Backdrop themeColorDimming="auto" />
          <Sheet.Content>
            <Sheet.BleedingBackground />
            <Sheet.Title>Title</Sheet.Title>
            <Sheet.Description>Description</Sheet.Description>
          </Sheet.Content>
        </Sheet.View>
      </Sheet.Portal>
    </Sheet.Root>
  );
}

See Getting started for the full setup, including Tailwind CSS v4.

Features

  • Swipes that feel native: the swipe is built on CSS Scroll Snap, so the sheet has the device's real momentum and overscroll.
  • Spring animations at full frame rate: opening, stepping between detents and dismissing use spring physics (presets like "snappy" and "bouncy", or your own), run off the main thread.
  • Swipe gestures everywhere: touch, trackpad and mouse wheel, on mobile, tablet and desktop.
  • Detents (snap points): rest a sheet at one or more heights and step between them.
  • Any placement: bottom, top, left, right or centered.
  • Scrollable content: a Scroll component made to work inside sheets.
  • On-screen keyboard handling: inputs stay visible, the page doesn't jump.
  • Stacked and nested sheets, with animations driven by the gesture.
  • Modal or non-modal: focus trapping, outside-interaction blocking and scroll locking, each configurable.
  • Accessible: WAI-ARIA roles, labels, focus management, Escape, reduced motion.
  • Gesture-driven effects: animate any CSS property of any element from the sheet's position, like scaling the page behind it or fading a backdrop.
  • Unstyled: works with CSS, CSS Modules, Tailwind CSS or CSS-in-JS.
  • TypeScript, with all types exported.
  • No dependencies other than React. Works with React 17, 18 and 19.

Examples

The examples/css directory is a Next.js app with 12 complete examples, ready to copy:

Example What it shows
BottomSheet A modal bottom sheet
SheetWithDetent A sheet with a detent (snap point) and a scrollable list
SheetWithKeyboard A form that works with the on-screen keyboard
SheetWithStacking Sheets opened from sheets, with a stacking animation
Sidebar A sidebar from the left edge
Toast A non-modal, swipeable notification
TopSheet A sheet from the top edge
DetachedSheet A floating sheet, detached from the screen's edges
Card A centered card
LongSheet A sheet taller than the screen
Page A full-screen page that slides in from the right and swipes back
PageFromBottom A full-screen page that slides up from the bottom

Try them in CodeSandbox, see them live on silkhq.com, or copy the directory:

npx degit silk-hq/silk/examples/css silk-examples-css

4 advanced examples (Sheet with Depth, Persistent Sheet with Detent, Lightbox, Parallax Page) come with the commercial license.

Documentation

License

Silk is free for non-commercial use. Commercial use requires a commercial license: a one-time payment, starting at €299, priced by your organization's size at purchase (buy a license), for unlimited projects within your organization, with free updates.

Silk is proprietary software: its source is not in this repository. See the terms.

Issues and discussions

探索相关项目

加载中…