Skip to Content
CodeUI

API reference for agents

@codeui/solid v0.3.0

Imports, signatures, and limits of @codeui/solid in one page, for coding agents.

This page is for coding agents that generate UI with @codeui/solid. It lists the import paths, the rules generated code must follow, and every component with its main props. Each component name links to its full page.

Read this site as Markdown

URLContent
/llms.txtAn index of every kit page, grouped as in the sidebar, with a one-line description and a link to its Markdown. It starts with the install line and the import rules.
/llms-full.txtEvery kit page in one file. The Inkstone design pages are left out.
/docs/<page>.mdOne page as Markdown, such as /docs/components/select.md. Demos are replaced by their source code, and props tables by Markdown tables.
/docs/<page>.txtThe same text as the .md route, served as plain text.

Start with /llms.txt. Fetch the .md of each component you use before you write code with it.

The kit package also ships its design specification as node_modules/@codeui/solid/DESIGN.md. Read it before you build a new screen.

Import map

Import fromWhat it holdsUse it for
@codeui/solidEvery ready component, the option helpers, field helpers, icons, SvgIcon, mergeClasses, and the token objectsAlmost everything
@codeui/solid/<name>The ready component and its public types and helpersImport a single component
@codeui/solid/<name>/partsThe styled parts of one component, its part name map, and its style functionsA layout the ready component cannot give
@codeui/solid/tokenstokens, themeVars, themeTokens, layoutVars, breakpoints, responsiveStyle. No component.vanilla-extract .css.ts files, which run in Node

See Ready or parts for supported component entry points.

Import parts as a namespace:

import * as D from "@codeui/solid/dialog/parts";

The app needs Solid 2, @solidjs/web, and @solidjs/vite-plugin. See Installation.

Rules for generated code

Export snippet

Format
agents/export-panel.tsx
import { Button, createToaster, Select, Stack, Switch, Text, Toaster } from "@codeui/solid";
import { createSignal } from "solid-js";
import "./export-panel.css";

const formats = ["PNG", "SVG", "JPEG"];

export default function ExportPanel() {
	const notifications = createToaster();
	const [format, setFormat] = createSignal("PNG");
	const [lineNumbers, setLineNumbers] = createSignal(true);

	return (
		<Stack as="section" gap="4" class="export-panel" aria-labelledby="export-title">
			<Text as="h3" id="export-title" size="md" weight="semibold">
				Export snippet
			</Text>
			<Select
				aria-label="Format"
				label="Format"
				options={formats}
				value={format()}
				onChange={value => value && setFormat(value)}
			/>
			<Switch label="Show line numbers" checked={lineNumbers()} onChange={setLineNumbers} />
			<Button
				variant="primary"
				onClick={() =>
					notifications.show({ tone: "success", description: `hello-world.${format().toLowerCase()} exported` })
				}
			>
				Export
			</Button>
			<Toaster toaster={notifications} closeLabel="Dismiss" />
		</Stack>
	);
}
export-panel.css
/* App CSS reads only --cui-* tokens, and stays unlayered so it wins over the kit. */
.export-panel {
	background: var(--cui-surface-panel);
	border-radius: var(--cui-radius-card);
	padding: var(--cui-space-4);
	max-width: 360px;
}

Follow every rule. A reviewer rejects code that breaks one.

  1. Use a ready component first. Compose parts only when the ready component cannot give the layout. Ready or parts explains the choice.
  2. Read values from tokens. Write colors, radii, spacing, font sizes, shadows, and durations as var(--cui-…) in CSS, or as tokens.… in TypeScript. Never write a hex color, a pixel radius, or a pixel gap for UI chrome. Artwork the user creates is the only exception. Tokens lists every name.
  3. Lay out with Stack. Set gap to a spacing key, such as "2" or "4". Do not write margins between siblings.
  4. Set text with Text. Set the element with as and the size with size. A heading level never comes from the size.
  5. Style an inner part with classes or data-cui. Pass classes={{ trigger: "…" }} on the ready component, or select [data-cui="select-trigger"] in app CSS. Copy part names from the Anatomy table of the component page. Never guess them from export names.
  6. Write app CSS without a layer. Kit rules sit in @layer cui, so unlayered app CSS wins without !important. Put a CSS reset in a layer declared before cui. See Cascade layers.
  7. Theme with data-cui-theme. Set "dark" or "light" on <html>. Remove the attribute to follow the system. The kit has no theme provider and no system value.
  8. Name every control. Give each field a label, or an aria-label when no visible label fits. Give each IconButton an aria-label. Give each Spinner a label.
  9. Keep the keyboard working. Do not put a click handler on a div. Use Button, Link, or a radio or checkbox component. Do not stop Escape from reaching an overlay.
  10. Use the controlled pattern. See Controlled state.

Controlled state

Every stateful component follows Kobalte's pattern. Pass the uncontrolled default, or the value and its change handler together.

