Skip to Content
vitus·labs

Getting Started

Install and configure Vitus Labs in your React project.

Installation

Install the core packages:

npm install @vitus-labs/core @vitus-labs/styler @vitus-labs/connector-styler @vitus-labs/unistyle @vitus-labs/elements @vitus-labs/rocketstyle

Configuration

Initialize the CSS-in-JS engine at the root of your application. This connects the styling engine to all Vitus Labs components.

src/init.ts
import { init } from '@vitus-labs/core'
import * as connector from '@vitus-labs/connector-styler'

init({
  ...connector,
  component: 'div',
  textComponent: 'span',
})

@vitus-labs/connector-styler exposes css, styled, provider, useTheme, keyframes, createGlobalStyle, and useCSS as named exports (no default export). The namespace import above spreads them into init() in one go (init() ignores keys it doesn't use).

@vitus-labs/elements lists @vitus-labs/unistyle as a peer dependency, so install it alongside.

Import this file early in your app entry point (e.g., _app.tsx, layout.tsx, or main.tsx).

Framework Integration

Next.js (App Router)

src/app/layout.tsx
import '@/init' // Initialize vitus-labs

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

Vite

src/main.tsx
import './init' // Initialize vitus-labs
import { createRoot } from 'react-dom/client'
import App from './App'

createRoot(document.getElementById('root')!).render(<App />)

React Native (Expo)

npm install @vitus-labs/core @vitus-labs/connector-native @vitus-labs/unistyle @vitus-labs/elements @vitus-labs/rocketstyle
src/init.ts
import { init } from '@vitus-labs/core'
import { View, Text } from 'react-native'
import {
  css,
  styled,
  provider,
  useTheme,
  createMediaQueries,
} from '@vitus-labs/connector-native'

init({
  css,
  styled,
  provider,
  useTheme,
  component: View,
  textComponent: Text,
  createMediaQueries,
})
App.tsx
import './src/init'
import { Element } from '@vitus-labs/elements'

export default function App() {
  return (
    <Element css={(css) => css`padding: 24px;`}>
      Hello from React Native!
    </Element>
  )
}

Key differences from web setup:

  • Use connector-native instead of connector-styler
  • Set component: View and textComponent: Text (RN primitives instead of HTML tags)
  • Pass createMediaQueries for responsive breakpoint support
  • No @vitus-labs/styler needed — the native connector handles CSS parsing internally

See the React Native connector docs for details on how CSS template literals are converted to style objects.

Your First Component

import { Element } from '@vitus-labs/elements'

function Card({ title, children }: { title: string; children: React.ReactNode }) {
  return (
    <Element
      tag="article"
      css={(css) => css`
        padding: 24px;
        border-radius: 8px;
        border: 1px solid #e0e0e0;
      `}
    >
      <Element tag="h2" css={(css) => css`margin-bottom: 12px;`}>
        {title}
      </Element>
      {children}
    </Element>
  )
}

Try It Live

Edit the code below to see changes in real time:

What's Next?

Edit on GitHub

Last updated on

On this page