新栏目《999 个小技巧,让你 Vibe 的产品更有质感》
✨ 005 更灵动的拖拽排序
001–005 都在我主页,关注我,每天一个让产品更有质感的小技巧
做横向或纵向的拖拽排序时,让落点两侧的元素轻轻让开,并且由近及远依次启动,动作会更像真实世界里的推挤。
要点:
1. 光标及时反馈:悬停时变成手指,按下时变成抓手;
2. 落点用一条插入线提示:出现时从中间轻轻展开,拖动时跟着移到新的落点;
3. 插入线两侧的元素向外避让,离得越近,让得越多、动得越早:
位移 = 10px × 0.7ⁿ
延迟 = 24ms × n
(n 是与插入线相隔的层数,紧挨着的为 0)
Prompt 如下,可以直接抄 ⬇️
Make drag-to-reorder in my product feel like this. Apply it to the lists,
rows and docks I name, and reuse any drag helper the project already has.
1. Cursor: a pointing hand over anything draggable, a grabbing hand while
dragging.
2. Lift: the picked item follows the pointer, raised off the list so it
never hides where it will land: above a horizontal row, or pulled aside
and shrunk to about 90% in a vertical list. Its old slot closes up.
3. Drop hint: a faint, thin line in the gap where it will land (vertical in
a row, horizontal in a list), about 15% of the text color. It grows from
its middle when it appears and glides to each new gap. No line over the
item's own slot.
4. Ripple: items on both sides of the line lean away from it. Counting n
from the line (0 = the item touching it), item n moves
A x 0.7^n (A is about 10px for icons, 8px for cards)
and starts 24ms x n later, on a quick spring that barely overshoots and
settles in about 0.25s. Nearer items move sooner and further, so the
push spreads out like a ripple.
5. Drop: the item takes the gap and every item springs into its new place.
Escape or dropping outside the list cancels, and everything springs back.
6. Give each motion its own curve (hand-like for the pointer, a small pop
for the lift, springs for settling) instead of one ease-out everywhere.
Move things with transforms, not layout. Let the keyboard reorder too, and
with reduced motion keep only the line.
新栏目《999 个小技巧,让你 Vibe 的产品更有质感》
✨ 007 让你的文字排版更顺眼(以中英文为例)
不论是英文,还是中文,都需要解决对齐、长度不均,避头尾问题。你可以通过一些简单的 CSS 来进行处理——
更重要的是,在做 i18n 的时候,让 Agent 结合网页布局选择合适的文本。避免一个词居于两行,也避免过多的空隙。
001–007 都在主页,关注我,每天一个让产品更有质感的小技巧
Prompt 如下,可以直接抄 ⬇️
```
Polish the typography in my product with a set of CSS switches. Change
only how text wraps, spaces, aligns and truncates. No copy, font, colour
or layout changes beyond what each rule says.
## 0. Start from what exists
- Put the rules in the global text styles (base CSS, typography tokens,
Tailwind config or shared text components) so every page inherits them.
Add per-component rules only where a component overrides the base.
- Every rule below is progressive enhancement: browsers that don't know a
property ignore it. Add no polyfills.
- Scope the Chinese rules with :lang(zh) and make sure lang is set on
<html> or on the element, so English text keeps its own rules.
## 1. Headings break into even lines
- On h1-h3, card titles and hero lines:
text-wrap: balance;
- Lines come out about the same length, so a heading never ends on one
lonely word. Short text only: Chrome balances up to 6 lines.
## 2. No lone word at the end of a paragraph
- On paragraphs, descriptions and list items:
text-wrap: pretty;
- Also keep pairs that must not split together with a non-breaking space
( ): an em dash and the name after it, a number and its unit.
## 3. Numbers that change keep their width
- On anything that updates in place or sits in a column (counters,
prices, timers, stats, table cells):
font-variant-numeric: tabular-nums;
- The font must have tabular figures (the tnum feature); check that the
width actually stops changing. Leave running text proportional.
## 4. Button labels stay on one line
- On buttons and other labels in flex rows:
white-space: nowrap;
- (flex-shrink: 0 works too.) A crowded row must not squeeze a label onto
two lines.
## 5. Long text truncates instead of spilling out
- A flex item will not shrink below its content, so text inside it can't
truncate. On the flex item:
min-width: 0;
- And on the text itself:
overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
- When the text really is cut (scrollWidth > clientWidth), show the full
text on hover in a tooltip.
## 6. Chinese body text: justified, on a whole number of characters
- On Chinese paragraphs only:
text-align: justify;
- Set the measure to a whole number of characters (for example
max-width: 26em at the paragraph's font size), so a justified line only
stretches to absorb Latin words and squeezed punctuation.
- Not for narrow columns (under about 15 characters), short text,
captions, buttons or mostly-English text: the gaps get uneven.
## 7. Space between Chinese and Latin text or numbers
- On Chinese text:
text-autospace: normal;
- The browser adds a thin gap between Han characters and Latin letters or
digits. Don't also hand-type spaces in copy or translation files.
Skip code, inputs and monospaced text.
## 8. No half-width gap before an opening bracket at a line start
- On Chinese UI text without a first-line indent:
text-spacing-trim: trim-start;
- An opening 「 “ ( at the start of a line drops its blank half and lines
up with the text above. Long-form text with a two-character indent
should use space-first instead. Chrome only for now.
## 9. Chinese headings break between words
- Chinese has no spaces, so a heading can split a word across lines.
Mark the break points between words with BudouX (its Simplified or
Traditional Chinese model) as <wbr>, at build time for static copy or at
render time for dynamic copy, then:
word-break: keep-all;
overflow-wrap: anywhere;
text-wrap: balance;
- Never use keep-all on Chinese without break points: the heading becomes
one unbreakable word. Don't use Intl.Segmenter for this (it splits common
words wrongly), and don't apply it to body text.
## 10. Line-start and line-end rules (避头尾)
- Browsers already keep punctuation off the start of a line and squeeze
line-end punctuation. Don't rebuild this.
- Find and remove line-break: anywhere used to stop overflow: it turns
these rules off. Use overflow-wrap: anywhere instead.
- Text drawn on canvas or SVG, or wrapped by hand in JS, gets none of
this: apply the rules there yourself.
## 11. When done
- List every file and selector you changed.
- List every line-break: anywhere and word-break: break-all you removed or
kept, and why.
- Show before and after on my own pages: a wrapped heading, a paragraph
ending, a changing number, a truncated label and a mixed
Chinese-English paragraph.
```
新栏目《999 个小技巧,让你 Vibe 的产品更有质感》
✨ 003 Dither 与 ASCII 参数化效果
001–003 都在我主页,关注我,每天一个让产品更有质感的小技巧
为你的登录页面/卡片添加可控的 Dither 与 ASCII 效果,并附带遮罩、色调、采样强度、大小、间距等可调参数。
两种效果怎么拆:
ASCII:把画面切成网格,每格按亮度换成一个字符,从 “.” 到 “@” 越来越密。大小是字号,间距是格子疏密,采样强度是明暗对比,取样区域决定字画的是暗部还是亮部。
Dither:把画面切成像素块,用 4×4 的 Bayer 矩阵当阈值,把每个颜色压成几级。大小是像素块,间距是纹理的尺度,采样强度越高,颜色级数越少,颗粒感越重。 两者都可以加一层遮罩,让画面退后,效果更像纹理而不是噪点。
推荐参数:
ASCII:遮罩 90、取样暗部、采样强度 100、大小 37、间距 0
Dither:遮罩 88、采样强度 100、大小 15、间距 0
Prompt 如下,可以直接抄 ⬇️
Add an ASCII / ordered-dither effect to one specific image or video in this project, with a live control panel next to it. Use the asset and the place I name (an , a , or a file path or URL, and the page or section it sits in); ask me if I have not named them. Apply the effect to that asset only, in place: keep its size, position, rounded corners and anything layered on top of it. If the project already has an image or canvas effect pipeline, or slider, segmented-control and panel components, build on them; otherwise create a reusable EffectLayer and EffectPanel.
Settings, one object shared by the layer and the panel: { filter: 'ascii' | 'dither', mask, palette, inkTone, strength, size, spacing } Keep separate values per filter, so switching filters brings back that filter's own settings.
What each control does in each filter, its range, and the recommended value (ASCII / Dither):
Mask effect, 0-100 (90 / 88): a vertical veil over the picture so the effect reads as texture rather than noise. Same in both filters.
Color, Original or one of five palettes (Original): gradient-maps the asset's luminance into one color family before filtering.
Sample tones, Shadows | Highlights (Shadows; ASCII only, hidden for Dither): which end of the tonal range becomes dense characters.
Sampling strength, 0-100 (100 / 100). ASCII: contrast of the tone curve and how bright and opaque the characters are. Dither: how few levels each color channel keeps (8 at 0, 2 at 100) and how fully the quantized color replaces the original.
Size, 0-100 (37 / 15). ASCII: font size, 7-24px. Dither: pixel block, 2-9px.
Spacing, 0-100 (0 / 0). ASCII: grid step, 8-24px across and 9-26px down, never tighter than the glyphs. Dither: scale of the Bayer pattern, 1-4 blocks per matrix cell.
Helpers used throughout:
range(v, a, b) = a + (b - a) * v / 100
luminance L = (0.299 R + 0.587 G + 0.114 B) / 255
s = strength / 100
"The box" is the asset's rendered size on the page.
Sampling:
Cover-fit the asset into the box and draw it into a small sampling canvas (about 480px on the long side), then read it with getImageData. A sample is the pixel under a point in the box, composited over white.
With a palette, recolor that canvas first: map each pixel's L through a 256-entry lookup built from the palette's four stops.
Per image or video frame, take about 12,000 evenly spaced samples: low = 8th percentile of L, high = 92nd percentile.
Shadows means dark ink, Highlights light ink.
ASCII:
Characters, from empty to full: " .,:;-=+xX08S#&@" (starts with two spaces).
Font: round(range(size, 7, 24))px monospace (22 instead of 24 when the box is under 720px wide), centered in each cell.
Grid: x step = max(range(spacing, 8, 24), widest glyph * 1.08); line height = max(range(spacing, 9, 26), height of "@" * 1.12, font * 1.04). The first cell sits half a step in from the edge.
Tone of a cell: raw = dark ink ? 1 - L : L; normalized = dark ink ? (high - L) / (high - low) : (L - low) / (high - low), clamped 0-1 (use raw alone when high - low < 0.025); mix = 0.72 + 0.14 s; t = raw (1 - mix) + normalized mix. Then a tone curve: black = 0.22 s, white = 1 - 0.08 s, lev = clamp((t - black) / (white - black), 0, 1), tone = lev (1 - s) + smoothstep(lev) s.
Skip cells with tone <= 0.02. Character = chars[round(tone * 16)]; skip spaces.
Ink: the sampled color lifted in HSV: value += (1 - value) * (0.24 + 0.18 s + 0.24 tone); saturation *= 1 + 0.16 + 0.2 s (clamped). Alpha = clamp((0.12 + 0.7 tone) (0.72 + 0.28 s), 0.06, 0.94).
Dither (ordered, Bayer 4x4):
pixel size = max(2, round(range(size, 2, 9))) (7 instead of 9 under 720px); pattern scale = max(1, round(range(spacing, 1, 4))); levels = max(2, round(range(strength, 8, 2))) per channel; blend = range(strength, 0.32, 1).
Matrix [[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]]; threshold = (m + 0.5) / 16, indexed by floor(x / pattern scale), floor(y / pattern scale).
For each block sample its center, push saturation away from luma by 1 + 0.06 + 0.18 s, then per channel: scaled = c / 255 * (levels - 1); q = floor(scaled) + (fraction > threshold ? 1 : 0); out = c + (q / (levels - 1) * 255 - c) * blend.
Write the blocks into a canvas of box / pixel size and draw it scaled up with image smoothing off.
Mask and layering:
The mask is a vertical gradient with stops at the top, 42% and the bottom. Base opacities: on a light page white 54/20/38%, on a dark page black 44/20/50%. For a mask value v: stop = v <= 50 ? base * (v / 50)^1.08 : base + (100 - base) * ((
新栏目《999 个小技巧,让你 Vibe 的产品更有质感》
✨ 001 富有点击手感的拟物按钮
Prompt 如下,可以直接抄 ⬇️
Define a tactile, skeuomorphic Button component with five variants, from
strongest to weakest: primary, secondary, tertiary, ghost, text.
If the project already has a component library or design system, do not
add a new component: restyle its existing Button through its own variant
and token system, and keep its API, props and accessibility as they are.
Otherwise create one reusable Button with `variant` and `size` props.
Style: calm and precise, like the Lumno browser extension and the Cloudflare
dashboard. Neutral grays only, no brand hues. Lit from straight above.
No glossy Web 2.0 shine, no glow, no large blur.
Variants:
1. primary - near-black slate face (#404859 -> #273042), white label
2. secondary - raised white key (#FFFFFF -> #F4F5F7), dark gray label
3. tertiary - soft gray key (#F3F4F6 -> #E7E9EC), dark gray label
4. ghost - no face at rest; faint gray fill on hover; a recessed well
when pressed
5. text - gray label with a thin underline and an arrow that nudges
right on hover
Every filled variant is the same five material layers; only the values
change, so define them once as tokens and let each variant set its own:
1. Face: 180deg linear gradient, top 6-8% lighter than bottom.
2. Edge: 1px solid border one step darker than the bottom of the face
(primary #12161F, secondary rgba(15,23,42,.14), tertiary rgba(15,23,42,.1)).
3. Top highlight: inset 0 1px 0 white (18% on slate, 85-100% on light
faces). Put every inset layer in the button's own box-shadow, before the
drop layers, never on a pseudo-element overlay: inset shadows on the
element follow the inner radius (outer radius minus border), so the
corners line up in every state.
4. Bottom shade: inset 0 -1px 0 black (22% on slate, 6% on light faces).
5. Drop shadow in two layers: a tight contact shadow 0 1px 2px plus a soft
lift 0 4px 10px -3px (18% and 28% on slate, about a third of that on
light faces).
States (hover, pressed/active, focus-visible, disabled):
- Hover: face one step lighter; the lift grows to 0 8px 16px -5px.
- Pressed: translateY(1px); flip the gradient (darker on top); the outer
shadow collapses to 0 1px 1px; the top highlight becomes an inner shadow,
inset 0 1px 2px black (40% on slate, 12-16% on light faces). Light faces
keep a 1px white line below, 0 1px 0 rgba(255,255,255,.9), like a key
pressed into paper.
- Give rest and pressed the same number of inset layers (pad with
inset 0 0 0 transparent) so the shadow animates instead of jumping.
- Focus-visible and disabled follow the library's existing conventions.
- Timing: 120ms for transform, 140ms for shadows, 160ms for colors.
Sizes: all values above are for the 14px label size: height 40px,
padding 0 18px, radius 10px, label weight 600, optional 16px leading icon.
On the slate face add a label text-shadow 0 -1px 0 rgba(0,0,0,.28).
Scale the material with the type, never keep it at fixed pixels: express
every length (height, padding, radius, border, icon, the 1px press offset,
and every shadow offset, blur and spread) as a multiple of a size unit
u = label size / 14. Provide two sizes: md (14px label, u = 1px) and
lg (16px label, u = 16/14 px, so height 45.7px, radius 11.4px, lift shadow
0 4.6px 11.4px -3.4px).
尺寸:所有数值均适用于 14 像素的标签。标签的高度为 40 像素。
填充 0,宽度 18px,半径 10px。标签权重 600,可选字体大小 16px,带有图标。
在幻灯片面上添加如下标签样式:text-shadow 0 -1px 0 rgba(0,0,0,.28)。
使用相应的类型来缩放素材,切勿将其固定在固定的像素上:请表达出来。
各种长度(高度、填充、半径、边框、图标、1 像素的鼠标点击偏移量等)
以及每个阴影的偏移量、模糊程度以及扩散情况,所有这些参数都是按照某个尺寸单位来计算的。
u = 标签大小 / 14。提供两种尺寸:md(14 像素的标签,u = 1 像素)和
左图(16 像素标签,上距 16/14 像素,因此高度为 45.7 像素,半径 11.4 像素,带有提升阴影效果)
0 4.6 像素,11.4 像素,-3.4 像素。