Ink Web

MacWindow

A macOS-style window container with traffic light buttons (close, minimize, maximize) and an optional title bar.

Preview

Your content here

Installation

npx shadcn@latest add https://raw.githubusercontent.com/cjroth/ink-web/main/packages/ink-ui/registry/mac-window.json
npx shadcn@latest add https://raw.githubusercontent.com/cjroth/ink-web/main/packages/ink-ui/registry/mac-window.json
pnpm dlx shadcn@latest add https://raw.githubusercontent.com/cjroth/ink-web/main/packages/ink-ui/registry/mac-window.json
bunx shadcn@latest add https://raw.githubusercontent.com/cjroth/ink-web/main/packages/ink-ui/registry/mac-window.json

Usage

app/terminal.tsx
"use client";

import { Box, Text } from "ink";
import { MacWindow } from '@/components/ui/mac-window'
import { InkXterm } from "ink-web";
import "ink-web/css";
import "xterm/css/xterm.css";

export default function Terminal() {
  return (
    <MacWindow title="Terminal">
      <InkXterm focus>
        <Box flexDirection="column">
          <Text color="green">Hello from Ink!</Text>
        </Box>
      </InkXterm>
    </MacWindow>
  )
}

Props

PropTypeDescription
childrenReactNodeContent to render inside the window
classNamestringAdditional CSS classes
titlestringOptional title displayed in the center of the title bar
onClose() => voidCallback when close button is clicked
onMinimize() => voidCallback when minimize button is clicked
onMaximize() => voidCallback when maximize button is clicked

Examples

Basic Window

<MacWindow>
  <div className="p-4">
    <p>Window content</p>
  </div>
</MacWindow>

With Title

<MacWindow title="My App">
  <div className="p-4">
    <p>Window with title</p>
  </div>
</MacWindow>

With Button Handlers

<MacWindow
  title="Terminal"
  onClose={() => console.log('Close clicked')}
  onMinimize={() => console.log('Minimize clicked')}
  onMaximize={() => console.log('Maximize clicked')}
>
  <div className="p-4">
    <p>Interactive window</p>
  </div>
</MacWindow>