Communitygithub.com

xiezhongyuAI/Keyhtml

HTML presentations with magical move capabilities — single file, zero dependencies, Keynote-style effects, supports cross-page shared element transitions (View Transitions). Can be used as an AI agent skill.

What is Keyhtml?

Keyhtml is a skill for creating single-file HTML presentations that feature Keynote's signature 'Magical Move' effect, where elements with the same name smoothly animate between adjacent slides. Built on the browser-native View Transitions API, it gracefully degrades to simple fades for unsupported browsers. This skill provides a template with built-in theming (ink, midnight, paper), a customizable engine (movement logic), and a layout system for designing slides entirely by hand. The core workflow involves choosing a theme, copying the template, adjusting slide count and layouts based on content, and using special data attributes (`data-magic`, `data-magic-shell`, `data-magic-fade`, `data-rise`) to choreograph transitions. Whether used as an AI agent skill or by a human developer, Keyhtml empowers users to craft highly expressive, narrative-driven presentations without any external libraries or complicated build tools.

Works with~Claude Code~Codex CLI~Cursor
npx skills add xiezhongyuAI/Keyhtml

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Keyhtml — Magical Move HTML Presentations

Create single-file HTML presentations with cross-page 'magical move' element transitions. Output is a single HTML file: double-click to present, no external dependencies. Navigate with arrow keys, scroll wheel, or right-side dots; press F for fullscreen.

'Magical Move' = elements with the same name on adjacent pages automatically interpolate and fly during navigation, Keynote's signature effect. Built on the browser-native View Transitions API; unsupported browsers gracefully fall back to fade-in/fade-out (Chrome/Edge/Safari 18+ fully supported).

One line to get started: Copy assets/template.html → create your slides inside it → open in a browser to verify. All capabilities are built into the template; you only write content and transition markers.

The number of slides is determined by content, not fixed. The <section class="slide"> elements in the template are just examples demonstrating different layouts — freely add or remove them based on your actual content: use three slides if that's all you need, or thirty if required. Don't be constrained by the template's page count, and don't keep example slides you won't use just to fill space.

Workflow

