Pitsi UI
  • Home
  • Docs
1
1
Sections
  • Get Started
  • Components
  • Animations
  • MCP Server
  • Changelog
Get Started
  • Installation
  • CLI
  • llms.txt
Components
  • Accordion
  • Alert Dialog
  • Alert
  • Aspect Ratio
  • Avatar
  • Badge
  • Breadcrumb
  • Button Group
  • Button
  • Card
  • Carousel
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • Container
  • Context Menu
  • Data Table
  • Dialog
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • Flex
  • Form
  • Grid
  • Hero Button
  • Hover Card
  • Input Group
  • Input OTP
  • Input
  • Item
  • Kbd
  • Label
  • Menubar
  • Native Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Radio Group
  • Resizable
  • Responsive
  • Scroll Area
  • Segmented Control
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spacer
  • Spinner
  • Squircle
  • Switch
  • Table
  • Tabs
  • Textarea
  • Theme Toggle
  • Toggle Group
  • Toggle
  • Tooltip
  • Typography
  • Unicorn Wrapper
Animations
  • Background Image Parallax
  • Card Swipe Carousel
  • Cards Parallax
  • Parallax Scroll
  • Perspective Carousel
  • Perspective Section Transition
  • Scroll Expand
  • Scroll Fade
  • Scroll Scale
  • Slide Down
  • Slide Up
  • Smooth Parallax Scroll
  • Smooth Scroll
  • Sticky Footer
  • Text Along Path
  • Text Gradient Opacity
  • Text Parallax
  • Transforms 3d
  • Zoom Parallax

Unicorn Wrapper

PreviousNext

A wrapper component for Unicorn Studio projects with optimized performance and error handling.

Powered by
shadcn/ui
Docs API Reference
"use client"

import { UnicornWrapper } from "@/components/ui/unicorn-wrapper"

export function UnicornWrapperDemo() {
  return (
    <div className="flex size-[400px] items-center justify-center overflow-hidden rounded-2xl">
      <UnicornWrapper
        className="h-full w-full"
        projectId="OpSYWgbtD97AYWlhMu2W"
        production
      />
    </div>
  )
}

Installation

pnpm dlx pitsi@latest add unicorn-wrapper

Usage

import { UnicornWrapper } from "@/components/ui/unicorn-wrapper"
<UnicornWrapper className="h-[400px] w-full" projectId="your-project-id" />

About Unicorn Studio

Unicorn Studio is a tool for creating interactive 3D and motion graphics that can be embedded in React applications. The UnicornWrapper component provides an optimized way to integrate Unicorn Studio projects into your pitsi/ui applications.

Features

  • Performance Optimized: Uses Intersection Observer to only render projects when visible in viewport
  • Error Handling: Gracefully handles errors and prevents crashes
  • Lazy Loading: Projects load only when they enter the viewport (with 50px margin)
  • Production Ready: Automatically enables production mode for better performance
  • Automatic Cleanup: Properly cleans up observers on unmount
  • Ref Support: Fully supports React refs for advanced use cases

Examples

Basic Project

<UnicornWrapper projectId="abc123xyz" className="h-[500px] w-full" />

Responsive Project

<div className="container mx-auto">
  <UnicornWrapper projectId="def456uvw" className="aspect-video w-full" />
</div>

Project with Custom Styling

<UnicornWrapper
  projectId="ghi789rst"
  className="h-96 rounded-lg border shadow-lg"
/>

Props

The component accepts all props from UnicornSceneProps from the unicornstudio-react package, plus:

PropTypeDefaultDescription
projectIdstring-The unique project ID from Unicorn Studio
classNamestring-Additional CSS classes to apply to the wrapper
productionbooleantrueWhether to enable production mode (optimized rendering)
onError() => void-Callback when an error occurs (automatically handled)

For the complete list of available props, see the Unicorn Studio React documentation.

How It Works

The wrapper enhances the base UnicornScene component with:

  1. Intersection Observer: Monitors when the component enters/exits the viewport
  2. Conditional Rendering: Only renders the project when visible (with 50px margin)
  3. Error Boundary: Catches errors and unmounts the component to prevent crashes
  4. Ref Forwarding: Supports both callback and object refs

This approach significantly improves performance when you have multiple projects on a page or projects that are initially offscreen.

Getting Your Project ID

To use this component, you'll need:

  1. Create a project at unicorn.studio
  2. Get your project ID from the Unicorn Studio dashboard
  3. Use the project ID in the component props

Notes

  • The component requires unicornstudio-react to be installed
  • Projects only load when they're within 50px of entering the viewport
  • Production mode is enabled by default for better performance
  • If a project errors, it will automatically unmount to prevent app crashes
  • The wrapper has a 10% intersection threshold for triggering visibility
TypographyAnimations

On This Page

InstallationUsageAbout Unicorn StudioFeaturesExamplesBasic ProjectResponsive ProjectProject with Custom StylingPropsHow It WorksGetting Your Project IDNotes

© 2025 pitsi/ui. All rights reserved.

Sign In