StateUncontrolledControlled
ValuedefaultValuevalue and onChange
CheckeddefaultCheckedchecked and onChange
OpendefaultOpenopen and onOpenChange
  • Select calls onChange with null when the selection clears. Guard it: onChange={value => value && setFont(value)}.
  • NumberField uses null for an empty field.
  • Slider calls onChange while the thumb moves and onChangeEnd once on release.
  • Pagination takes page and onChange, starting at 1.
  • CommandMenu has no uncontrolled mode. Pass open and onOpenChange.

Fields

TextField, TextArea, NumberField, Select, Combobox, Checkbox, RadioList, Switch, Slider, and OptionCardGroup take label, description, and errorMessage. The kit links the label and the messages to the input.

  • On the text fields and Select, errorMessage shows only while validationState="invalid". The kit runs no validation of its own.
  • Select requires aria-label in its type, even when it has a label.
  • To build a custom field, use the helpers in Field helpers.
  • To build options from objects, use createSelectOptions, createComboboxOptions, createOptionCardItems, or createAccordionItems. See Options and collections.

Toasts and SSR

Create the toast controller inside a component, as ExportPanel does above, or in the app root. A controller in a module is shared by every request on a server. Render one Toaster for each controller, inside the app's providers. Show notifications shows the setup.

On the server, show and promise do nothing. Toasts render only on the client.

Portalled content renders only on the client. That covers the bodies of Dialog, Sheet, Popover, DropdownMenu, Tooltip, Select lists, Combobox lists, and CommandMenu. Do not put content a crawler must read inside one.

Components

Import each component family below from its own entry point or from @codeui/solid. Append /parts to the component path in the parts column to import its styled parts.

ComponentPartsMain props
Accordionaccordionitems, value, defaultValue, onChange, collapsible
Alertalerttone, title, description, icon, fluid
Badgebadgetone, size, variant, icon, textValue
Buttonnonevariant, size, ghost, pill, block, loading, leftIcon
Checkboxcheckboxlabel, checked, defaultChecked, onChange, indeterminate, size
Comboboxcomboboxlabel, options, value, onChange, inputValue, renderOption, emptyContent
CommandMenucommand-menuopen, onOpenChange, items, onSelect, onHighlightChange, placeholder
Dialogdialogopen, onOpenChange, title, description, size, closeLabel. Body in DialogPanelContent, actions in DialogPanelFooter.
DropdownMenudropdown-menuDropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem with onSelect, and DropdownSubMenu
IconButtonnonearia-label, variant, size, ghost, pill
Kbdkbdsize, variant
Linknonehref, variant
Listboxlistboxoptions, value, onChange, size, bordered
NumberFieldnumber-fieldlabel, value, onChange, min, max, step, precision, prefix, postfix
OptionCardoption-cardOptionCardGroup with label, items, value, onChange, variant
Paginationpaginationpage, onChange, size, rounded
PopoverpopoverPopover with open, placement, gutter. PopoverTrigger. PopoverContent with title, description, mount.
Progressprogresslabel, value, indeterminate, showValue, size
RadioListradio-listlabel, value, onChange, and RadioListItem with value, label
SegmentedControlsegmented-controlvalue, onChange, size, and SegmentedControlItem with value
Selectselectaria-label, label, options, value, onChange, placeholder, multiple, classes
Sheetsheetopen, onOpenChange, side, title, footer, draggable
Skeletonskeletonwidth, height, radius
Slidersliderlabel, value, onChange, onChangeEnd, minValue, maxValue, step, showValue
Spinnerspinnerlabel, size
Stackstackdirection, gap, align, justify, wrap, as
Switchswitchlabel, checked, onChange, description, size
TabstabsTabs with value, onChange. TabsList, TabsHeader with value, TabsContent with value.
Texttextas, size, weight, tone
TextAreatext-arealabel, value, onChange, placeholder, errorMessage
TextFieldtext-fieldlabel, value, onChange, placeholder, type, errorMessage
ToasttoastcreateToaster({ duration }), then show({ tone, title, description, action }). Toaster with toaster, position, closeLabel.
Tooltiptooltipcontent, placement. The trigger is the child.
VirtualizedListboxnoneoptions, virtualizerOptions, size

Most ready components take class for the root and classes for inner parts, keyed by part name. Checkbox and Tooltip take slotClasses instead. Button, IconButton, Link, Pagination, Tabs, and the DropdownMenu exports have no classes prop.

What does not exist

Do not generate code that uses these. Each one fails to compile or to resolve.

  • @codeui/solid/theme.css. Solid components import their CSS and theme automatically. CSS-only consumers import @codeui/styles/theme.css and component CSS files, or @codeui/styles/all.css.
  • A theme provider, or data-cui-theme="system".
  • Box, HStack, VStack, or sprinkles props such as padding or marginTop. Use Stack and a class.
  • asChild. Kobalte and the kit use as for polymorphism.
  • A re-export of Kobalte's toaster. Import it from @kobalte/core/toast when you compose toast parts.
  • toast.remove or toast.custom. Use dismiss, or compose the toast parts.
  • A Meter, ContextMenu, HoverCard, DatePicker, or ColorPicker component.
  • Subpaths for components outside the list in Import map.

On this page