/modern-html:modern-html-scroll-and-motionfrom modern-html
Scroll snap, scroll-driven animations, view transitions same-doc/cross-doc, smooth-scroll — scroll-snap-type, animation-timeline scroll()/view(), startViewTransition, @view-transition MPA, ::scroll-button/::scroll-marker, prefers-reduced-motion. Use when: carousel, snap scroller, page transitions SPA/MPA, scroll-position effects, sticky reveal/hide. Skip: no scrollable region, motion disabled.
Ships in modern-html. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 1rem; }
.carousel > * { flex: 0 0 100%; scroll-snap-align: center; }
值:
scroll-snap-type: x mandatory | proximity — 軸 + 強度。scroll-snap-align: start | center | end.scroll-snap-stop: always — 強單步。a11y:scroll container 加 role="region" + aria-label。
@media (prefers-reduced-motion: no-preference) {
html { scroll-behavior: smooth; }
}
或 JS:element.scrollIntoView({ behavior: 'smooth' }).
.header { position: sticky; top: 0; z-index: 10; }
thead th { position: sticky; top: 0; }
注:Safari iOS 上 <table> collapsed border + sticky thead 偶 bug,驗之。
function update(callback) {
if (!document.startViewTransition) return callback();
document.startViewTransition(callback);
}
@media (prefers-reduced-motion: no-preference) {
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.2s; }
}
.hero { view-transition-name: hero; }
view-transition-class (乙):
.card { view-transition-class: card; }
::view-transition-group(.card) { animation: ...; }
@view-transition { navigation: auto; }
必 fallback:Firefox 即 instant nav。配 Speculation Rules 加速。
@supports (animation-timeline: scroll()) {
.progress { animation: progress linear; animation-timeline: scroll(); }
@keyframes progress { from { width: 0; } to { width: 100%; } }
}
JS fallback (IO):
const io = new IntersectionObserver((es) => {
for (const e of es) e.target.classList.toggle('in', e.isIntersecting);
});
document.querySelectorAll('.reveal').forEach(el => io.observe(el));
animation-timeline: view() — 元素入視動畫。
scroll-timeline-name / view-timeline-name — 多時間軸。
@supports selector(::scroll-button(*)) {
.carousel { scroll-marker-group: after; }
.carousel::scroll-button(left) { content: "←" / "Previous"; }
.carousel::scroll-button(right) { content: "→" / "Next"; }
.carousel > *::scroll-marker {
content: ""; width: 10px; height: 10px;
border-radius: 50%; background: #ccc;
}
.carousel > *::scroll-marker:target-current { background: currentColor; }
}
跨瀏需 JS 補。
@starting-style + discrete animations (乙, 2024-08)進出動畫從 display: none:
.modal {
opacity: 0;
transition: opacity 0.2s, display 0.2s allow-discrete, overlay 0.2s allow-discrete;
}
.modal.open { opacity: 1; display: block; }
@starting-style {
.modal.open { opacity: 0; }
}
三件齊:
@starting-style { ... } — 入態起點。transition-behavior: allow-discrete 或 transition list 含 display 0.2s allow-discrete。display(top-layer 加 overlay)。缺一則靜默失敗。
@media (prefers-reduced-motion: no-preference) { ... }(opt-in)。forced-colors: active 下 disable 裝飾動畫。examples/scroll-snap.cssexamples/view-transitions.cssexamples/scroll-driven.cssmodern-html:baseline-decision-protocol — 前置 Tier A/B/C 閘;先判可用層,再取此技各特性。modern-html:performance-and-containment — 滾動 / 動畫之效能與 containment,配對取用。What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub standardbeagle/standardbeagle-tools --plugin modern-html10 skills in this plugin
/modern-html-accessibility-primitivesNative a11y primitives — focus-visible, focus-within, inert, prefers-reduced-motion, prefers-color-scheme, prefers-contrast, forced-colors, accessibility-tree for dialog/popover/anchor-positioning, ARIA labeling. Use when: focus styles, keyboard nav, animating UI, picking colors, modal/popover content, auditing component a11y. Skip: backend code, non-rendered content./modern-html-baseline-decision-protocolBaseline-tier decision tree for HTML/CSS/DOM Tier A Widely-9mo auto-adopt, Tier B Newly prompt, Tier C Limited avoid sans fallback. Use when: writing CSS/HTML, picking UI pattern, replacing JS lib, choosing layout/animation primitive, before popover/dialog/container-queries/anchor-positioning/view-transitions/scroll-driven-animations/color-mix/oklch/:has(). Skip: non-UI code./modern-html-css-architectureCascade layers (@layer), @scope at-rule, native CSS nesting for stylesheet structure, specificity, component scoping, replacing BEM/CSS-Modules. Use when: new design system, migrating off Sass mixins, organizing token layers, specificity battles, scoping component CSS sans build step. Skip: single-file demo or prototype, architecture overhead not worth it./modern-html-js-replacement-patternsReplace JS UI libs with native HTML/CSS — modal, tooltip, popover, dropdown, accordion, tabs, carousel, sticky, smooth-scroll, form-validation, lazy-load, line-clamp. Use when: replacing/evaluating Floating UI, Popper, Headless UI, Radix, Reach, Tippy, Swiper, GSAP, Framer Motion, IntersectionObserver libs; building UI primitives; removing JS from frontend. Skip: backend code, non-UI domain./modern-html-modern-css-layoutContainer queries, container query units (cqw/cqh/cqi/cqb), subgrid, :has() relational selector for responsive component-driven sizing. Use when: cards/sidebars/dashboards/responsive components, grandchild row alignment across siblings, styling parents by descendants, replacing viewport media queries with component-aware. Skip: static single-viewport layout, Baseline-Widely-3yr-only project./modern-html-native-form-controlsNative form/input/validation/picker/auto-size — constraint validation (required, pattern, type-inputs), :user-valid/:user-invalid, accent-color, color-scheme, customizable select Limited, field-sizing:content. Use when: login/signup/search/data-entry forms, validation styling, tinting checkbox/radio/range/progress, auto-grow textarea, replacing JS form libs. Skip: read-only display, no inputs.