Skip to Content
CodeUI

From 0.1.x

@codeui/solid v0.3.0

Move an existing CodeUI app to Solid 2 and the new component package.

This guide covers the Solid peer update, Kobalte behavior changes, compiled CSS, package imports, and the theme to variant rename. If your app already uses styled parts from a component subpath, move those imports to the new /parts entry points.

Work through the sections in order.

Upgrade Solid and switch packages

pnpm add @codeui/solid solid-js@^2 @solidjs/web@^2

Upgrade the app to Solid 2 by following the Solid 2 migration guide. Replace the previous component package with @codeui/solid, then update the package name in your imports. Keep the component subpath and add /parts where you import styled parts.

For Vite, replace vite-plugin-solid with @solidjs/vite-plugin and set jsxImportSource to @solidjs/web. See the Vite setup.

Load the compiled CSS

Solid components import their compiled CSS and theme automatically. Remove manual kit stylesheet imports from your app entry unless you also use CSS-only markup. @codeui/styles remains available as a separate package for CSS-only consumers.

The library publishes plain CSS with its generated Inkstone theme. Remove a vanilla-extract plugin that was configured only for the kit. Keep it if the app authors its own .css.ts files. See Installation.

Check the Kobalte behavior changes

The kit now uses Kobalte 2.0.0. If your app also imports Kobalte directly, upgrade that dependency to the same release. These behavior changes also apply when upgrading from a kit version built on Kobalte 0.13.

ChangeWhere you see itWhat to do
Escape in a list with disallowEmptySelection is no longer swallowedListbox, Select inside a Dialog or PopoverEscape now reaches the overlay and can close it. Test the Escape key in nested overlays.
Select calls onChange only when the value changesSelectCode that relied on onChange when the user picks the current option no longer runs.
Labels get their for attribute during SSRTextField, TextArea, NumberField, Select, Checkbox, RadioListServer HTML changes. Update SSR snapshots.
aria-hidden outside a modal is applied later, and kept during a modal handoffDialog that opens a DropdownMenu or PopoverRemoves a focus warning. No change needed.
Hidden inputs no longer scroll the page when focusedCheckbox, RadioList, SelectNo change needed.
The tabs indicator does not animate on first renderTabs, SegmentedControlCheck the indicator position on first paint.
Interact outside works across shadow rootsEvery dismissable overlayNo change needed.

Kobalte's changelog lists every entry.

Two kit fixes also change behavior:

  • Tooltip opens when keyboard focus reaches its trigger, and Escape closes it without moving focus.
  • SegmentedControl releases Escape to the layer around it, such as a dialog.

Move CSS resets below the cui layer

Every kit rule now sits in the cui cascade layer. Unlayered app CSS always wins over a layered rule, whatever its specificity. That is useful for overrides. It also means an unlayered reset, such as button { background: none }, now strips kit buttons.

Put the reset in a layer declared before cui:

app.css
@layer reset, cui;

@layer reset {
	button {
		background: none;
		border: 0;
	}
}

Search your app for !important added to beat kit styles in 0.1.x. An unlayered class wins without it now. Cascade layers explains the order.

Move to the token contract

hello-world.tsvar(--cui-surface-panel)
from-0-1/tokens.tsx
import { Stack, Text, tokens } from "@codeui/solid";

// `tokens` holds var(--cui-…) strings. `themeVars` and `themeTokens` still
// work and point at the same variables, but new code reads `tokens`.
export default function Tokens() {
	return (
		<Stack
			gap="1"
			style={{
				background: tokens.surface.panel,
				padding: tokens.space["4"],
				"border-radius": tokens.radius.card,
			}}
		>
			<Text weight="semibold">hello-world.ts</Text>
			<Text tone="muted">{tokens.surface.panel}</Text>
		</Stack>
	);
}

