YL

FORM & INPUT

星级评分输入Star Rating Input

五颗星从灰变琥珀,悬停时预览、点击后定格,星星还会微微弹一下。

中英对照

中文
星级评分输入
英文
Star Rating Input
别名
评分组件、打星、Rating Stars
一句话
五颗星从灰变琥珀,悬停时预览、点击后定格,星星还会微微弹一下。

效果预览

★★★★★
4 / 5 · 悬停可预览,点击定格

适合用在哪

商品评价、服务反馈、内容评分、NPS 调研。

不适合:需要开放题反馈或 NPS 0–10 时:五星粒度不够;只读展示评分也不要用可点星级,改用静态星 + 数字。

和相近模式的区别

星级评分展示Star Rating Display

社会证明星级是只读展示(常配人数);星级评分输入可悬停预览、点击锁定,并常配档位文案。

自定义勾选框Custom Checkbox & Radio

勾选是是否同意/多选;星级是 1–5 的序数评价,互斥且有序。

容易踩的坑

  • 只支持鼠标悬停预览,触屏没有 hover,用户点下去前看不到选的是几星。
  • 五颗星没用 radio 组语义,键盘无法用方向键打分,读屏也不念出当前星级。
  • 未选中星星的浅灰描边对比度低于 3:1,用户看不出总共有 5 颗。

设计提示词 · Prompt

星级评分输入(Star Rating Input):5 颗星(SVG 星形,20-28px,间距 2-4px),默认描边灰或浅灰填充;悬停到第 n 颗时前 n 颗填充琥珀色 #F59E0B(预览态),移开恢复;点击后锁定。每颗星悬停时 scale 1.1-1.2 微弹(transition 150ms)。星星旁可配文字档位("还行 / 不错 / 超棒")随选择变化。半星用两层星叠加 + 宽度裁切实现。提交按钮在未评分时 disabled,避免空评分提交。
Star Rating Input: 5 stars (SVG star shapes, 20-28px, 2-4px spacing), defaulting to a gray outline or light gray fill; when hovering the nth star, the first n stars fill with amber #F59E0B (preview state), reverting on mouse leave; clicking locks the rating. Each star does a small scale 1.1-1.2 bounce on hover (transition 150ms). Text tiers next to the stars ("Okay / Good / Awesome") can change with the selection. Half stars are implemented by stacking two star layers + width clipping. The submit button is disabled until a rating is given, preventing empty ratings from being submitted.

可复制 CSS

自包含的最小实现,粘贴到空白页面即可生效;类名可以按项目规范改名。

/* 五星;悬停预览;点击锁定 */
.stars {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.stars button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d1d5db;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, color .15s ease;
}
.stars button.is-on,
.stars button.is-preview { color: #f59e0b; }
.stars button:hover { transform: scale(1.15); }
.stars button:focus-visible { outline: 2px solid #4f46e5; outline-offset: 2px; }
.stars__hint {
  margin-left: 10px;
  font: 13px/1 system-ui, sans-serif;
  color: #6b7280;
}
@media (prefers-reduced-motion: reduce) {
  .stars button { transition: none; }
  .stars button:hover { transform: none; }
}

演示 HTML 结构

<div class="s d-starsdemo">
  <div class="d-stars">
    <i class="is-on">★</i><i class="is-on">★</i><i class="is-on">★</i><i class="is-on">★</i><i>★</i>
  </div>
  <span class="d-starsdemo__hint">4 / 5 · 悬停可预览,点击定格</span>
</div>

无障碍要点

  • 每颗星用 button,aria-label 写成「1 星」…「5 星」;整组可用 radiogroup 语义。
  • 未评分时提交按钮 disabled,避免空评分。

常见问题

星级评分输入的英文是什么?

星级评分输入的英文是 Star Rating Input。常见英文别名还包括 Rating Stars。

Star Rating Input 的中文是什么?

Star Rating Input 的中文是「星级评分输入」。常见中文别名还包括 评分组件、打星。五颗星从灰变琥珀,悬停时预览、点击后定格,星星还会微微弹一下。

琥珀色一定要用 #F59E0B 吗?

这是常见评分色,与提示词一致。品牌若禁止橙黄,可用品牌色,但要保证与灰底对比足够。

半星怎么做?

两层星叠加,上层用宽度裁切(如 width:50% + overflow:hidden)。输入场景更常见整星;半星多用于只读均分展示。

常见搭配

同一页面里经常和「星级评分输入」一起出现的模式,可以收藏后用「组合收藏为整页提示词」一起交给 AI。

标签