Windows
Kitten is a Window Manager, has many Operating System’s window-manager-like features like resizing, moving, minimizing, opening/closing windows and other window management fundamentals like dealing with z-index and focusing windows.
Basic Window
BasicWindow
is the most basic window component in Kitten. It provides a title, a close button, and a content area. It can be used to create simple windows.
BasicWindow
takes props like title
, initialPosition
, initialSize
, opened
, and children node, so you don’t need to deal with state management for simple use cases.
Let’s start with a basic window. We’ll create a window with a title, a close button, and a content area.
We’ll work on the Cat.tsx
file for this.
We’ll add a BasicWindow
component to the Cat
component in our Space
component.
Here is the full code:
Every space can have multiple windows. You can add as many windows as you want to a space.
Note
Window
andBasicWindow
components can be placed in anywhere in the component tree. They don’t need to be direct children of theSpace
component. You can also have nestedWindow
components.
API Reference
BasicWindow
has some options that you can use to customize the window.
BasicWindow
Props
Name | Type | Default |
---|---|---|
children? | React.ReactNode | null |
title? | string | '' |
initialSize? | [number, number] | [500, 400] |
initialPosition? | [number, number] | 'random' | 'auto' | 'auto' |
opened? | boolean | true |
onClose? | () => void | undefined | undefined |
Congratulations! 🥳 You’ve learned how to create windows with Kitten’s BasicWindow
component.
- Installing dependencies
- Starting http server