Every color, radius, space, font, shadow, and duration is now a --cui-* custom property. The tokens export holds a var(--cui-…) string for each one.

  • themeVars and themeTokens keep working. Each name points at the closest --cui-* role. Both are deprecated. Read tokens in new code.
  • Font sizes follow the new scale. xs is 12px, lg is 18px, and xl is 20px. Check layouts that used those sizes.
  • Every component changes appearance. Brand, danger, and status colors meet WCAG AA text contrast. The brand color is #0076cf in both themes, for every filled and selected control. Motion is shorter, with one ease-out curve.
  • Override a token with plain CSS on :root, on [data-cui-theme], or on any element. Theming shows each case.
  • Style files evaluated in Node, such as vanilla-extract .css.ts files, import tokens from @codeui/solid/tokens. That entry loads no component. See Token exports.

Set the theme attribute

data-cui-theme="dark" or data-cui-theme="light" picks the mode. In 0.1.x, an element outside both attributes got no color values. Now the kit follows prefers-color-scheme there. Set the attribute on <html> to keep one mode whatever the system setting.

Use the widened signatures

These ready component signatures add options to the 0.1.x signatures.

from-0-1/dialog-title.tsx
import { Badge, Button, Dialog, DialogPanelContent, Stack } from "@codeui/solid";
import { createSignal } from "solid-js";

// In 0.1.x, `title` took a string and there was no `description`.
// Both take JSX now.
export default function DialogTitle() {
	const [open, setOpen] = createSignal(false);
	return (
		<>
			<Button variant="secondary" onClick={() => setOpen(true)}>
				Export settings
			</Button>
			<Dialog
				open={open()}
				onOpenChange={setOpen}
				size="sm"
				closeLabel="Close export settings"
				title={
					<Stack as="span" direction="row" gap="2" align="center">
						Export settings <Badge tone="info">Beta</Badge>
					</Stack>
				}
				description="Applies to every PNG and SVG export of this project."
			>
				<DialogPanelContent>Pick a format and a scale in the export panel.</DialogPanelContent>
			</Dialog>
		</>
	);
}
Component0.1.xNow
Dialogtitle?: stringtitle and description take JSX. New closeLabel, mount, classes, and aria-label. New content focus callbacks, such as onOpenAutoFocus and onCloseAutoFocus.
PopoverContenttitle?: string. Children wrapped in a <p>.title and description take JSX. New mount and classes. Children render without the <p> wrapper.
Popovergutter ignoredgutter is honored. The default stays 6.
SelectslotClassesNew classes, keyed by part name. slotClasses still works and is deprecated.
TextField, TextArea, NumberFieldslotClasses. Some input attributes dropped.Input attributes are forwarded. description takes JSX. New classes. slotClasses still works and is deprecated.
RadioList, RadioListItemItem props droppedItem props are forwarded and classes is kept.
Listbox, VirtualizedListboxNo class hooksNew classes.

Without a trigger, Dialog now returns focus to the element that opened it. If your app moved focus by hand on close, remove that code and test it.

A PopoverContent whose children relied on the <p> wrapper for spacing or text style now renders them as written. Wrap them in a Text or a p yourself.

Move from slotClasses to classes

Font
from-0-1/select-classes.tsx
import { Select } from "@codeui/solid";

// In 0.1.x: slotClasses={{ input: "font-picker-trigger", errorLabel: "font-picker-error" }}
// `slotClasses` still works and is deprecated. Move to `classes`, keyed by part name.
export default function SelectClasses() {
	return (
		<Select
			aria-label="Font"
			label="Font"
			options={["JetBrains Mono", "Fira Code", "Source Code Pro"]}
			defaultValue="JetBrains Mono"
			classes={{
				trigger: "font-picker-trigger",
				errorMessage: "font-picker-error",
				content: "font-picker-list",
			}}
		/>
	);
}
slotClasses keyclasses key
rootroot
inputtrigger
labellabel
errorLabelerrorMessage
itemValuevalue

