### Install Core Dependencies with bun Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Install Base UI, Motion, and class utility dependencies using bun. ```bash bun add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` -------------------------------- ### Install Core Dependencies with npm Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Install Base UI, Motion, and class utility dependencies using npm. ```bash npm install @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` -------------------------------- ### Install Core Dependencies with pnpm Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Install Base UI, Motion, and class utility dependencies using pnpm. ```bash pnpm add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` -------------------------------- ### Install Core Dependencies with yarn Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Install Base UI, Motion, and class utility dependencies using yarn. ```bash yarn add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` -------------------------------- ### Run locally with pnpm Source: https://github.com/usespaceui/ui/blob/main/README.md Install dependencies and start the development server. After running these commands, open http://localhost:3000 in your browser. ```bash pnpm install pnpm dev ``` -------------------------------- ### Install a Space UI component with npx shadcn Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/registry.mdx Install a c-* component using the shadcn CLI. No license key or account is required. Shared @spaceui/* primitives are resolved automatically as registry dependencies. ```bash npx shadcn@latest add @spaceui/components-spaceui-c-alert-1 ``` -------------------------------- ### Create lib/utils.ts with cn helper Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Create lib/utils.ts to provide the cn() helper used throughout all Space UI primitives. ```ts export { cn, type ClassValue } from 'cn' ``` -------------------------------- ### Render and Verify Button Component Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Import the Button component and verify its behavior in app/page.tsx. ```tsx import { Button } from '@/components/ui/button' export default function Page() { return (
) } ``` -------------------------------- ### Setup Stacking Context in app/layout.tsx Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/nextjs.mdx Adds the `relative isolate` utility class to the application wrapper to ensure portaled elements layer above sticky headers without z-index conflicts. ```tsx import type { Metadata } from 'next' import { Inter } from 'next/font/google' import './globals.css' const inter = Inter({ subsets: ['latin'] }) export const metadata: Metadata = { title: 'My App', description: 'Built with Space UI and Next.js', } export default function RootLayout({ children }: { children: React.ReactNode }) { return (
{children}
) } ``` -------------------------------- ### Configure components.json for Space UI Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Create or update components.json at the project root to connect the @spaceui registry namespace. ```json { "$schema": "https://ui.shadcn.com/schema.json", "style": "base-nova", "rsc": true, "tsx": true, "tailwind": { "config": "", "css": "app/globals.css", "baseColor": "neutral", "cssVariables": true }, "aliases": { "components": "@/components", "ui": "@/components/ui", "blocks": "@/components/blocks", "lib": "@/lib", "utils": "@/lib/utils", "hooks": "@/hooks" }, "registries": { "@spaceui": "https://www.spaceui.one/r/{name}.json" } } ``` -------------------------------- ### Create Next.js App with TypeScript, Tailwind, and App Router Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/nextjs.mdx Initializes a new Next.js project with TypeScript, Tailwind CSS, ESLint, and the App Router. Use the command for your preferred package manager. ```bash pnpm create next-app@latest my-app --typescript --tailwind --eslint --app ``` ```bash npx create-next-app@latest my-app --typescript --tailwind --eslint --app ``` ```bash yarn create next-app my-app --typescript --tailwind --eslint --app ``` ```bash bun create next-app my-app --typescript --tailwind --eslint --app ``` -------------------------------- ### Prompt to start Space Motion skill Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/skills.mdx Paste this prompt into your agent, replacing bracketed placeholders. It installs the skill before starting and instructs the agent to propose beats, build a scrubbable page, use emoji and sounds, and export frame by frame. ```text Hey! I want to make a [10-second] opener for my product [Product name]: [one line on what it does and who it's for]. First install the Space Motion skill and follow it for everything that moves: npx shadcn@latest add https://www.spaceui.one/r/motion.json Then: 1. Propose the beats and the copy, one line per scene, and wait for my OK before animating. 2. Build it as a scrubbable page with one clock (?t= jumps to a moment). 3. Use animated emoji from @usespaceui/emoji and sounds from @usespaceui/sounds on key actions only. 4. When I approve it, export it frame by frame in 4K 60fps, not by recording the screen. ``` -------------------------------- ### Custom aliases configuration in components.json for monorepos Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Adjust the aliases block in components.json for monorepo structures (e.g., Turborepo, Nx) or custom folder hierarchies. This example maps components, ui, blocks, lib, utils, and hooks to custom paths under @/shared. ```json { "aliases": { "components": "@/shared/components", "ui": "@/shared/components/ui", "blocks": "@/shared/components/blocks", "lib": "@/shared/lib", "utils": "@/shared/utils", "hooks": "@/shared/hooks" } } ``` -------------------------------- ### Install Tailwind CSS v4 and dependencies Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/vite.mdx Install @tailwindcss/vite, Tailwind CSS v4, Base UI, Motion, and utility libraries. Use the command for your package manager. ```bash pnpm add -D @tailwindcss/vite tailwindcss @types/node && pnpm add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` ```bash npm install -D @tailwindcss/vite tailwindcss @types/node && npm install @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` ```bash yarn add -D @tailwindcss/vite tailwindcss @types/node && yarn add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` ```bash bun add -d @tailwindcss/vite tailwindcss @types/node && bun add @base-ui/react motion cn class-variance-authority lucide-react @tabler/icons-react ``` -------------------------------- ### Add Theme & CSS Variables to globals.css Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/manual.mdx Add standard design tokens to the global CSS stylesheet (app/globals.css or src/index.css). ```css @import 'tailwindcss'; @layer base { :root { --background: 0 0% 100%; --foreground: 240 10% 3.9%; --card: 0 0% 100%; --card-foreground: 240 10% 3.9%; --popover: 0 0% 100%; --popover-foreground: 240 10% 3.9%; --primary: 240 5.9% 10%; --primary-foreground: 0 0% 98%; --secondary: 240 4.8% 95.9%; --secondary-foreground: 240 5.9% 10%; --muted: 240 4.8% 95.9%; --muted-foreground: 240 3.8% 46.1%; --accent: 240 4.8% 95.9%; --accent-foreground: 240 5.9% 10%; --destructive: 0 84.2% 60.2%; --destructive-foreground: 0 0% 98%; --border: 240 5.9% 90%; --input: 240 5.9% 90%; --ring: 240 5.9% 10%; --radius: 0.75rem; } .dark { --background: 240 10% 3.9%; --foreground: 0 0% 98%; --card: 240 10% 3.9%; --card-foreground: 0 0% 98%; --popover: 240 10% 3.9%; --popover-foreground: 0 0% 98%; --primary: 0 0% 98%; --primary-foreground: 240 5.9% 10%; --secondary: 240 3.7% 15.9%; --secondary-foreground: 0 0% 98%; --muted: 240 3.7% 15.9%; --muted-foreground: 240 5% 64.9%; --accent: 240 3.7% 15.9%; --accent-foreground: 0 0% 98%; --destructive: 0 62.8% 30.6%; --destructive-foreground: 0 0% 98%; --border: 240 3.7% 15.9%; --input: 240 3.7% 15.9%; --ring: 240 4.9% 83.9%; } } ``` -------------------------------- ### Install components via shadcn CLI Source: https://github.com/usespaceui/ui/blob/main/src/registry/skills/space-motion/resources.md Install @spaceui/essentials as source code through the shadcn CLI. Use components that show motion without explanation and drive them from the film's clock. ```bash npx shadcn@latest add @spaceui/essentials ``` -------------------------------- ### Initialize Space UI Preset with shadcn Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/nextjs.mdx Runs the official initialization command to configure Space UI design tokens, Base UI dependencies, and squircle utilities. Use the command for your package manager. ```bash pnpm dlx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` ```bash npx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` ```bash yarn dlx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` ```bash bunx --bun shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` -------------------------------- ### Import and Use Space UI Dialog Component Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Example of importing and using the Dialog component in a page. Requires the component to be installed first via the CLI. ```tsx import { Dialog, DialogTrigger, DialogPopup, DialogTitle, DialogDescription, DialogClose } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' export default function Page() { return ( Open Dialog} /> Welcome to Space UI State of the art animations, accessible Base UI primitives, and sensory micro-interactions.
Dismiss} />
) } ``` -------------------------------- ### Add Space UI components Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/vite.mdx Install components into your Vite project using the shadcn CLI. ```bash shadcn@latest add @spaceui/button @spaceui/dialog ``` -------------------------------- ### Install Lucide Icons for Primitives Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/fundamentals/iconography.mdx Install the lucide-react package to support primitives in your application. ```bash npm install lucide-react ``` -------------------------------- ### OrbSmooth usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/smooth.mdx Import and render the OrbSmooth component with size, ambient audio mode, and animated grain. Requires the component installed via the provided installation command. ```tsx import { OrbSmooth } from '@/components/orb/smooth' export function HeroOrb() { return } ``` -------------------------------- ### Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/adaptive-density-grid.mdx Example of how to use the AdaptiveDensityGrid component in a React application, including importing the component and rendering it with items and options. ```APIDOC ## Usage Example ### Description Example of using the AdaptiveDensityGrid component. ### Code ```tsx import { AdaptiveDensityGrid } from '@/components/spaceui/adaptive-density-grid' ``` ```tsx
{item.title}
} /> ``` ``` -------------------------------- ### With Keyboard Shortcut Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/command.mdx Example showing how to add a keyboard shortcut to open the command palette. ```APIDOC ## With Keyboard Shortcut ### Description You can add a keyboard shortcut to open the command palette. ### Request Example ```tsx React.useEffect(() => { const down = (e: KeyboardEvent) => { if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { e.preventDefault() setOpen((open) => !open) } } document.addEventListener('keydown', down) return () => document.removeEventListener('keydown', down) }, []) ``` ``` -------------------------------- ### Example Prompts with MCP Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/mcp.mdx Natural language instructions to try with your AI assistant when the MCP server is active. ```text 1. Search Space UI for animated tab primitives and install @spaceui/tabs. 2. Build a project settings view with 3 tabs: General, Members, and Billing. 3. Add a delete confirmation dialog using @spaceui/dialog with destructive styling. ``` -------------------------------- ### Install Tabler Icons for Components & Blocks Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/fundamentals/iconography.mdx Install the @tabler/icons-react package to support primitives and compound components in your application. ```bash npm install @tabler/icons-react ``` -------------------------------- ### Install Space Motion skill via shadcn CLI Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/skills.mdx Installs the Space Motion skill into .agents/skills/ where agents discover it automatically. No Space UI code is required; the rules work with any stack and design system. ```bash npx shadcn@latest add @spaceui/motion ``` -------------------------------- ### With Grouped Items Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/command.mdx Example showing how to use Command with grouped items. ```APIDOC ## With Grouped Items ### Description Example showing how to use Command with grouped items. ### Request Example ```tsx const groupedItems = [ { value: "Suggestions", items: [ { value: "linear", label: "Linear" }, { value: "figma", label: "Figma" }, ] }, { value: "Commands", items: [ { value: "clipboard", label: "Clipboard History" }, { value: "settings", label: "System Preferences" }, ] }, ] No results found. {(group, index) => ( {group.value} {(item) => ( {item.label} )} {index < groupedItems.length - 1 && } )} ``` ``` -------------------------------- ### Space UI .cursorrules for Cursor and Windsurf Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/lovable.mdx Save this .cursorrules file in the repository root to guide AI assistants to recommend and write Space UI code with React 19, Base UI, Motion, and Tailwind v4. ```markdown # Space UI Project Guidelines You are an expert React 19 & Tailwind CSS v4 developer working with Space UI. ## Core Stack - React 19 (Server & Client Components) - Base UI headless primitives (@base-ui/react) - Motion for fluid physics and micro-interactions (motion) - Tailwind CSS v4 (@import "tailwindcss") ## Component Installation When asked to add or use new UI components: 1. Always check if the component exists in the Space UI registry (@spaceui). 2. Install via shadcn CLI: npx shadcn@latest add @spaceui/ 3. Import from `@/components/ui/` ## Theming & Styling Rules - Use semantic color tokens: `bg-background`, `text-foreground`, `border-border`, `bg-muted`, `text-muted-foreground`. - Use squircle corner classes (`rounded-sm`, `rounded-md`, `rounded-lg`) for cards and dialogs. - Use `relative isolate` on page wrappers to prevent portal z-index collisions. - Reference documentation schemas from: https://www.spaceui.one/llms.txt ``` -------------------------------- ### Add Space UI primitives in Bolt.new Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/lovable.mdx Install required Space UI primitives (dialog and button) directly in the Bolt terminal using the shadcn add command. ```bash npx shadcn@latest add https://www.spaceui.one/r/primitives-dialog.json https://www.spaceui.one/r/primitives-button.json -y ``` -------------------------------- ### Next.js page.tsx with Space UI Dialog Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/nextjs.mdx Create a test page to verify smooth animations and styling. Imports Dialog components and Button from local UI components. Renders a Dialog with trigger, popup, title, description, and close button. Works in React 19 Server Components without 'use client' because internal primitives encapsulate client boundaries. ```tsx import { Dialog, DialogTrigger, DialogPopup, DialogTitle, DialogDescription, DialogClose } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' export default function HomePage() { return (

