Skip to content

How styles are resolved

Hozo does not treat a dynamic className as a single thing to give up on. There are three tiers, and only the last one costs anything at runtime.

Static — compiled away.

tsx
<View className="p-4 bg-blue-500" />

Becomes a scoped class in a real stylesheet. Nothing is left at runtime.

Structurally dynamic — compiled into a conditional.

tsx
import { cx, View } from '@hozo/core'<View className={cx('p-4', active && 'bg-blue-500', size === 'lg' && 'text-xl')} />

The compiler does not need to know what active is. It keeps the shape of the expression and compiles each branch, so all three classes are real CSS and the choice between them is a boolean at runtime.

Here is a filter chip in that shape, rendered by this site’s build. Open the outputs: each cx becomes a conditional over class names that already exist in the stylesheet, on the Web, and over StyleSheet entries on React Native.

All
Open
Closed
Rendered by Hozo when this page was built. No JavaScript reaches the browser for it.
Filter.tsx
import { cx, Text, View } from '@hozo/core'export function Filter({ label, active }: { label: string; active: boolean }) {  return (    <View className={cx('rounded-full px-3 py-1', active ? 'bg-blue-600' : 'bg-gray-200')}>      <Text className={cx('text-sm font-medium', active && 'text-white')}>{label}</Text>    </View>  )}
What the Web build writes
Markup
((__hozoClassPlan157) => (<div className={["hozo-view hozo-0", (__hozoClassPlan157[0]) && 'hozo-cond-186-192'].filter(Boolean).join(' ')}>  {((__hozoClassPlan251) => (<span className={["hozo-1", (__hozoClassPlan251[0]) && 'hozo-cond-277-283'].filter(Boolean).join(' ')}>{label}</span>))([...((active) ? [true] : [false])])}</div>))([...((active) ? [true] : [false])])
CSS
@property --tw-leading {  syntax: "*";  inherits: false;}.hozo-0 {  border-radius: calc(infinity * 1px);}.hozo-0:where(.hozo-cond-186-192) {  background-color: oklch(54.6% 0.245 262.881);}.hozo-0:not(:where(.hozo-cond-186-192)) {  background-color: oklch(92.8% 0.006 264.531);}.hozo-0 {  padding-inline-start: 12px;  padding-inline-end: 12px;  padding-top: 4px;  padding-bottom: 4px;}.hozo-1 {  font-size: 14px;  line-height: var(--tw-leading, 20px);  font-weight: 500;}.hozo-1:where(.hozo-cond-277-283) {  color: #fff;}
What the React Native build writes
Components
((__hozoClassPlan157) => (<View style={[hozoStyles.hozo0, (__hozoClassPlan157[0]) && hozoStyles.hozo0_cond_186_192, (!(__hozoClassPlan157[0])) && hozoStyles.hozo0_cond_not_186_192, hozoStyles.hozo0_cascade2]}>  {((__hozoClassPlan251) => (<Text style={[hozoStyles.hozo1, (__hozoClassPlan251[0]) && hozoStyles.hozo1_cond_277_283]}>{label}</Text>))([...((active) ? [true] : [false])])}</View>))([...((active) ? [true] : [false])])
StyleSheet
{  hozo0: {    borderRadius: 9999,  },  hozo0_cond_186_192: {    backgroundColor: '#155dfc',  },  hozo0_cond_not_186_192: {    backgroundColor: '#e5e7eb',  },  hozo0_cascade2: {    paddingStart: 12,    paddingEnd: 12,    paddingTop: 4,    paddingBottom: 4,  },  hozo1: {    fontSize: 14,    lineHeight: 20,    fontWeight: '500',  },  hozo1_cond_277_283: {    color: '#fff',  },}

The shapes it reads are a string, &&, a ternary, a template literal, and a call to cx from @hozo/core, or to a function imported from clsx or classnames. Inside them, a part it cannot read, such as a caller’s className, falls back alone and the rest still compiles.

A project’s own helper is not one of them, even when it only wraps those libraries, as a cn in @/lib/utils often does. The compiler reads one file at a time, so it cannot see what cn does, and the whole call takes the runtime fallback below.

So Hozo follows the import to the helper’s file and reads it. A function that only hands its arguments to clsx, classnames, cx, or twMerge is then read argument by argument (#964, #1676). Direct twJoin calls compile when all class tokens are known and supported. Its opaque arguments and wrappers stay at runtime to preserve array flattening; twJoin does not share clsx’s object-dictionary semantics.

When the call uses twMerge or a helper such as shadcn/ui’s cn, Hozo can apply the merger’s conflict rules at compile time. Vite resolves the actual dependency and checks its shipped entry against the implementation used to generate Hozo’s conflict table. A different or unverified implementation stays at runtime. This includes externalized imports, generated dependency entries without matching bytes, Metro’s startup scan, and source-only tools without bundler resolution for the merger. Static conflicts (twMerge('p-4', 'px-2')) and conditional overrides (cn('px-3', active && 'px-2')) are resolved into the compiled rules and guards. This requires every possible class token to be known and supported by the compiler. If any argument contains an opaque caller class list (cn('px-3 py-1 hover:bg-blue-500', className)) or an unsupported token, the whole merge stays at runtime. Custom classes and ambiguous arbitrary values cannot be classified by prefix alone, and a token removed by a later token must not suppress an earlier class. The merger decides which tokens survive. Tailwind’s CSS cascade decides the precedence of the utilities that survive. On Native, a Pressable can apply runtime hover: and active: candidates from the project map using its own interaction state. Runtime variant support depends on what the candidate map can represent and what state the component supplies. Custom mergers built with extendTailwindMerge or createTailwindMerge also stay at runtime so their configured conflict groups remain authoritative.

Pure joiners can also be declared:

ts
hozo({ classHelpers: [{ module: '@/lib/utils', name: 'cn' }] })

module is the specifier as callers write it, and recognize: false undoes a function found automatically. merge: true identifies a conflict merger and keeps the original call when the build has no proof of its rules. The same options work for withHozo on Metro. Vite resolves the import as the build does and re-reads the helper when it changes. Metro reads helpers once when it starts, resolving relative imports and tsconfig paths, so a helper edited while it runs needs a restart, and one behind any other alias needs declaring. Or use cx from @hozo/core, which needs neither.

Truly dynamic — a runtime fallback.

tsx
<View className={classNameFromProps} />

Here the compiler genuinely cannot tell. Every class any source file in the project mentions is scanned and emitted into one project-wide stylesheet, so whatever the expression produces is already defined. The scan is cached and incremental.

The theme behind all of this is read from the project’s own Tailwind entry stylesheet by running Tailwind’s resolver, rather than by parsing a config file — the same discipline the conformance suite uses when it asks Tailwind for its own class list instead of keeping a copy. See the Tailwind CSS guide for how @theme tokens, variants and React Native layout helpers work, or the StyleX guide for combining static StyleX sheets with Tailwind in the same compiler pass. On React Native, Text styles reach the text explains how a container’s text classes reach a Text the compiler cannot see.

To see it compiled, the Tailwind page puts one component beside the CSS and the StyleSheet the build makes from it, and the Conformance Matrix shows class by class how close the output is to Tailwind’s own.