组件

Bookmark

A ribbon bookmark you can press. Unpressed, a dashed pencil ghost of a ribbon marks the place; pressed, the woven, edge-stitched cloth ribbon hangs there in its color and casts a short shadow. It is a Toggle underneath, so `aria-pressed`, Space and Enter come for free. `BookmarkRibbon` is the same ribbon as a page marker with no behavior.

安装

terminal
npx shadcn@latest add @wobko/bookmark

第一次使用?先把 registry 加进 components.json。 如何安装

示例

A bookmark

Press it: the ghost becomes a ribbon that settles in with a little turn. It is a toggle button, so Space and Enter work, and its state is `aria-pressed`.

Eight ribbons

Every stationery accent. Each ribbon is woven and edge-stitched, lit from the upper left, a hair off straight.

Page markers

`BookmarkRibbon` is the ribbon with no behavior: decoration that hangs out of the top of a sheet or a notebook.

A reading list

A real use: save articles for later. Each card holds a Bookmark; the count follows. State lives in your app, as with any toggle.

API 参考

Bookmark

A Radix Toggle (a `button`) 2 rem wide and 3 rem high, with a hit area 6 px larger all round. It takes every Toggle prop. Its content is its accessible name (default "Bookmark"), visually hidden.

属性类型默认值说明
toneAccent"tomato"The ribbon's color: tomato, tangerine, lemon, grass, teal, sky, grape or bubblegum.
pressed / defaultPressed / onPressedChangeboolean / boolean / (pressed: boolean) => void-As Toggle: controlled or not.
disabledboolean-A pale ghost that cannot be pressed.
tilt / seed / sizeboolean | number / string | number / [w, h]-A seeded turn under 1.4 degrees (flat in calm density); pins the hand; the box in px for server-rendered drawings.

BookmarkRibbon

The ribbon alone, hanging: an aria-hidden, pointer-events-none `div` for a page marker. Place it with `absolute -top-1 end-6` on a sheet.

属性类型默认值说明
toneAccent"tomato"The ribbon's color.

无障碍

  • Bookmark is a real toggle button: it announces "pressed" or "not pressed", it is reached by Tab and pressed with Space or Enter. Give it a name that says what it saves ("Save this article"); the name does not change with the state, `aria-pressed` does.
  • The ribbon, its stitching and its ghost are aria-hidden decoration, so the state is never carried by color alone: `aria-pressed` and the ghost-versus-ribbon shape (dashed outline versus a filled tail) both tell it. Focus shows the standard focus ring around the box.
  • The hit area is 44 x 60 px with its extension (24 px minimum). Windows high contrast replaces the drawing with a button outline, and a pressed bookmark fills with the system highlight color so the state is still visible; `aria-pressed` follows either way.

源码

CLI 会复制进你项目的文件。

正在加载源码