Space UI + Next.js

Sensory interactions, accessible Base UI primitives, and fluid Motion physics.

Open Interactive Dialog } /> Hello from Space UI This dialog uses Base UI portal management and fluid Motion physics.
Cancel} />
) } ``` -------------------------------- ### useMap usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-map.mdx Import the useMap hook and initialize it with an initial entry. The returned actions object provides methods like set to update the map. ```tsx import { useMap } from '@/hooks/use-map' const [map, actions] = useMap([['key', 'val']]) actions.set('key', 'newVal') ``` -------------------------------- ### Add Space UI Components via CLI Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Install any primitive or component directly from the @spaceui registry. Shared dependencies like @base-ui/react, motion, and @spaceui/* primitives are resolved and downloaded automatically by the CLI. ```bash npx shadcn@latest add @spaceui/dialog @spaceui/button ``` -------------------------------- ### Import and use usePrefersTheme Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-prefers-theme.mdx Import the hook from '@/hooks/use-prefers-theme' and call it to get the system color scheme as 'dark' or 'light'. No parameters are required. ```tsx import { usePrefersTheme } from '@/hooks/use-prefers-theme' const theme = usePrefersTheme() // 'dark' | 'light' ``` -------------------------------- ### Import and use useWindowSize hook Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-window-size.mdx Import the hook from '@/hooks/use-window-size' and call it to get the current viewport width and height as numbers. ```tsx import { useWindowSize } from '@/hooks/use-window-size' const { width, height } = useWindowSize() ``` -------------------------------- ### StatusBadge Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/status-badge.mdx Example usage of StatusBadge with status 'available', primary text 'Disponible', and a link as children. ```tsx 1 place restante pour ce mois-ci ``` -------------------------------- ### useClipboard usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-clipboard.mdx Import useClipboard from '@/hooks/use-clipboard', call it with a timeout option (default 2000 ms), and use the returned copy function to copy text. The copied state resets after the timeout. ```tsx import { useClipboard } from '@/hooks/use-clipboard' const { copy, copied } = useClipboard({ timeout: 2000 }) copy('Text to copy') ``` -------------------------------- ### useFullscreen usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-fullscreen.mdx Import the useFullscreen hook and call it with a ref to an element. The hook returns isFullscreen and toggle. The targetRef parameter defaults to document.documentElement if not provided. ```tsx import { useFullscreen } from '@/hooks/use-fullscreen' const ref = React.useRef(null) const { isFullscreen, toggle } = useFullscreen(ref) ``` -------------------------------- ### Import and use useFirstRender Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-first-render.mdx Import the hook from '@/hooks/use-first-render' and call it to get a boolean that is true only on the initial mount. ```tsx import { useFirstRender } from '@/hooks/use-first-render' const isFirst = useFirstRender() ``` -------------------------------- ### Describe job to trigger skill automatically Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/skills.mdx Example user request that automatically triggers the Space Motion skill when skills are discovered in .agents/skills/. ```text Make a 45-second launch video of our landing page, then export it in 4K. ``` -------------------------------- ### usePagination usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-pagination.mdx Import and call usePagination with options for total items, page size, initial page, and sibling count. Returns pagination state and navigation controls. ```tsx import { usePagination } from '@/hooks/use-pagination' const { page, setPage, totalPages, range, startIndex, endIndex, nextPage, prevPage, firstPage, lastPage, hasNext, hasPrev, } = usePagination({ total: 100, pageSize: 10, initialPage: 1, siblings: 1, }) ``` -------------------------------- ### PreviewCard usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/preview-card.mdx Renders a preview card with a trigger and popup. The trigger shows the popup on hover. The popup displays the preview content. ```tsx Open Preview Card Preview Card Content ``` -------------------------------- ### Create Vite React TypeScript project Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/vite.mdx Scaffold a new Vite React application with TypeScript. Choose the command for your package manager. ```bash pnpm create vite my-app --template react-ts ``` ```bash npm create vite@latest my-app -- --template react-ts ``` ```bash yarn create vite my-app --template react-ts ``` ```bash bun create vite my-app --template react-ts ``` -------------------------------- ### MeshGradient usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/mesh-gradient.mdx Import the MeshGradient component and render it inside a relative container with defined height and width. The example sets colors, speed, distortion, swirl, rotation, and grain props. WebGL is required and the component depends on @paper-design/shaders-react. ```tsx import { MeshGradient } from '@/components/shader/mesh-gradient' export default function SpaceUI() { return (
) } ``` -------------------------------- ### Basic Menubar usage Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/menubar.mdx A basic menubar with a File menu containing items, a separator, and a shortcut. Use this as a starting point for building desktop-style menus. ```tsx File New Tab ⌘T New Window Print... ``` -------------------------------- ### slugifyHeadline usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/format-content.mdx Imports the slugifyHeadline utility from '@/utils/format-content' and converts a headline string to a URL-friendly slug. The example shows the output for 'Getting Started with React!' as 'getting-started-with-react'. ```tsx import { slugifyHeadline } from '@/utils/format-content' slugifyHeadline('Getting Started with React!') // => "getting-started-with-react" ``` -------------------------------- ### Add path mappings to tsconfig.app.json Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/vite.mdx Add baseUrl and paths to tsconfig.app.json (or tsconfig.json) so that '@/*' resolves to './src/*'. Required for TypeScript path aliases. ```json { "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"] } } } ``` -------------------------------- ### PreviewLinkCard usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/preview-link-card.mdx Renders a link card with a trigger and a popup containing an image preview. The popup appears when the trigger is hovered. ```tsx Space UI Docs ``` -------------------------------- ### Initialize Space UI Preset with npm Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Run this command to configure components.json, color variables, and squircle utility classes. Requires an existing React project with Tailwind CSS. ```bash npx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` -------------------------------- ### Initialize Space UI Preset with pnpm Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Run this command to configure components.json, color variables, and squircle utility classes. Requires an existing React project with Tailwind CSS. ```bash pnpm dlx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` -------------------------------- ### Initialize Space UI Preset with bun Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Run this command to configure components.json, color variables, and squircle utility classes. Requires an existing React project with Tailwind CSS. ```bash bunx --bun shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` -------------------------------- ### ContextMenuLinkItem with plain anchor href Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/context-menu.mdx Use the `href` prop only for plain anchor links, not for router links. This example shows a `ContextMenuLinkItem` with a simple `href`. ```tsx Docs ``` -------------------------------- ### useSize usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-size.mdx Import useSize from '@/hooks/use-size' and pass a React ref to measure the element's width and height in pixels. The hook returns an object with width and height properties. ```tsx import { useSize } from '@/hooks/use-size' const ref = React.useRef(null) const { width, height } = useSize(ref) ``` -------------------------------- ### AdaptiveDensityGrid Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/adaptive-density-grid.mdx Renders the grid with items, density options (spacious, normal, compact) with responsive column counts, and a custom renderItem function. ```tsx
{item.title}
} /> ``` -------------------------------- ### ContextMenuLinkItem with router Link and render prop Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/context-menu.mdx When using a router `Link`, keep the `render` prop instead of replacing it with `href`. This example shows a `ContextMenuLinkItem` rendering a `Link` component. ```tsx }>Docs ``` -------------------------------- ### Initialize Space UI Preset with yarn Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/index.mdx Run this command to configure components.json, color variables, and squircle utility classes. Requires an existing React project with Tailwind CSS. ```bash yarn dlx shadcn@latest init https://www.spaceui.one/r/lib-style.json ``` -------------------------------- ### useClickOutside Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-click-outside.mdx Import the hook and attach it to a ref to trigger a callback when clicking outside the target element. The ref must be attached to the target element and the handler is called on outside clicks. ```tsx import { useClickOutside } from '@/hooks/use-click-outside' const ref = React.useRef(null) useClickOutside(ref, () => setOpen(false)) ``` -------------------------------- ### useIsMounted Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-is-mounted.mdx Import the useIsMounted hook and call it to get a function that returns a boolean indicating whether the component is mounted. Use this to safely update state only when the component is mounted. ```tsx import { useIsMounted } from '@/hooks/use-is-mounted' const isMounted = useIsMounted() if (isMounted()) updateState() ``` -------------------------------- ### Prompt v0.dev to use Base UI and Space UI tokens Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/lovable.mdx Pass Space UI documentation context to v0 to generate a multi-step checkout dialog using Base UI and Motion with semantic tokens. ```text Generate a multi-step checkout dialog using Base UI (@base-ui/react) and Motion. Use Space UI semantic tokens (--background, --foreground, --card, --primary). Ensure dialogs use Base UI Portal and Backdrop with smooth scale-in animations. ``` -------------------------------- ### Test Space UI Dialog in src/App.tsx Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/vite.mdx Replace the default Vite App component with this example to verify Space UI integration. It imports Dialog components and a Button, then renders a dialog with trigger, popup, title, description, and close actions. Requires React 19, Tailwind v4, and Motion primitives. ```tsx import { Dialog, DialogTrigger, DialogPopup, DialogTitle, DialogDescription, DialogClose } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' export default function App() { return (

