studio-keychain
v1.0.3
Published
Interactive 3D vector charm and keyring physics simulation for React and Next.js.
Maintainers
Readme
Studio Keychain
Interactive 3D vector charm and keyring physics simulation for React and Next.js.
Overview
Studio Keychain parses SVG vector paths and URLs into watertight 3D meshes with real-time rigid-body chain physics, PBR metallic finishes, and studio lighting. It can be embedded as a React component on any background or integrated into design customizers.
Features
- Vector SVG Extrusion: Converts raw SVG strings, Data URIs, and HTTPS URLs into 3D geometry with bevels and multi-layer enamel faces.
- Rigid-Body Physics: Cannon.js simulation with multi-joint cone-twist constraints, rotational inertia, and drag/tap pointer interactions.
- 22+ PBR Finishes: Includes Gold, Silver Chrome, Holographic Foil, Platinum, Titanium, Rose Gold, Damascus, and custom color tints.
- Transparent Canvas: Supports transparent alpha rendering for placement over cards, modals, or gradient backgrounds.
- Minimal Loader: Built-in minimal loading spinner with full support for custom loader elements.
- Responsive Layout: Adapts automatically to parent container boundaries via
ResizeObserver.
Installation
# npm
npm install studio-keychain
# pnpm
pnpm add studio-keychain
# yarn
yarn add studio-keychain
# bun
bun add studio-keychainQuick Start
React / Vite
import { Keychain } from "studio-keychain";
export default function App() {
return (
<div style={{ width: "100%", height: "500px", position: "relative" }}>
<Keychain
svg="https://svgl.app/library/react.svg"
finish="Gold"
style="Shiny"
transparent={true}
/>
</div>
);
}Next.js (App Router)
WebGL and physics engines require client browser APIs. Use next/dynamic with SSR disabled:
"use client";
import dynamic from "next/dynamic";
const Keychain = dynamic(
() => import("studio-keychain").then((mod) => mod.Keychain),
{ ssr: false }
);
export default function Page() {
return (
<main className="w-screen h-screen">
<Keychain
svg="https://svgl.app/library/nextjs.svg"
finish="Silver"
style="Shiny"
transparent={true}
/>
</main>
);
}Dual Charms Setup
import { Keychain } from "studio-keychain";
export default function DualCharmDemo() {
return (
<div style={{ width: "100%", height: "600px", position: "relative" }}>
<Keychain
charm1="https://svgl.app/library/github-light.svg"
charm2="https://svgl.app/library/tailwind.svg"
finish="HoloFoil"
style="Shiny"
transparent={true}
/>
</div>
);
}Props Reference
| Prop | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| svg | string | — | Single SVG string or URL. Shorthand for charm1. |
| charm1 / charm1Svg | string | YouTube logo | Primary charm SVG string or URL. |
| charm2 / charm2Svg | string | Gemini logo | Secondary charm SVG string or URL. |
| charms | (string \| CharmConfig)[] | — | Array of charm configurations. |
| charmCount | 1 \| 2 | 2 (if charm2 present) | Total number of charms on the ring. |
| finish | FinishId | "Silver" | Metallic or mineral finish preset. |
| style | "Shiny" \| "Matte" | "Shiny" | Surface finish reflectivity. |
| customColor | string | "#ec4899" | Hex color used when finish="Custom". |
| transparent | boolean | false | Enables WebGL alpha transparency. |
| background | string \| null | null | Solid background color or "transparent". |
| isDark | boolean | false | Adjusts specular lighting for dark surfaces. |
| interactive | boolean | true | Enables pointer drag and physics impulse. |
| showLoader | boolean | true | Shows loading indicator during fetch/build. |
| loader | ReactNode \| boolean | Default Spinner | Custom React loader component or false. |
| proxyUrl | string | — | Custom CORS proxy template for remote URLs. |
| className | string | "" | CSS classes for the container element. |
| styleProps | CSSProperties | undefined | Inline styles for the container element. |
| onLoad | () => void | — | Callback fired when rendering is complete. |
| onError | (err: Error) => void | — | Callback fired on fetch or parse failure. |
| onLoadingChange | (loading: boolean) => void | — | Callback fired when loading state changes. |
Available Finishes
Import FINISH_OPTIONS or FINISH_MAP for programmatic access:
| Finish ID | Name | Tone |
| :--- | :--- | :--- |
| "Silver" | Silver Chrome | Polished chrome |
| "Gold" | 24K Gold | Warm yellow gold |
| "Platinum" | Platinum | Bright crisp platinum |
| "HoloFoil" | Holographic Foil | Iridescent chromatic dispersion |
| "Rose Gold" | Rose Gold | Warm copper rose |
| "Champagne" | Champagne Gold | Pale soft champagne |
| "Brass" | Antique Brass | Brushed industrial brass |
| "Copper" | Sunset Copper | Vibrant sunset copper |
| "Bronze" | Antique Bronze | Deep classical bronze |
| "Titanium" | Titanium Grey | Space-grade brushed titanium |
| "Pewter" | Brushed Pewter | Matte tactile pewter |
| "Sandblasted" | Raw Sandblasted | High-roughness matte alloy |
| "Graphite" | Graphite Grey | Deep gunmetal graphite |
| "Damascus" | Damascus Pearl | Dark pearlescent steel |
| "Gunmetal" | Space Black | Deep space black |
| "Ruby" | Imperial Ruby | Gemstone ruby red |
| "Amethyst" | Amethyst Violet | Mineral purple |
| "Cobalt" | Navy Cobalt | Deep vibrant blue chrome |
| "Midnight" | Midnight Navy | Dark twilight navy |
| "Steel Blue" | Steel Blue | Crisp industrial blue-grey |
| "Emerald" | Emerald Chrome | Lustrous mineral green |
| "Custom" | Custom Tint | Custom hex tint from customColor |
Advanced Usage
Custom Loading State
import { Keychain } from "studio-keychain";
export default function CustomLoaderExample() {
return (
<Keychain
svg="https://svgl.app/library/supabase.svg"
loader={
<div style={{ fontSize: "12px", opacity: 0.6 }}>
Loading 3D mesh...
</div>
}
/>
);
}Raw SVG Code
import { Keychain } from "studio-keychain";
const STAR_SVG = `
<svg width="100" height="100" viewBox="0 0 24 24" fill="#f59e0b">
<polygon points="12,2 15,9 22,9 17,14 19,21 12,17 5,21 7,14 2,9 9,9" />
</svg>
`;
export default function RawSvgExample() {
return <Keychain svg={STAR_SVG} finish="Gold" />;
}Technical Stack
- Graphics: Three.js, SVGLoader, PMREM RoomEnvironment
- Physics: Cannon.js
- Framework: React, Next.js, TypeScript
- Bundler: tsup (ESM & CJS output)
License
MIT License. See LICENSE for details.
