nudg_guide
nudg format guide
The nudg format in one page: skeleton, vocabulary, motion forms, structure rules, and which field to change for requests like "bouncier" or "snappier". Read it before writing your first nudg file.
無需輸入參數。

io.github.seukwoo由 GitHub 帳號 seukwoo 發布v1.5.1更新於 Nov 3, 2026
為 Web、iOS 和 Android 編寫、檢查並比較 UI 互動(彈簧動畫、手勢、狀態)。
AI 翻譯由 AI 模型根據下方的原文描述翻譯,可能有誤。
Write, check and compare UI interactions (springs, gestures, states) for web, iOS and Android.
nudg 的本機 MCP 服務;無需登入;STDIO;11 個工具。
暫無 AI 概覽:以下資訊來自註冊中心條目和服務本身。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
參照 儲存庫 中的啟動說明。
The interaction format your AI can nudge.
[A toggle, a toggle that shrinks while pressed, and a like button, each played by nudg]nudg describes a UI interaction in a small JSON file next to your component: its states, the events that move between them, and the motion in between. Your AI coding tool edits the file, nudg checks the edit, and a tiny runtime plays it in your app.
Everyday words map to single fields: bouncier is bounce, slower is duration. The component code doesn't change.
And it shows you, without being asked. nudg_compare plays both versions under the same tap and says first whether you'd even notice ("A clear change: knob.x moves up to 2.1 units differently, settles 0.23 s later", or "Nothing a person will notice; look at an exaggerated version first"), then lays real frames of before and after side by side: in the browser for web apps, and in SwiftUI and Compose on the app's own views. You judge by looking.
This is the toggle above, complete:
on, the knob sits at 20 and the track is green.animate says how. The knob springs there; the color tweens.when says what moves between states. A tap on the track.Interrupt it mid-flight and the spring carries its velocity into the new direction, with nothing extra to write.
Your component binds its parts by name, and nudg plays the file on them:
The look is yours (size, shape, the knob's resting place); the file moves it. Values go straight to the elements' styles, so the component doesn't re-render while things move. With Vite, add nudg() from @nudg/core/vite to the plugins: files are compiled at build time, a file with errors fails the build, and nudg adds about 14 kB gzipped instead of 28. Not using React? The DOM adapter binds data-nudg="knob" attributes instead; see Using nudg.
nudg ships the platforms' own motion as libraries in the same format: SwiftUI's springs, and Material 3's motion tokens, copied from their published values. They share common names like standard, quick and playful, so switching an interaction from iOS feel to Android feel is a one-line diff:
See platform motion for every name and value.
People don't usually ask for duration: 0.35 and bounce: 0.2. They say "make this a FAB", "use tabs", "show it as a bottom sheet", "let the row swipe to delete", or "make the toast feel more iOS". nudg is built to make those words map to reusable interaction patterns instead of one-off code guesses.
The direction is mobile-first: patterns such as fab, tab-bar, bottom-sheet, toast / snackbar, swipe-row, carousel, switch, slider, dialog, list, grid, voice-chat, video-call, camera, music-player and video-player should come with expected parts, states, gestures and platform motion. The host still owns the markup, layout and device APIs; nudg supplies the interaction behavior that an AI can edit and a person can judge.
Give your AI agent the nudg tools over MCP. This is for Claude Code; any MCP client can run the same command:
Or use the CLI yourself on the file:
Node 22.4 or later. See Using nudg for every command and option.
nudg maps familiar UI terms to versioned interaction contracts instead of asking an AI to reinvent them. A recipe names the expected parts, states, events, continuous inputs, host responsibilities, motion, known format gaps, and a validated starter:
The catalog covers every shipped example, from switches, tabs and sheets to voice chat, camera and media players. Patterns the format can't express yet, such as menus, spinners and screen transitions, are listed too, without a starter, so the AI says which part the host does instead of improvising. Recipes remain ordinary nudg documents at runtime; they guide generation without making the core component-specific.
A press, a hover, a toggle or a toast needs no file. Presets are ready-made nudg documents:
When the options aren't enough, nudg preset press > press.nudg.json writes the same document as a file, and from there it's yours to edit, or your AI's.
An agent can't watch an animation, so nudg tells it what happened, in text and in pictures:
The examples site's playground has the same judge view live: Compare with original plays the original beside your edit, a tap on either reaches both, slow motion is a select, and the verdict updates as you type.
[nudg plot output: the knob's position and the track's color over time, tapped twice]nudg plot output for the toggle, tapped again while still moving. The spring turns around smoothly instead of restarting.
The nudg core never draws anything. Events go in, property values come out, and a thin adapter applies them to your views:
@nudg/core/schema.json.Interactive animation usually lives in binary files made in a dedicated studio. An AI can't edit them, a reviewer can't read the diff, and every small change goes back through that one tool. nudg keeps interactions as text in your repo, where your AI coding tool already works. More on the design.
Stable. Version 1.5 (format 1.1) is on npm with a starter for every semantic recipe, taps, hovers, drags, throws and glides, pinches, long press and double tap, keyboard events, scroll direction and input thresholds, pausable timers, continuous app and scroll inputs, measured layout, entry keyframes, loops, staggered delays, screen transitions, a declared host interface, reduced motion, type-safe host names (nudg generate), one "motion is over" callback (onSettle) on every platform, screen-reader activation and adjusting on native, server rendering without a flash, and adapters for the DOM, React (with bridges to MUI, Radix and shadcn/ui), React Native, SwiftUI and Jetpack Compose. Within 1.x, files and APIs only gain; anything that breaks waits for 2.0. See the changelog.
The roadmap tracks development priorities and stage status, from component interactions through screens and flows, native adapters and exploratory standalone content. Mobile-first semantic patterns build on that progression.
nudg gives motion to the components you already have; it doesn't replace them. With shadcn/ui, Radix, Headless UI or React Aria, useNudg(file, { watch: true }) follows the state they show (data-state, aria-*). With MUI, Ant Design or React Bootstrap, nudgTransition(file) plugs into their transition slot. The library keeps behavior and accessibility; the file holds the feel, where an AI can tune it and you can judge it. See Using nudg.
nudg's goal is that a motion change takes one round: you say a word, see before and after, and judge. Whether it does is measured on your machine, in a local log that never leaves it by itself. If you use nudg, please share it now and then:
It shows exactly what it would send (counts only: rounds per change, verdicts, tool calls; no file names, paths or code) and opens a GitHub issue for you to read and submit.
Issues and pull requests are welcome. nudg is designed before it is coded, so for anything beyond a bug fix, please open an issue first to talk through the interaction you want to build. See CONTRIBUTING.md.
來源:README.md,提交 faa19f0
nudg format guide
The nudg format in one page: skeleton, vocabulary, motion forms, structure rules, and which field to change for requests like "bouncier" or "snappier". Read it before writing your first nudg file.
無需輸入參數。
Resolve a semantic UI recipe
Turn a common UI term such as toggle, FAB, sheet, voice call, video chat, or media player into a stable interaction contract: required and optional parts, states, events, continuous inputs, host responsibilities, motion, known format gaps, and a validated starter example. Omit name to list available recipes.
namesourceValidate a nudg file
Check a nudg file. Each problem has a stable code, a JSON pointer path, and a hint that says how to fix it. Pass `file`, or `source` to check text before writing it.
revfilepathsourceSimulate a nudg file
Send events at given times without rendering anything, and get active states and property values over time, plus a per-property summary: min, max, final value, and when it came to rest.
revfilepatheverystartuntileventslayoutsourcepropertiesreducedMotionPlot motion
Draw a motion graph image: each property over time with state bands, events, targets, overshoot (max/min) and settle times. Good for judging feel, e.g. comparing bounce before and after an edit.
outrevfilepathstartuntileventslayoutsourcepropertiesreducedMotionCompare two versions
Two versions of an interaction under the same events, for a person to judge. Says first whether anyone would notice the difference (imperceptible / subtle / clear, per property, with what changed: overshoot, settle time, position), then shows both: with `html`, real A/B filmstrips in two rows; otherwise both curves on one graph. If the change is below perception it proposes looking at an exaggerated version first.
abatouturlfilehtmlopenpagestartuntilbefore另有 8 個Render frames
Draw real frames of the component as one filmstrip image, using the host page's markup and styles (elements with data-nudg names). Needs a local Chrome.
atoutfile必填html必填startuntileventsframesreducedMotionCritique the motion
Whether the motion is good, not only valid. Plays every transition from rest and checks it against the platforms' motion guidelines and accessibility rules: transitions that take too long, press feedback that arrives late, changes nobody can see, fades that bounce, exits slower than entrances, auto-dismiss too short to read, dialogs that can't be closed with Escape. Each finding has a JSON pointer, a fix and its source. Call it once after writing or changing a file, and fix the warnings before showing the person.
revfilepathsourceTypeScript contract for the host
The TypeScript module `nudg generate` writes beside a file (x.nudg.json -> x.nudg.ts): a types-only interface with the file's targets, handled events, continuous inputs and state paths, imports resolved. Hosts pass it to the adapters, e.g. useNudg<ToggleContract>(toggle), so misspelled names fail to compile. After changing a file's names, write the returned text to that path, or run `nudg generate <file>`.
revfilepathsourceShare usage with the nudg project
Prepares a counts-only summary of this machine's nudg log (rounds per change, verdicts, tool calls, versions; no file names, paths, URLs or code) and a link to a prefilled GitHub issue the person can read and submit. Sends nothing by itself. Call it only when the person agreed to share, typically after nudg_compare said a change took several rounds; pass their words as `note`.
noteObserve the real page
Host truth. Opens the real page (its scripts run) in headless Chrome, performs actions on the element as a finger or a key would, measures it every frame (translate, scale, rotation, opacity, size, and whether it is still there), and says what the page actually showed. With `file`, judges the page against the file under the same actions: played as the file says, differs, never shown (the element left the page), or nothing moved. Needs a local Chrome.
onurl必填filestarteventssettlewarmupactions必填selectorviewportreducedMotion已滿足適用檢查項的 90%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
"animate": {- "knob.x": { "spring": { "duration": 0.35, "bounce": 0.25 } },+ "knob.x": { "spring": { "duration": 0.35, "bounce": 0.6 } },{ "nudg": "1.1", "targets": ["knob", "track"], "values": { "knob.x": 0, "track.color": "#D1D5DB" }, "animate": { "knob.x": { "spring": { "duration": 0.35, "bounce": 0.25 } }, "track.color": { "tween": { "duration": 0.2, "ease": "out" } } }, "initial": "off", "states": { "off": { "when": { "track.tap": "on" } }, "on": { "set": { "knob.x": 20, "track.color": "#4ADE80" }, "when": { "track.tap": "off" } } }}import { useNudg } from "@nudg/core/react";import toggle from "./toggle.nudg.json";
function Toggle() { const { bind } = useNudg(toggle); return ( <button ref={bind("track")} aria-label="Wi-Fi" style={{ position: "relative", width: 52, height: 32, padding: 0, border: 0, borderRadius: 16 }}> <span ref={bind("knob")} style={{ position: "absolute", top: 4, left: 4, width: 24, height: 24, borderRadius: "50%", background: "#fff" }} /> </button> );}- "import": ["./motion/apple.nudg.json"],+ "import": ["./motion/material-expressive.nudg.json"], "animate": { "knob.x": "standard", "track.color": "fade" }human UI words -> semantic pattern -> states, events, targets and motion -> compare / observenpm install @nudg/corenpx nudg recipe toggle --source > toggle.nudg.json # a validated starter; `npx nudg recipe` lists them allclaude mcp add nudg -- npx -y @nudg/core mcpnpx nudg validate toggle.nudg.jsonnpx nudg simulate toggle.nudg.json --send [email protected]npx nudg recipe "video chat"npx nudg recipe sheet --jsonnpx nudg recipe toggle --source > toggle.nudg.jsonimport { useNudg, presets } from "@nudg/core/react";
const { bind } = useNudg(presets.press({ scale: 0.96 }));<button ref={bind("button")}>Save</button>import { playDoc } from "@nudg/core/dom";import { presets } from "@nudg/core";
playDoc(presets.toast({ duration: 3 }), document.querySelector(".toast")); your app (web, React Native, SwiftUI, Compose, ...) │ events: tap, drag, hover, focus, app events ▼ ┌──────────────── nudg core ────────────────┐ │ states + clock + motion math (headless) │ └────────────────────────────────────────────┘ │ values: knob.x = 18.3, track.color = #4ADE80 ▼ adapter sets them on your viewsnpx @nudg/core log --share