Space UI + Vite

Ultra-fast development with React 19, Tailwind v4, and Motion primitives.

Open Dialog} /> Vite Integration Active Space UI components are rendered with native physics and Base UI accessibility.
Close} />
) } ``` -------------------------------- ### LoadingOrb and BuildingLoader Usage Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/loading.mdx Shows how to import and use LoadingOrb and BuildingLoader components. LoadingOrb cycles through states by default, or you can lock a specific pattern with the pattern prop. BuildingLoader displays an assistant status card with a state and detail message. Both accept Tailwind color classes and size props. ```tsx import { LoadingOrb, BuildingLoader } from '@/components/orb/loading' export default function App() { return (
{/* Standard loader cycling states with Tailwind color */} {/* Specific pattern locked */} {/* Companion assistant status card */}
) } ``` -------------------------------- ### useInterval Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-interval.mdx Declarative timer hook with start, pause, and dynamic delay controls. Accepts a callback and delay, returns start and stop functions. ```APIDOC ## useInterval ### Description Declarative timer with start, pause, and dynamic delay controls. ### Parameters / Props | Parameter | Type | Default | Description | | :--------- | :--------------- | :--------- | :------------- | | `callback` | `() => void` | _required_ | Tick function. | | `delay` | `number \| null` | `null` | Delay in ms. | ### Return Value | Property | Type | Description | | :------- | :------------------------- | :--------------- | | `start` | `(delay?: number) => void` | Starts interval. | | `stop` | `() => void` | Pauses interval. | ### Usage Example ```tsx import { useInterval } from '@/hooks/use-interval' const { start, stop } = useInterval(() => tick(), 1000) ``` ``` -------------------------------- ### Select Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/select.mdx Root component for the select. Alias for Select.Root from Base UI. ```APIDOC ## Select ### Description Root component for the select. Alias for `Select.Root` from Base UI. ``` -------------------------------- ### SmoothSlider usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/smooth-slider.mdx Import SmoothSlider from '@/components/spaceui/smooth-slider' and use it as a controlled component with React state. The example sets an initial value of 50, a range from 0 to 100, a step of 5, and an accessible label 'Volume'. ```tsx import { SmoothSlider } from '@/components/spaceui/smooth-slider' export default function Example() { const [value, setValue] = React.useState(50) return } ``` -------------------------------- ### Import and use useFirstVisit Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-first-visit.mdx Import the hook from '@/hooks/use-first-visit' and call it with a visit key. Returns true on the first visit for that key. ```tsx import { useFirstVisit } from '@/hooks/use-first-visit' const isFirst = useFirstVisit('welcome_popup') ``` -------------------------------- ### defaultEventOrder Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/event-calendar.mdx Default sort: earlier start, then longer duration, then key. ```APIDOC ## defaultEventOrder ### Description Default sort: earlier start, then longer duration, then key. ### Signature `(a, b: EventCalendarOccurrence) => number` ### Parameters - **a** (EventCalendarOccurrence) - Required - First occurrence. - **b** (EventCalendarOccurrence) - Required - Second occurrence. ### Returns Number indicating sort order. ``` -------------------------------- ### Initialize Space UI in Bolt.new WebContainer terminal Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/installation/lovable.mdx Run the standard shadcn initialization command in the Bolt terminal to set up Space UI with the lib-style registry. ```bash npx shadcn@latest init https://www.spaceui.one/r/lib-style.json -y ``` -------------------------------- ### Import Menubar components Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/menubar.mdx Import the Menubar components from the UI library. This is the first step before using the Menubar in your application. ```tsx import { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarShortcut, } from '@/components/ui/menubar' ``` -------------------------------- ### Nested Groups Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/group.mdx Nest multiple groups to create complex layouts with spacing. ```tsx ``` -------------------------------- ### NumberField usage with scrub area and stepper Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/number-field.mdx Example usage of NumberField with a scrub area and increment/decrement buttons. ```tsx ``` -------------------------------- ### GroupText with render prop Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/group.mdx Use the render prop to render a custom component as the text, for example a label. ```tsx }>https:// ``` -------------------------------- ### MenubarMenu Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/menubar.mdx Individual menu dropdown root. Wrapper for Menu.Root from Base UI. ```APIDOC ## MenubarMenu ### Description Individual menu dropdown root. Wrapper for `Menu.Root` from Base UI. ### Usage ```tsx File New Tab ``` ``` -------------------------------- ### Group API Reference Example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/group.mdx Basic Group with two buttons and a separator, as shown in the API reference. ```tsx ``` -------------------------------- ### Accordion anatomy Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/accordion.mdx Shows the minimal structure of the Accordion components. The AccordionItem does not require a value prop in this example. ```tsx ``` -------------------------------- ### Standalone Command (Without Dialog) Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/command.mdx Example showing how to use the Command component without a dialog wrapper. ```APIDOC ## Standalone Command (Without Dialog) ### Description You can use the Command component without a dialog wrapper. ### Request Example ```tsx No results found. {(item) => ( {item.label} )} ``` ``` -------------------------------- ### ShowcaseGallery usage with rows data Source: https://github.com/usespaceui/ui/blob/main/src/content/library/blocks/showcase-gallery.mdx Import ShowcaseGallery and pass a rows array. Each row contains tiles with title, category, image, optional video, and aspect ratio. Tiles justify to full width and regroup two per row in narrow containers. Focus behavior: mouse follows pointer, touch tap to focus, keyboard tab and Escape to let go. Reduced motion disables animation. Remote images require adding host to images.remotePatterns in next.config. ```tsx import { ShowcaseGallery } from '@/components/blocks/showcase-gallery' const rows = [ [ { title: 'Launch film', category: 'Motion', image: '/work/launch.webp', video: '/work/launch.mp4', aspect: 16 / 9 }, { title: 'Watch face', category: 'Product', image: '/work/watch.webp', video: '/work/watch.mp4', aspect: 0.8 }, ], [ { title: 'Dashboard', category: 'Product', image: '/work/dashboard.webp', aspect: 16 / 9 }, { title: 'Mobile app', category: 'Product', image: '/work/app.webp', aspect: 1 }, ], ] export default function Work() { return } ``` -------------------------------- ### Import Show Component Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/show.mdx Import the Show component from the '@/components/show' module. ```tsx import { Show } from '@/components/show' ``` -------------------------------- ### useEventListener usage example Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-event-listener.mdx Imports the useEventListener hook and binds a keydown event listener that logs the pressed key to the console. ```tsx import { useEventListener } from '@/hooks/use-event-listener' useEventListener('keydown', (e) => console.log(e.key)) ``` -------------------------------- ### MemberSelector usage with state Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/member-selector.mdx Example usage of MemberSelector with selected state, onChange handler, maxVisible, and label props. ```tsx const [selected, setSelected] = useState(['1', '2']) ``` -------------------------------- ### iOS mobile input font size Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/fundamentals/typography.mdx Start mobile inputs at 16px to prevent iOS Safari auto-zoom, then scale down on larger viewports. ```tsx ``` -------------------------------- ### Automatic MCP Configuration for Cursor Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/mcp.mdx Run the initialization command to automatically write the MCP configuration file for Cursor. Use the package manager command matching your environment. ```shell pnpm dlx shadcn@latest mcp init --client cursor ``` ```shell npx shadcn@latest mcp init --client cursor ``` ```shell yarn shadcn@latest mcp init --client cursor ``` ```shell bunx --bun shadcn@latest mcp init --client cursor ``` -------------------------------- ### get(name) Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/cookie.mdx Retrieves the value of a cookie by name. Returns the cookie string or null if not found. ```APIDOC ## get(name) ### Description Retrieves the value of a cookie by name. Returns the cookie string or null if not found. ### Method get ### Parameters - **name** (string) - Required - The name of the cookie to retrieve. ### Response Returns the cookie string or null. ``` -------------------------------- ### Import Input component Source: https://github.com/usespaceui/ui/blob/main/src/content/library/primitives/input.mdx Import the Input component from the UI components directory. ```tsx import { Input } from '@/components/ui/input' ``` -------------------------------- ### Import and render SlideToConfirm component Source: https://github.com/usespaceui/ui/blob/main/src/content/library/components/slide-to-confirm.mdx Basic usage example for the SlideToConfirm component. Import it from '@/components/spaceui/slide-to-confirm' and render it in a React component. ```tsx import { SlideToConfirm } from '@/components/spaceui/slide-to-confirm' export default function Example() { return } ``` -------------------------------- ### Explicitly call space-motion skill Source: https://github.com/usespaceui/ui/blob/main/src/content/docs/skills.mdx Example of naming the skill explicitly to invoke it for a specific task, such as reviewing transitions. ```text Review the transitions of this dialog with space-motion. ``` -------------------------------- ### Import and use usePerformanceMode Source: https://github.com/usespaceui/ui/blob/main/src/content/library/hooks/use-performance-mode.mdx Import the hook and call it to get a boolean indicating whether the device is in eco/low-power mode. No parameters are required. ```tsx import { usePerformanceMode } from '@/hooks/use-performance-mode' const isEco = usePerformanceMode() ``` -------------------------------- ### Render AgentUsageCard with props Source: https://github.com/usespaceui/ui/blob/main/src/content/library/interactions/agent-usage-card.mdx Example usage of the AgentUsageCard component with title, description, usedHours, totalHours, resetLabel, and defaultWorking props. ```tsx ```