— Engines & connectors · @vitus-labs/connector-styler · @vitus-labs/connector-styled-components · @vitus-labs/connector-emotion · @vitus-labs/connector-native
One init(). Any engine.
Every ui-system component styles itself through @vitus-labs/core, never through an engine directly. A connector is the adapter you hand to init(): styler, styled-components, Emotion, or React Native, where CSS strings become style objects. Swap it, and the components stay as they are.
npm i @vitus-labs/core @vitus-labs/connector-styler- connectors, web and native
- 4
- required members: css, styled, provider
- 3
- line names the engine
- 1
— Why connectors
Components that don't pick an engine.
The engine is named once
Elements, rocketstyle, unistyle and coolgrid read css and styled from core's config. Your app's entry point calls init(connector), and that is the only file that knows which engine runs.
Import order doesn't matter
Core's css and styled are stable delegates. Before init() runs, css returns a thunk and styled returns a lazy component that resolves the engine on first render, so module-level const { styled, css } = config is safe.
Types follow the engine
Core exposes an empty CSSEngineResult interface, and the styler, styled-components and native connectors augment it with their own result type. css returns the type of the engine you installed, without core depending on any engine.
The same components on React Native
connector-native parses CSS template strings into React Native style objects and applies them through style. Pass View and Text as the base components, and breakpoints resolve against the window width.
— Before / after
Same card. Engine named once.
A styled card in a component library. The question is where the CSS engine is named.
import styled from 'styled-components'
export const Card = styled.div`
padding: 16px;
border-radius: 12px;
background: ${({ theme }) => theme.surface};
`
// switching to Emotion:
// import styled from '@emotion/styled' ← in every componentEvery component imports the engine. Moving to another one, or to React Native, means touching each file.
// Card.tsx: no engine import
import { config } from '@vitus-labs/core'
const { styled } = config
export const Card = styled.div`
padding: 16px;
border-radius: 12px;
background: ${({ theme }) => theme.surface};
`
// main.tsx: the only place the engine is named
import { init } from '@vitus-labs/core'
import * as connector from '@vitus-labs/connector-emotion'
init(connector)Components read styled from core. The entry point picks the engine; changing it is a one-line diff.
— Features
Four adapters, one shape.
- connector-styler
re-exports
@vitus-labs/styler; the only web connector that also shipsuseCSS - connector-styled-components
re-exports styled-components 6 or newer, with
csstyped from styled-components' own return type - connector-emotion
wraps Emotion's
cssso fragments compose like styled-components: functions, arrays and nestedcssresolve with props - Emotion globals & keyframes
createGlobalStylerenders Emotion's<Global>with the theme injected;keyframesobjects are kept intact, not stringified - connector-native
CSS strings to React Native style objects: kebab-case to camelCase,
pxto numbers,!importantstripped - Shorthand expansion
padding: 8px 16px,margin,inset,border-widthandborder-radiusexpand to React Native longhands - Native breakpoints
createMediaQuerieschecks the window width when styles resolve, and dynamic components re-render on rotation - Static native styles
templates without function interpolations are parsed once and skip the window and theme hooks entirely
- Lazy delegates
cssandstyledfrom core work beforeinit(); they bind to the engine at first use - CSSEngineResult
an empty interface each connector augments, so
cssis typed as the active engine's result - Clean engine swaps
a full
init()dropskeyframes,createGlobalStyleanduseThemethe new connector doesn't provide - Platform config
componentandtextComponentdefault todivandspan; React Native passesViewandText
— API
Three required members. Four adapters.
Every name links to its reference in the docs.
— Honest limits
Where the engines differ.
Where it isn't the right fit, and what to reach for instead.
React Native isn't a browser
Nested blocks such as
&:hoverand@mediaare dropped, there is nokeyframesorcreateGlobalStyle,styled.Viewshorthand doesn't exist (usestyled(View)), andremvalues stay strings. Overlay and Portal aren't exported on native. For web-only features, keep those components on the web.useCSS is styler-only
The styled-components and Emotion connectors don't export
useCSS: neither engine can turn acssfragment into an inserted class without a styled wrapper. Usestyled(), or the styler connector.Emotion's css isn't typed as an object
The Emotion connector's
cssreturns a string or a function, which can't augmentCSSEngineResult, so the interface stays empty there. Pass results as interpolations, as Emotion expects.One engine per app
The configuration is a singleton and components created after
init()bind to that engine directly. Two engines side by side in one tree aren't supported; callinit()once at the entry point.SSR comes from the engine
Collector-free SSR through
<style precedence>is a styler feature. With styled-components or Emotion, set up that engine's server rendering as you normally would.
— Recipes
Copy, paste, ship.
A web app on styler
Import the connector as a namespace and spread it: connectors have named exports only. This site is set up exactly this way.
import { init } from '@vitus-labs/core'
import * as connector from '@vitus-labs/connector-styler'
init({ ...connector, component: 'div', textComponent: 'span' })
// import './setup' once, before anything rendersKeep an existing styled-components app
The connector re-exports styled-components itself, so the ui-system renders through the copy your app already uses.
import { init } from '@vitus-labs/core'
import * as connector from '@vitus-labs/connector-styled-components'
import { createRoot } from 'react-dom/client'
import App from './App'
init(connector)
createRoot(document.getElementById('root')!).render(<App />)React Native with Expo
Hand core the native base components. The native styled takes a component, not a tag name, and filters $-props, as and data-* before they reach it.
import { init } from '@vitus-labs/core'
import * as connector from '@vitus-labs/connector-native'
import { Text, View } from 'react-native'
init({ ...connector, component: View, textComponent: Text })
// Badge.tsx
import { styled } from '@vitus-labs/connector-native'
export const Badge = styled(View)`
padding: 6px 12px;
border-radius: 999px;
background-color: ${({ theme }) => theme.accent};
opacity: ${({ $muted }) => ($muted ? 0.5 : 1)};
`— FAQ
Questions, answered.
Why `import * as connector`?
Connectors have no default export. A namespace import collects their named exports (css, styled, provider and the optional ones) into the object init() expects.
What happens if I forget init()?
Components created before init() are lazy, so nothing breaks at import time. Rendering one with no engine configured throws an error that shows the init() call to add.
Can I switch engines later?
Call init() once, at startup. Components created after it bind to that engine directly, so a later swap only affects components created afterwards. A full swap also clears optional members the new connector doesn't provide.
Do I need component and textComponent?
On the web they default to div and span, so init(connector) is enough. On React Native pass View and Text, because the primitives render them.
Which connector should I choose?
For a new web app, styler: it is the smallest engine and the only one with useCSS and collector-free React 19 SSR. If styled-components or Emotion is already in your app, use its connector and keep one engine in the bundle.
— @vitus-labs/connector-styler · @vitus-labs/connector-styled-components · @vitus-labs/connector-emotion · @vitus-labs/connector-native
Pick an engine. Keep the components.
npm i @vitus-labs/core @vitus-labs/connector-stylerSources · 39 claims, each traced to v2.9.1 code or docs
- CSSEngineConnector: css, styled, provider required; keyframes, createGlobalStyle, useTheme optionalui-system:packages/core/src/config.ts
- Elements read styled/css/component from core's config, not an engineui-system:packages/elements/src/helpers/Wrapper/styled.ts
- Rocketstyle imports from @vitus-labs/coreui-system:packages/rocketstyle/src/rocketstyle.tsx
- css/styled are stable delegates safe to destructure before init(); css returns a thunk, styled a lazy componentui-system:packages/core/src/config.ts
- Components created after init() bind to the engine directly (fast path)ui-system:packages/core/src/config.ts
- Rendering without an engine throws an error showing the init() callui-system:packages/core/src/config.ts
- Configuration is a singletonui-system:packages/core/src/config.ts
- A full init() drops optional members the new connector doesn't provideui-system:packages/core/src/config.ts
- component/textComponent default to 'div'/'span'ui-system:packages/core/src/config.ts
- CSSEngineResult is an empty interface augmented by connectors via declaration mergingui-system:packages/core/src/config.ts
- connector-styler re-exports styler and augments CSSEngineResult with CSSResultnpm:@vitus-labs/connector-styler/lib/index.d.ts
- connector-styler exports useCSS; provider = ThemeProvider; named exports onlynpm:@vitus-labs/connector-styler/lib/index.d.ts
- connector-styled-components re-exports styled-components; css typed from its own return type; no useCSSui-system:packages/connector-styled-components/src/index.ts
- connector-styled-components derives css result type from styled-componentsui-system:packages/connector-styled-components/src/index.ts
- styled-components peer >= 6ui-system:packages/connector-styled-components/package.json
- connector-emotion wraps Emotion's css for styled-components-style composition (functions, arrays, nesting)ui-system:packages/connector-emotion/src/index.ts
- Emotion createGlobalStyle uses <Global> and injects the context themeui-system:packages/connector-emotion/src/index.ts
- Emotion keyframes objects kept as-is, not stringifiedui-system:packages/connector-emotion/src/index.ts
- Emotion connector doesn't export useCSSui-system:packages/connector-emotion/src/index.ts
- Emotion css returns string | function; CSSEngineResult not augmentedui-system:packages/connector-emotion/src/index.ts
- connector-native exports css, styled, provider/ThemeProvider, useTheme, createMediaQueries; augments CSSEngineResultui-system:packages/connector-native/src/index.ts
- Native: kebab-case to camelCase, px to numbersui-system:packages/connector-native/src/parse.ts
- Native: !important strippedui-system:packages/connector-native/src/parse.ts
- Native: multi-value shorthands (margin, padding, inset, borderWidth, border-radius) expand to longhandsui-system:packages/connector-native/src/parse.ts
- Native: nested blocks (&:hover, @media) droppedui-system:packages/connector-native/src/parse.ts
- Native: rem/em values not convertedui-system:packages/connector-native/src/parse.ts
- Native styled: filters as, $-prefixed, data-* by default; shouldForwardPropui-system:packages/connector-native/src/styled.ts
- Native styled takes a component (no styled.View shorthand)ui-system:packages/connector-native/src/styled.ts
- Native static templates skip window/theme hooksui-system:packages/connector-native/src/styled.ts
- Native dynamic components subscribe to useWindowDimensions (re-render on rotation)ui-system:packages/connector-native/src/styled.ts
- Native createMediaQueries checks window width at resolve timeui-system:packages/connector-native/src/createMediaQueries.ts
- Native connector has no keyframes or createGlobalStyle (docs comparison table)site:content/docs/connectors/native.mdx
- Elements native entry excludes Portal and Overlaynpm:@vitus-labs/elements/README.md
- Expo example: init with connector-native, View and Textui-system:examples/expo-native/src/init.ts
- Vite styled-components example: init(connector) via namespace importui-system:examples/vite-styled-components/src/main.tsx
- Next.js Emotion example: init(connector)ui-system:examples/nextjs-emotion/app/setup.ts
- This site initializes styler through connector-styler with a namespace importsite:src/ui/init.ts
- Collector-free SSR via <style precedence> is styler'sui-system:packages/styler/src/styled.ts
- styler is the smallest engine (6.98 KB vs styled-components 17.89 KB, Emotion 16.59 KB)npm:@vitus-labs/styler/README.md