TextField, TextArea, and NumberField take the same move. Their classes keys are root, input, label, description, and errorMessage. Rename errorLabel to errorMessage and keep the other keys.

SegmentedControl also has classes. Its keys are the slotClasses keys, root, list, and indicator, plus item. Checkbox and Tooltip still take slotClasses only.

classes also reaches parts slotClasses never could, such as content for the portalled list and item for each option. Each component page lists its classes keys under Anatomy.

Update component imports

Ready components can still be imported from @codeui/solid. Each component family also has a direct entry point.

import { Combobox, createComboboxOptions } from "@codeui/solid/combobox";
import { Select, createSelectOptions } from "@codeui/solid/select";

If you used a component subpath for styled parts, append /parts. Move named and type imports from that entry along with namespace imports.

Before
import * as C from "@codeui/solid/combobox";
import type { RootProps } from "@codeui/solid/combobox";
import { Root as DialogRoot } from "@codeui/solid/dialog";
After
import * as C from "@codeui/solid/combobox/parts";
import type { RootProps } from "@codeui/solid/combobox/parts";
import { Root as DialogRoot } from "@codeui/solid/dialog/parts";

Apply the same change to existing parts imports for accordion, alert, badge, command-menu, kbd, option-card, popover, progress, settings, sheet, skeleton, slider, spinner, stack, switch, text, and toast.

New parts entry points include Select, Tabs, DropdownMenu, the field and selection controls, Tooltip, Pagination, and SegmentedControl. Add the /parts import when you build a custom primitive from them. For token values in build-time stylesheets, keep using @codeui/solid/tokens. See Ready or parts for the import conventions.

Rename theme to variant

The word theme now means light or dark only. The appearance prop that picks a color or a field style is variant.

Component0.1.xNow
Button, IconButtontheme="secondary"variant="secondary"
Button, IconButtontheme="secondary" variant="ghost"variant="secondary" ghost
Checkbox, RadioListtheme="filled"variant="filled"
TextField, TextArea, NumberField, Selecttheme="inline"variant="inline"
Listboxtheme="primary"variant="primary"
Tabstheme="inline"variant="inline"
Tooltiptheme="secondary"variant="secondary"
SegmentedControltheme="primary"accent
createBaseFieldProps{ theme: "filled" }{ variant: "filled" }

Attributes follow the props. data-theme becomes data-variant, and Tabs drops data-tabs-theme for data-variant. A ghost button sets data-ghost, and an accent SegmentedControl sets data-accent. SegmentedControl's data-autoWidth becomes data-auto-width.

Toast and Toaster keep their theme option, and data-cui-theme is unchanged. Both pick light or dark.

Update selectors that target kit markup

A compound component name in a data-cui marker is now one lowercase word. If your CSS or tests select these 0.1.x markers, update them.

0.1.xNow
text-fieldtextfield
number-fieldnumberfield
icon-buttoniconbutton
radio-group-fieldradiolist
dropdown-menu-content, dropdown-menu-itemdropdownmenu-content, dropdownmenu-item
segmentedControl, segmentedControlList, segmentedControlItem, segmentedControlIndicatorsegmentedcontrol, segmentedcontrol-list, segmentedcontrol-item, segmentedcontrol-indicator

The other 0.1.x markers keep their names. Class names in 0.1.x were generated, so do not select them. The new classes follow cui-<component>-<part>, as described in CSS markup. Kit /parts subpaths, such as @codeui/solid/text-field/parts, keep their hyphens.

New components

These ready components are new since 0.1.x. Each one replaces code an app had to write before.

Bug fixes you may have worked around

Remove a workaround for one of these:

  • NumberField masked input only when the caller passed a ref. It masks without one now.
  • The createSelectOptions types were too loose, and generated option keys could collide.
  • PaginationProps was not exported. Import it from @codeui/solid.
  • A custom gutter on a dropdown submenu was ignored.

On this page