Steps to produce a presentation:

  1. First ask the user to choose a theme (skip if already specified). You must ask before proceeding, presenting three options:
    • ink Theatre Ink Black (default) — ink black background + warm white body text + vermilion accent, suitable for formal speeches, product launches
    • midnight Midnight Blue — deep blue background + cool white + electric blue, suitable for tech, data topics
    • paper Light — cream white background + deep ink text + vermilion, suitable for bright environments, print sharing
  2. Copy assets/template.html to the target location and rename it (work on the copy, don't modify the original template), then set data-theme on line 2 to the user's chosen theme.
  3. Determine the number of slides based on user content: delete unused example slides, copy needed layouts, add or remove <section class="slide"> — the slide count is entirely dictated by content. If a new layout is needed, hand-write a CSS class in the LAYOUTS section.
  4. Use the 'Choreography Vocabulary' below to design page transitions, following the 'Author's Conventions'.
  5. Open in a browser to verify: each magical move must be tested in both forward and reverse directions — reverse is the mirror of forward, not free; layer-level bugs (flickering) often only appear in reverse.

The 12 <section> elements in the template are a layout example library, not a fixed page count: examples are provided for the cover, table of contents, section pages, content pages, and ending page, plus three runnable magical move cases — P4→P5 container transformation, P7→P8 text degradation, P10→P11 graphic scale and color change. The approach is 'pick the layouts you need, copy or delete based on content', not to replicate all 12 pages. If unsure how to write a specific effect, read the corresponding <section>.

Structure: One Engine (Do Not Touch) + Optional + Rewritable

The template is divided into three sections, with only one hard boundary — ENGINE must not be touched; the rest is free to modify. The difference lies in 'how to modify': THEME is optional (flip a switch, choose a preset), LAYOUTS is rewritable (do carpentry, hand-write layouts).

SectionPermissionContentHow to Modify
ENGINE🔒 Do not touchPage turning + magical move + fallback (CSS and JS sections)Prohibited from modification. Modifying the engine = updating the template version, not patching within a single presentation
THEME✎ OptionalColor themes (multiple presets) + font size scaleChange skin by modifying only <html data-theme="..."> in one place, no CSS knowledge needed; see 'Theme Switching'
LAYOUTS✎ RewritableLayout classesHand-write new classes + corresponding structure as needed, freely extend

Where to Change Colors / Font Sizes

Everything is concentrated in the THEME section of the <style> at the top of the template (from the comment THEME — ✎ Optional to ENGINE — 🔒 Engine). Modify this section without touching HTML content or the engine.

  • Switch entire color scheme → Change the value of <html data-theme="ink"> on line 2 (ink/midnight/paper), see 'Theme Switching'.
  • Adjust a specific color → Go into the THEME section, find the corresponding :root[data-theme="..."]{} block, and modify the color variables inside (e.g., --accent accent color, --bg background color).
  • Adjust font sizes → The 5 lines of :root{ --fs-2xl … --fs-sm } at the end of the THEME section, see 'Font Size Scale'.

Principle: Colors and font sizes should always be changed by modifying the variable definitions (THEME section), never hardcode color: / font-size: on specific elements — doing so would break theme switching and responsiveness.

Theme Switching

Change the value of data-theme on line 2 of the file <html lang="zh-CN" data-theme="ink"> to switch the entire skin without touching any style code. Three presets:

ValueNameStyle
inkTheatre Ink Black (default)Ink black background + warm white body text + vermilion accent
midnightMidnight BlueDeep blue background + cool white + electric blue
paperLightCream white background + deep ink text + vermilion

To add a new theme: In the THEME section, copy any :root[data-theme="name"]{...} block and change the colors. Each set includes a group of color variables — body text three levels (--text/--dim/--faint), accent (--accent/--accent-soft), stroke (--line/--line-lit), --strong (bold body text, should be a dark color for light themes), --overlay (overlay background), --orb-* and --orb-warm-* (two sets of gradient ball colors). LAYOUTS/ENGINE sections must not hardcode colors; always use variables, otherwise theme switching will leak colors (e.g., hardcoding #fff for --strong would be invisible on the white background of the paper theme). The font size scale is shared across all themes and does not change with the theme.

Font Size Scale (type scale · 5 levels)

All text uses these 5 variables; hardcoding font-size is prohibited. Named from large to small, purely dimensional semantics, for easy sorting and addition:

Variableclamp RangeUsage
--fs-2xl46–100pxCover / page h1 titles
--fs-xl32–58pxContent page / section h2 titles
--fs-lg20–30pxCard titles / table of contents topics
--fs-md15–19pxBody text / lead / detail lines
--fs-sm13–16pxEyebrow / annotations / page numbers / labels

Each level is a clamp(min, ideal vw, max) range; font size scales smoothly with viewport width and is bounded within the limits — the same presentation will have consistent visual proportions on laptops, projectors, and large screens.

For the complete design specification (colors + font sizes + choreography property visualization), see assets/design-spec.html, double-click to open and show the team.

Choreography Vocabulary (Attributes on Slide Elements)

The first three are for magical moves (active during page navigation), data-rise is for on-page entrance:

AttributeSemanticsUsage
data-magic="id"Fly: Cross-page pairing tweenElements on adjacent pages with the same id automatically fly; id must be unique per page
data-magic-shellTransform: True box interpolationApply to pure box elements for frame-by-frame numeric interpolation of background, stroke, border-radius, gradient instead of snapshot dissolve
data-magic-fadeDissolve: Detach from root snapshotApply to regular content on the same page as a flying element; the engine automatically lifts them to a glass layer for independent fade-out/fade-in in both directions
data-rise="1..5"Entrance: Ascend in sequenceAscend one by one on page entry according to the sequence number. The engine automatically disables this for elements with data-magic; do not rely on both simultaneously

Division of labor between data-magic-fade and data-rise: On pages without flying elements, use data-rise; once a page has a flying element, change content you want to animate to data-magic-fade (otherwise it's frozen in the root snapshot and becomes a hard cut, see Convention 7).

The right-side dot pager automatically groups by data-act="section-id": inserts a separator between adjacent data-act values that differ. Mark each <section> with its section (e.g., intro / c1 / c2 / end); use the same value for the same section; if not marked, it merges into the previous section.

Image zoom is a built-in capability: add class="zoomable" to any image or graphic container to enable click-to-zoom (engine includes a lightbox, close with Esc or click anywhere). <img> uses data-full || src as the zoom source; non-image elements like SVGs are auto-cloned for display. No need to rewrite a lightbox for each presentation.

Motion Easing (Two Tokens, Not One-Size-Fits-All)

Apple's keynote effects have a sense of proportion: 'bounce where appropriate, stay smooth where not.' The engine provides two easing variables:

VariableUsage
--ease-smoothSmooth deceleration. Used for page turning, position tweening of magical moves — large displacements would appear shaky and cheap if overshot
--ease-springSpring overshoot. Used for entrance reveals (rise), micro-scaling (image hover) — a light bounce at landing gives a sense of life

When extending layouts, follow the same sense of proportion: use spring for elements 'appearing / subtle scaling'; use smooth for elements 'moving large distances.' Applying overshoot indiscriminately to all motion is a common pitfall for beginners.

Author's Conventions (Each One Was Learned the Hard Way)

  1. Box is visual. The tween targets element boxes, not text. Block-level text elements must have width:fit-content, otherwise the box fills the entire line, making the flight start point appear in the center of the screen.
  2. Prevent inline element fragmentation. Add display:inline-block to <span> magic elements; elements broken across lines cannot be snapshotted.
  3. Pairing granularity is a means of expression. Text-to-text = conceptual continuity (light); container-to-container = object transformation (heavy); both can be used simultaneously — named child elements are extracted from the parent snapshot and fly independently.
  4. Transform layer pattern. For cards requiring true interpolation, split into 'shell + content' two layers: <div class="shell skin-class" data-magic="id" data-magic-shell></div> absolutely positioned to fill as the base, with content placed beside it. The shell must be an empty box — its snapshot is hidden, and any internal content will instantly disappear.
  5. Gradient transition conditions. Both sides must have the same gradient type, same number of color stops (string consistent after removing colors) for the engine to do frame-by-frame interpolation; a solid color side can be written as a same-color gradient to satisfy the pairing. Otherwise, a hard cut occurs.
  6. Mark overlaid content with fade. A shell's flight will push sibling content above it to the glass layer's bottom, causing flickering; these must be marked with data-magic-fade.
  7. Regular content on the same page also needs fade for entrance. During magical move page transitions, unmarked elements are bundled into the 'root snapshot' for overall cross-fade; their data-rise ascent is frozen into a hard cut. Therefore: once this page has flying elements, mark all other smoothly transitioning content (body text, lists, etc.) with data-magic-fade.
  8. Page skips also trigger transitions. Dot navigation skips also go through pairing checks; don't assume only adjacent pages will transition.

Design Philosophy: Why No Component Library

Keyhtml intentionally does not provide a library of components like cards, buttons, etc., a core design decision, not an omission. The principle in one sentence:

Solidify correctness and functionality; open up taste and expressiveness; deliver syntax, not vocabulary.

  • Solidified (written into ENGINE, do not touch): Page turning, magical moves, font size scale, easing, theme variables, and functional UI (pager / lightbox / fullscreen) — their exact appearance is irrelevant; getting them wrong would break things.
  • Open (left to the author): Expressive elements (cards, buttons, etc.) — they carry content and personal taste; their appearance is an aesthetic judgment; getting them 'wrong' would only look bad, not break anything.

Why not a component library: Presentations require 'different each time, serving the current narrative,' opposite to product UI's pursuit of 'consistent, reusable.' The maintenance cost of a component library here diverges with the diversity of tastes and can never catch up; it can only level the floor, not create highlights.

Keyhtml provides the grammar to create words, not ready-made vocabulary: theme variables, font size scale, data-magic-shell transform layer, 'box is visual' conventions — it doesn't prescribe what a card should look like, but ensures that your own card will automatically integrate into the system and participate in magical moves. Slower users can copy from the template examples (with a floor); faster users can freely create using the grammar (no ceiling).

For maintainers: When receiving requests like 'add a component library,' use the above principle to judge — if an element is functional and its appearance doesn't affect expression, consider building it in (like the pager); expressive elements are always left to the author.

Design Guidance (When to Use, How Much to Use)

Subtraction First — First Think 'How Much Can This Page Be Reduced'

Apple keynote's power comes from restraint: a page often has just one word, one object. The tool provides large font size capability, but by default, don't fill the page.

  • One idea per page. Dare to let one sentence, or even one word, fill the entire screen (using --fs-2xl + vcenter). What the audience remembers is the focus, not the volume of information.
  • The eyebrow + title + lead + hint on the cover is the 'upper limit,' not a 'template.' Most content pages are more powerful stripped down to just a title + one sentence, or even just the title.
  • When there are three points, prefer splitting into three pages rather than listing three items per page — one focus per page, connected by magical moves.
  • Decoration serves content: hint, eyebrow can be left blank or omitted; if whitespace works, don't add lines and color blocks.

Magical Moves

  • Magical moves are a narrative tool: the continuity of elements expresses the continuity of concepts. Typical scenarios — overview card collapses into a detail tab, section title degrades into a corner badge, graphic grows across pages.
  • Don't force pairing between adjacent pages that have no conceptual connection; the default fade-in/fade-out is the correct answer; the engine automatically uses classic transitions for unpaired page navigations — this is a feature, not a bug.
  • Each transition focuses on one set of protagonists; the flying elements should be 'one set of elements of the same concept'; flying everything randomly equals no focus.
  • Text in tweening is a snapshot cross-dissolve (consistent with Keynote); the larger the difference in old and new font sizes, the more noticeable the dissolve effect — when the two ends are vastly different (e.g., a large title shrinking to a small corner badge), prefer container pairing over text pairing.

Related Skills