Install Keyframery by hand
Add Keyframery's animated UI SDK components to any React 19 and Tailwind CSS v4 app without the shadcn CLI: dependencies, motion tokens, helpers and files.
Keyframery's components are plain files. The CLI copies them and adds a block of CSS; this page does the same by hand. It works in any React 19 app with Tailwind CSS v4.
Set up Tailwind CSS and shadcn's theme
The components use shadcn's colour variables (--background, --primary, --muted and the rest), a cn helper in lib/utils.ts and the @/ import alias. If your app doesn't have them yet, follow shadcn's manual installation first.
Add the dependencies
npm install @ui-sdk/[email protected] @ui-sdk/[email protected] clsx tailwind-mergeUI SDK is pinned to the version the components are tested with.
Add the motion tokens
Paste this whole block into your global stylesheet, below @import "tailwindcss";. It's exactly what the CLI adds.
@layer base {
:root {
--kf-speed: 1;
--ease-house: cubic-bezier(0.22, 1, 0.36, 1);
--ease-spring: linear(0, 0.001 0.5%, 0.010 1.5%, 0.036 2.8%, 0.082 4.4%, 0.153 6.3%, 0.247 8.5%, 0.358 10.9%, 0.480 13.5%, 0.604 16.3%, 0.721 19.3%, 0.825 22.4%, 0.911 25.8%, 0.976 29.3%, 1.019 33.0%, 1.044 36.8%, 1.054 40.8%, 1.052 45.0%, 1.044 49.3%, 1.033 53.8%, 1.022 58.4%, 1.012 63.1%, 1.005 68.0%, 1.000 73.0%, 0.998 78.1%, 0.997 83.4%, 0.997 88.8%, 0.998 94.3%, 1);
--ease-pop: linear(0, 0.002 0.5%, 0.019 1.5%, 0.066 2.8%, 0.150 4.4%, 0.276 6.3%, 0.435 8.5%, 0.612 10.9%, 0.789 13.5%, 0.945 16.3%, 1.064 19.3%, 1.136 22.4%, 1.163 25.8%, 1.151 29.3%, 1.114 33.0%, 1.067 36.8%, 1.023 40.8%, 0.992 45.0%, 0.976 49.3%, 0.974 53.8%, 0.980 58.4%, 0.989 63.1%, 0.997 68.0%, 1.003 73.0%, 1.004 78.1%, 1.004 83.4%, 1.002 88.8%, 1.000 94.3%, 1);
}
[data-motion="springy"] {
--kf-speed: 1;
--ease-spring: linear(0, 0.001 0.5%, 0.010 1.5%, 0.036 2.8%, 0.082 4.4%, 0.153 6.3%, 0.247 8.5%, 0.358 10.9%, 0.480 13.5%, 0.604 16.3%, 0.721 19.3%, 0.825 22.4%, 0.911 25.8%, 0.976 29.3%, 1.019 33.0%, 1.044 36.8%, 1.054 40.8%, 1.052 45.0%, 1.044 49.3%, 1.033 53.8%, 1.022 58.4%, 1.012 63.1%, 1.005 68.0%, 1.000 73.0%, 0.998 78.1%, 0.997 83.4%, 0.997 88.8%, 0.998 94.3%, 1);
--ease-pop: linear(0, 0.002 0.5%, 0.019 1.5%, 0.066 2.8%, 0.150 4.4%, 0.276 6.3%, 0.435 8.5%, 0.612 10.9%, 0.789 13.5%, 0.945 16.3%, 1.064 19.3%, 1.136 22.4%, 1.163 25.8%, 1.151 29.3%, 1.114 33.0%, 1.067 36.8%, 1.023 40.8%, 0.992 45.0%, 0.976 49.3%, 0.974 53.8%, 0.980 58.4%, 0.989 63.1%, 0.997 68.0%, 1.003 73.0%, 1.004 78.1%, 1.004 83.4%, 1.002 88.8%, 1.000 94.3%, 1);
}
[data-motion="calm"] {
--kf-speed: 1.35;
--ease-spring: linear(0, 0.001 0.5%, 0.007 1.5%, 0.024 2.8%, 0.055 4.4%, 0.102 6.4%, 0.163 8.5%, 0.235 10.9%, 0.316 13.5%, 0.400 16.3%, 0.484 19.3%, 0.565 22.4%, 0.641 25.8%, 0.708 29.3%, 0.767 33.0%, 0.818 36.8%, 0.859 40.8%, 0.893 45.0%, 0.920 49.3%, 0.941 53.8%, 0.957 58.4%, 0.970 63.1%, 0.979 68.0%, 0.985 73.0%, 0.990 78.1%, 0.993 83.4%, 0.995 88.8%, 0.997 94.3%, 1);
--ease-pop: linear(0, 0.001 0.5%, 0.006 1.5%, 0.022 2.8%, 0.052 4.4%, 0.099 6.4%, 0.161 8.5%, 0.237 10.9%, 0.325 13.5%, 0.419 16.3%, 0.515 19.3%, 0.609 22.4%, 0.697 25.8%, 0.775 29.3%, 0.841 33.0%, 0.896 36.8%, 0.938 40.8%, 0.970 45.0%, 0.991 49.3%, 1.005 53.8%, 1.012 58.4%, 1.015 63.1%, 1.015 68.0%, 1.013 73.0%, 1.011 78.1%, 1.008 83.4%, 1.005 88.8%, 1.003 94.3%, 1);
}
[data-motion="snappy"] {
--kf-speed: 0.6;
--ease-spring: linear(0, 0.001 0.5%, 0.007 1.5%, 0.022 2.8%, 0.052 4.4%, 0.098 6.4%, 0.159 8.5%, 0.234 10.9%, 0.319 13.5%, 0.410 16.3%, 0.502 19.3%, 0.592 22.4%, 0.676 25.8%, 0.752 29.3%, 0.816 33.0%, 0.870 36.8%, 0.913 40.8%, 0.946 45.0%, 0.969 49.3%, 0.986 53.8%, 0.996 58.4%, 1.002 63.1%, 1.005 68.0%, 1.006 73.0%, 1.006 78.1%, 1.005 83.4%, 1.004 88.8%, 1.003 94.3%, 1);
--ease-pop: linear(0, 0.001 0.5%, 0.009 1.5%, 0.032 2.8%, 0.074 4.4%, 0.139 6.4%, 0.225 8.5%, 0.329 10.9%, 0.445 13.5%, 0.564 16.3%, 0.681 19.3%, 0.787 22.4%, 0.877 25.8%, 0.948 29.3%, 1.000 33.0%, 1.033 36.8%, 1.050 40.8%, 1.054 45.0%, 1.050 49.3%, 1.041 53.8%, 1.030 58.4%, 1.019 63.1%, 1.010 68.0%, 1.004 73.0%, 1.000 78.1%, 0.998 83.4%, 0.997 88.8%, 0.997 94.3%, 1);
}
[data-motion="playful"] {
--kf-speed: 1.15;
--ease-spring: linear(0, 0.001 0.5%, 0.010 1.5%, 0.033 2.8%, 0.079 4.4%, 0.149 6.4%, 0.243 8.5%, 0.359 10.9%, 0.489 13.5%, 0.624 16.3%, 0.756 19.3%, 0.875 22.4%, 0.974 25.8%, 1.047 29.3%, 1.095 33.0%, 1.117 36.8%, 1.118 40.8%, 1.104 45.0%, 1.080 49.3%, 1.054 53.8%, 1.029 58.4%, 1.009 63.1%, 0.995 68.0%, 0.988 73.0%, 0.986 78.1%, 0.987 83.4%, 0.991 88.8%, 0.995 94.3%, 1);
--ease-pop: linear(0, 0.003 0.5%, 0.023 1.5%, 0.080 2.8%, 0.185 4.4%, 0.341 6.4%, 0.539 8.5%, 0.757 10.9%, 0.968 13.5%, 1.140 16.3%, 1.250 19.3%, 1.286 22.4%, 1.255 25.8%, 1.176 29.3%, 1.078 33.0%, 0.991 36.8%, 0.935 40.8%, 0.918 45.0%, 0.933 49.3%, 0.965 53.8%, 0.997 58.4%, 1.018 63.1%, 1.023 68.0%, 1.017 73.0%, 1.006 78.1%, 0.997 83.4%, 0.993 88.8%, 0.995 94.3%, 1);
}
}
@utility ease-house {
transition-timing-function: var(--ease-house);
}
@utility ease-spring {
transition-timing-function: var(--ease-spring);
}
@utility ease-pop {
transition-timing-function: var(--ease-pop);
}Add the shared helpers
Every component imports its speed prop and KeyframeryProvider from this file. Save it as lib/keyframery.tsx.
"use client"
/* Speed for Keyframery components, as a prop.
Every duration in the components is written as calc(Nms * var(--kf-speed, 1)). These helpers set
that variable for you, so nobody has to know it exists:
<Tabs speed="fast"> one component
<KeyframeryProvider speed="slow"> the whole app
Parts that render in a portal (popups, menus, dialogs) are not inside the component in the page,
so they pick the speed up through React context instead of the CSS cascade. */
import * as React from "react"
/** `"fast"` (0.6×), `"normal"` (1×), `"slow"` (1.4×), or any multiplier: `0.8` is 20% quicker. */
export type Speed = "fast" | "normal" | "slow" | number
export type SpeedProps = {
/** How fast the component moves. `"fast"` (0.6×), `"normal"` (1×), `"slow"` (1.4×), or a multiplier like `0.8`. Popups follow it too. */
speed?: Speed
}
export type MotionStyleName = "springy" | "calm" | "snappy" | "playful"
const presets = { fast: 0.6, normal: 1, slow: 1.4 } as const
export function speedValue(speed: Speed | undefined): number | undefined {
if (speed === undefined) return undefined
return typeof speed === "number" ? speed : presets[speed]
}
const SpeedContext = React.createContext<number | undefined>(undefined)
type SpeedStyle = React.CSSProperties & { "--kf-speed"?: number }
/* Wraps a component's parts. Without `speed` it adds nothing to the page. With it, a
`display: contents` element carries the variable to the parts in place, and context carries it
to the parts in a portal. */
export function Speed({ speed, children }: SpeedProps & { children?: React.ReactNode }) {
const value = speedValue(speed)
if (value === undefined) return children
const style: SpeedStyle = { display: "contents", "--kf-speed": value }
return (
<SpeedContext value={value}>
<span data-slot="speed" style={style}>
{children}
</span>
</SpeedContext>
)
}
/* For parts that render in a portal: adds the speed of the component they belong to. `style` can
be an object or UI SDK's function of the part's state. */
export function useSpeedStyle<S>(style: S): S {
return withSpeed(style, React.useContext(SpeedContext))
}
/* Adds a speed to a part's own `style`, for a part that takes `speed` and renders in a portal. */
export function withSpeed<S>(style: S, speed: Speed | undefined): S {
const value = speedValue(speed)
if (value === undefined) return style
if (typeof style === "function")
return ((state: unknown) => ({ "--kf-speed": value, ...(style as (s: unknown) => React.CSSProperties)(state) })) as S
return { "--kf-speed": value, ...(style as React.CSSProperties | undefined) } as S
}
/* UI SDK parts take `children` as content or as a function of the part's state. A styled part
that adds elements of its own (a chevron, a moving key) wraps either form with this, so the
function form keeps working. */
export function mapChildren<State>(
children: React.ReactNode | ((state: State) => React.ReactNode),
wrap: (content: React.ReactNode) => React.ReactNode,
): React.ReactNode | ((state: State) => React.ReactNode) {
return typeof children === "function" ? (state: State) => wrap(children(state)) : wrap(children)
}
/* Sets speed and motion style for the whole app, popups included. A component's own `speed` prop
still wins inside that component. Server-rendered pages can put `data-motion` on <html> directly
to avoid a change after hydration. */
export function KeyframeryProvider({
speed,
motion,
children,
}: SpeedProps & {
/** The motion style for the whole app: `"springy"` (the default), `"calm"`, `"snappy"` or `"playful"`. */
motion?: MotionStyleName
children?: React.ReactNode
}) {
const value = speedValue(speed)
React.useLayoutEffect(() => {
const html = document.documentElement
if (motion) html.setAttribute("data-motion", motion)
if (value !== undefined) html.style.setProperty("--kf-speed", String(value))
return () => {
if (motion) html.removeAttribute("data-motion")
if (value !== undefined) html.style.removeProperty("--kf-speed")
}
}, [motion, value])
return children
}Copy the components
Every component page has a Manual tab with its files: the styled component, its primitive and, for some, a core file. Copy them to the paths shown, under components/keyframery/.
components/keyframery/tabs.tsx
components/keyframery/primitives/tabs.tsxIf your aliases differ from @/components and @/lib, change the imports at the top of each file.
Add a preset (optional)
Build one at Keyframery Create and press Copy CSS. Paste it into your global stylesheet after the motion tokens. If the preset uses a font, install it from Fontsource as the copied CSS says, for example:
npm install @fontsource-variable/inter@import "@fontsource-variable/inter";That's it
Import a component and use it:
import { Tabs, TabsList, TabsPanel, TabsPanels, TabsTab } from "@/components/keyframery/tabs"Something not moving? Check that the motion tokens are in the stylesheet your app loads. More in Troubleshooting.
Questions
When should I install by hand?
When your app can't use the shadcn CLI, or you want to see every line before it lands. The result is the same files and CSS the CLI writes.
Can I use a preset without the CLI?
Yes. On Keyframery Create, Copy CSS gives you the preset as plain CSS to paste into your global stylesheet.
Astro
Add Keyframery's animated UI SDK components to an Astro site as React islands: install them with the shadcn CLI and hydrate each one with a client directive.
Swap the import
Every Keyframery primitive has the same parts and props as its UI SDK component. Change one import line and the component animates. Your markup and styles stay.