@molecule/app-ui
Core interface · ui · App (browser) · v1.18.0 · Apache-2.0
Styled component library with ClassMap
npm install @molecule/app-uiHow it works
@molecule/app-ui is the ui core interface on the app (browser) side: the API your app calls, with no vendor inside.
Choose the implementation by bonding one of its 9 providers: @molecule/app-ui-angular, @molecule/app-ui-nativewind, @molecule/app-ui-react, @molecule/app-ui-react-native, @molecule/app-ui-solid, @molecule/app-ui-svelte, @molecule/app-ui-tailwind, @molecule/app-ui-tailwind-glass, @molecule/app-ui-vue.
import { getClassMap, molIdProps } from '@molecule/app-ui'
const cm = getClassMap()
<button
className={cm.cn(cm.surface, cm.textSize('sm'))} // resolved classes — never a raw "px-3 text-sm"
{...molIdProps('save-button')} // data-mol-id for agents/tests
>…</button>Providers (9): @molecule/app-ui-angular, @molecule/app-ui-nativewind, @molecule/app-ui-react, @molecule/app-ui-react-native, @molecule/app-ui-solid, @molecule/app-ui-svelte, @molecule/app-ui-tailwind, @molecule/app-ui-tailwind-glass, @molecule/app-ui-vue
Works with: @molecule/app-bond, @molecule/app-filesystem, @molecule/app-i18n
Reference
UI component interfaces for molecule.dev.
Provides standardized prop interfaces for common UI components that can be implemented by different UI libraries (styled-components, Tailwind, Ionic, etc.).
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { getClassMap, molIdProps } from '@molecule/app-ui'
const cm = getClassMap()
<button
className={cm.cn(cm.surface, cm.textSize('sm'))} // resolved classes — never a raw "px-3 text-sm"
{...molIdProps('save-button')} // data-mol-id for agents/tests
>…</button>
Type
core
Installation
npm install @molecule/app-ui @molecule/app-bond @molecule/app-filesystem @molecule/app-i18n
API
Interfaces
ElementHandle
What an element's ref receives on every renderer: a DOM element and a React Native host
instance both satisfy it. Measure an element with the kit's measureElement, never with
getBoundingClientRect.
interface ElementHandle {
/** Moves focus to the element. */
focus(): void
/** Removes focus from the element. */
blur(): void
/** Selects the entire current text field value, via DOM selection or native TextInput selection. */
select?(): void
}
ElementBox
An element's box in the window, in CSS pixels on the web and density-independent pixels on native.
interface ElementBox {
/** Distance from the window's left edge. */
x: number
/** Distance from the window's top edge. */
y: number
/** Width of the box. */
width: number
/** Height of the box. */
height: number
}
ElementViewport
The visible window containing a registered element.
interface ElementViewport {
/** Available width, excluding the browser's scrollbar, or the native window width. */
readonly width: number
/** Full browser viewport or native window height. */
readonly height: number
/** Height excluding the browser's scrollbar. Equal to height on a device. */
readonly contentHeight: number
/** Web content uses the document scroll. Device content scrolls in an element. */
readonly scrollOwner: 'document' | 'element'
}
ElementDragPoint
One sample from the contact that owns a drag, in CSS pixels on web or dp on native.
interface ElementDragPoint extends KitModifierKeys {
/** Unclamped horizontal offset from the current HTML box, SVG viewport, or native frame. */
readonly x: number
/** Unclamped vertical offset from the current HTML box, SVG viewport, or native frame. */
readonly y: number
/** Horizontal displacement from contact-down in viewport axes on either renderer. */
readonly dx: number
/** Vertical displacement from contact-down in viewport axes on either renderer. */
readonly dy: number
/** Current frame in the same window space as the renderer's `measureElement`. */
readonly bounds: Readonly<ElementBox>
}
ElementDrag
One primary contact, owned until release or interruption on web and native.
interface ElementDrag {
/** Axis used to negotiate with an enclosing scroller on either renderer. Defaults to both. */
axis?: 'horizontal' | 'vertical' | 'both'
/** Whether touch acquires on contact or waits for a long press so an ordinary swipe can scroll. */
touchStart?: 'immediate' | 'longPress'
/** Acquires once, including a stationary mouse, pen, or touch on either renderer. */
onStart(point: ElementDragPoint): void
/** Reports motion of the owned pointer or native responder, including outside the surface. */
onMove?(point: ElementDragPoint): void
/** Reports the final position on web pointer-up or native touch release. */
onEnd?(point: ElementDragPoint): void
/** Reports the last reliable sample on web capture loss or native responder interruption. */
onCancel?(point: ElementDragPoint): void
}
ElementZoomPoint
A point in the untransformed outer frame, in CSS pixels or native dp.
interface ElementZoomPoint {
readonly x: number
readonly y: number
}
ElementZoom
Opts a surface into two-contact touch input and optionally focal wheel input.
interface ElementZoom {
/** Which vertical wheel events the web surface handles. Other wheel input can scroll as usual. */
wheel: 'all' | 'ctrl' | 'off'
/** Receives a focal wheel sample or the movement of the currently owned pair. */
onZoom(sample: ElementZoomSample): void
}
ElementDragProps
Continuous manipulation of an element, through pointer capture or the native touch responder.
interface ElementDragProps {
/** Binds one contact on the current box or the enclosing SVG viewport. */
drag?: ElementDrag
/**
* Reserves touch gestures on this surface. A pinch closes an acquired drag through
* `onCancel` (or `onEnd` when no cancel handler is supplied). When one contact remains,
* a new drag starts on its next move, using the surviving position as the origin.
* Apply transforms to the surface's children.
*/
zoom?: ElementZoom
}
ElementContentTransform
Translation after uniform scaling around a child's top-left corner.
interface ElementContentTransform {
readonly translateX: number
readonly translateY: number
readonly scale: number
}
BoxStyle
Inline layout and paint that CSS and React Native apply the same way. Numbers are CSS pixels on
the web and density-independent pixels on native. Shorthand strings (padding: '8px 12px',
border: '1px solid'), CSS grid, calc(), var() and units other than pixels and percent are
not accepted: write longhands, or use a ClassMap class (the nativewind ClassMap translates
classes for native).
interface BoxStyle {
/** `'flex'` or `'none'`; every native view is a flex container. */
display?: 'flex' | 'none'
/** Positioning scheme. */
position?: 'relative' | 'absolute'
/** Offset from the containing block's top. */
top?: ElementLength
/** Offset from the containing block's right. */
right?: ElementLength
/** Offset from the containing block's bottom. */
bottom?: ElementLength
/** Offset from the containing block's left. */
left?: ElementLength
/** Width. */
width?: ElementLength
/** Height. */
height?: ElementLength
/** Minimum width. */
minWidth?: ElementLength
/** Minimum height. */
minHeight?: ElementLength
/** Maximum width. */
maxWidth?: ElementLength
/** Maximum height. */
maxHeight?: ElementLength
/** Margin on all sides. */
margin?: ElementLength | 'auto'
/** Top margin. */
marginTop?: ElementLength | 'auto'
/** Right margin. */
marginRight?: ElementLength | 'auto'
/** Bottom margin. */
marginBottom?: ElementLength | 'auto'
/** Left margin. */
marginLeft?: ElementLength | 'auto'
/** Padding on all sides. */
padding?: ElementLength
/** Top padding. */
paddingTop?: ElementLength
/** Right padding. */
paddingRight?: ElementLength
/** Bottom padding. */
paddingBottom?: ElementLength
/** Left padding. */
paddingLeft?: ElementLength
/** Grow and shrink factor with a zero basis (`flex: 1`). */
flex?: number
/** Grow factor. */
flexGrow?: number
/** Shrink factor. */
flexShrink?: number
/** Initial main size. */
flexBasis?: ElementLength | 'auto'
/** Main axis direction. */
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
/** Whether lines wrap. */
flexWrap?: 'wrap' | 'nowrap' | 'wrap-reverse'
/** Cross-axis alignment of children. */
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'
/** Cross-axis alignment of this element. */
alignSelf?: 'auto' | 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'
/** Cross-axis alignment of wrapped lines. */
alignContent?:
| 'flex-start'
| 'flex-end'
| 'center'
| 'stretch'
| 'space-between'
| 'space-around'
| 'space-evenly'
/** Main-axis alignment of children. */
justifyContent?:
'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'
/** Gap between children. */
gap?: number
/** Gap between rows. */
rowGap?: number
/** Gap between columns. */
columnGap?: number
/** Clipping of overflowing children (scrolling content belongs in a `ScrollArea`). */
overflow?: 'visible' | 'hidden'
/** Transform for the content inside an untransformed gesture surface. */
contentTransform?: ElementContentTransform
/** Stacking order. */
zIndex?: number
/** Width-to-height ratio. */
aspectRatio?: number
/** Whether the element receives pointer and touch events. */
pointerEvents?: 'auto' | 'none'
/** Opacity, 0 to 1. */
opacity?: number
/** Background colour (a theme colour belongs in a ClassMap class). */
backgroundColor?: string
/** Border width on all sides. */
borderWidth?: number
/** Top border width. */
borderTopWidth?: number
/** Right border width. */
borderRightWidth?: number
/** Bottom border width. */
borderBottomWidth?: number
/** Left border width. */
borderLeftWidth?: number
/** Border colour on all sides. */
borderColor?: string
/** Top border colour. */
borderTopColor?: string
/** Right border colour. */
borderRightColor?: string
/** Bottom border colour. */
borderBottomColor?: string
/** Left border colour. */
borderLeftColor?: string
/** Border line style. */
borderStyle?: 'solid' | 'dotted' | 'dashed'
/** Corner radius on all corners. */
borderRadius?: number
/** Top-left corner radius. */
borderTopLeftRadius?: number
/** Top-right corner radius. */
borderTopRightRadius?: number
/** Bottom-left corner radius. */
borderBottomLeftRadius?: number
/** Bottom-right corner radius. */
borderBottomRightRadius?: number
}
TextStyle
BoxStyle plus the text properties, for a TextProps element only: on native,
text styles apply to a Text and are not inherited from a view.
interface TextStyle extends BoxStyle {
/** Text colour (a theme colour belongs in a ClassMap class). */
color?: string
/** Font size. */
fontSize?: number
/** Font weight. */
fontWeight?:
'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
/** Font style. */
fontStyle?: 'normal' | 'italic'
/** Line height in pixels (a multiplier such as `1.5` belongs in a ClassMap class). */
lineHeight?: `${number}px`
/** Spacing between letters. */
letterSpacing?: number
/** Horizontal alignment. */
textAlign?: 'left' | 'right' | 'center' | 'justify'
/** Letter case. */
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize'
/** Underline and strike-through. */
textDecorationLine?: 'none' | 'underline' | 'line-through' | 'underline line-through'
}
AriaAttributes
The accessibility attributes both renderers apply.
interface AriaAttributes {
'aria-label'?: string
'aria-labelledby'?: string
'aria-describedby'?: string
'aria-hidden'?: AriaBoolean
'aria-disabled'?: AriaBoolean
'aria-expanded'?: AriaBoolean
'aria-selected'?: AriaBoolean
'aria-checked'?: AriaBoolean | 'mixed'
'aria-pressed'?: AriaBoolean | 'mixed'
'aria-busy'?: AriaBoolean
'aria-live'?: 'off' | 'polite' | 'assertive'
'aria-valuenow'?: number
'aria-valuemin'?: number
'aria-valuemax'?: number
'aria-valuetext'?: string
'aria-current'?: AriaBoolean | 'page' | 'step' | 'location' | 'date' | 'time'
'aria-controls'?: string
'aria-haspopup'?: AriaBoolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'
'aria-modal'?: AriaBoolean
'aria-invalid'?: AriaBoolean
'aria-required'?: AriaBoolean
'aria-readonly'?: AriaBoolean
'aria-orientation'?: 'horizontal' | 'vertical'
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'
/** Web heading or tree depth. Native announces the depth and keeps the element's role. */
'aria-level'?: number
/** Web row total. Native exposes collection metadata or announces the localized total. */
'aria-rowcount'?: number
/** Web column total. Native exposes collection metadata or announces the localized total. */
'aria-colcount'?: number
/** One-based web row position. Native converts to collection metadata or announces the position. */
'aria-rowindex'?: number
/** One-based web column position. Native converts to collection metadata or announces the position. */
'aria-colindex'?: number
}
ElementProps
Props every element takes.
interface ElementProps extends AriaAttributes, DataAttributes {
/** Element id (native `nativeID`). */
id?: string
/** BCP 47 language tag for content or accessible labels, which any element can carry. */
lang?: string
/** ClassMap classes (`cm.*`). */
className?: string
/** Accessibility role, when it differs from the one `as` implies. */
role?: ElementRole
}
InteractionProps
The interaction handlers a focusable element takes on both renderers.
interface InteractionProps {
/** Activation: a click on the web, a press on native. */
onClick?: MouseEventHandler
/** Pointer enters (native: hover in, where the device has a pointer). */
onMouseEnter?: MouseEventHandler
/** Pointer leaves (native: hover out). */
onMouseLeave?: MouseEventHandler
/** The element gains focus. */
onFocus?: FocusEventHandler
/** The element loses focus. */
onBlur?: FocusEventHandler
/** A hardware key goes down; every key action also needs a touch route. */
onKeyDown?: KeyboardEventHandler
/** A hardware key goes up. */
onKeyUp?: KeyboardEventHandler
/** Web-only: a device has no double click. */
onDoubleClick?: MouseEventHandler
/** Web-only (deprecated on the web too); a hardware key press. */
onKeyPress?: KeyboardEventHandler
/** Tab order: in it (`0`) or only programmatically focusable (`-1`). */
tabIndex?: number
}
MousePressProps
Mouse handlers for containers and controls with corresponding device gestures.
interface MousePressProps {
/** DOM context menu. Native calls this for a stationary long press or secondary activation. */
onContextMenu?: MouseEventHandler
/** DOM mouse down. Native calls this on press-in and observes canceled activation. */
onMouseDown?: MouseEventHandler
}
BoxProps
A container (native View; a native Pressable when it has a press, hover or focus handler or a
tab stop, as a div with onClick is). Bare text inside it is laid out as the web lays it out
(in a flex container, its own flex item; in any other, a line with its inline siblings). Use
PressableProps for a control: a button, or anything announced as one.
interface BoxProps<Node = unknown>
extends ElementProps, InteractionProps, MousePressProps, ElementDragProps {
/** The web tag. A label activates the first labelable control it wraps. */
as: BoxTag | 'label'
/** Lets a surrounding drag surface handle direct contact on this view. */
passDragToParent?: boolean
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
title?: string
/** HTML hidden state. Native excludes the box from layout, hits and accessibility while mounted. */
hidden?: boolean
/** Native groups the box and its contents as one screen-reader element when true. Web ignores this. */
accessibilityGroup?: boolean
/** Web outside mouse down. Native observes outside touches in the enclosing box tree. */
onPressOutside?: () => void
/** Observes touch-down, including on a child, without claiming it on web or native. */
onTouchStart?: () => void
/** A browser double-click, native double tap, or native assistive action. */
secondaryAction?: {
/** Localized name for the native accessibility action. The browser adds no attribute. */
label: string
/** Runs the secondary action from the browser event or native gesture or assistive action. */
run: () => void
}
/** Consumes plain-text paste on the web or through a native field or focused Paste command. */
onPasteText?: (text: string) => void
/** Layout and paint both renderers apply. */
style?: BoxStyle & {
/**
* URI painted behind the contents, centered and sized to cover the box. Web emits
* CSS background declarations here. Native draws a decorative image within the box.
* An empty URI leaves the box's background color visible.
*/
coverImage?: string
}
/** Web-only paint. */
webStyle?: WebStyle
/** Child elements. */
children?: Node
}
DisclosureSummaryProps
Attributes of the browser summary or its native pressable control.
interface DisclosureSummaryProps extends ElementProps {
/** Layout and paint for the summary on web and device. */
style?: BoxStyle
/** CSS for the summary. Devices apply the subset they can draw. */
webStyle?: WebStyle
}
DisclosureProps
A disclosure with a first-child summary and a body that stays mounted while closed.
interface DisclosureProps<Node = unknown> extends ElementProps {
/** A literal details element on web and a view on device. */
as: 'details'
/** Initial open state and subsequent parent changes. Both renderers default to closed. */
open?: boolean
/** Content of the browser summary or native pressable summary. */
summary: Node
/** Attributes on the summary element or native pressable itself. */
summaryProps?: DisclosureSummaryProps
/** Reports the resulting state after the browser toggle event or a queued native transition. */
onToggle?: (open: boolean) => void
/** Layout and paint for the whole disclosure on web and device. */
style?: BoxStyle
/** CSS for the details element. Devices apply the subset they can draw. */
webStyle?: WebStyle
/** Body content. Both renderers hide it while closed and preserve its state. */
children?: Node
}
RuleProps
A horizontal thematic break. Web renders a void element and native draws a themed line.
interface RuleProps extends ElementProps, Pick<BoxProps, 'style' | 'webStyle'> {
/** A literal hr on web and a separator view on device. */
as: 'hr'
/** A thematic break has no children on either renderer. */
children?: never
}
GlyphIconProps
A glyph of the icon font (Material Symbols): text on the web, which the font draws by ligature
(<span class="…">check_circle</span>); its codepoint on native, which draws neither ligatures
nor variable axes. It flows inline, as text.
interface GlyphIconProps extends ElementProps {
/** The glyph's name (`check_circle`). On native, a name the font does not draw renders nothing. */
name: string
/** Draws the filled form (the font's `FILL` axis at 1). */
filled?: boolean
/** Layout and text paint both renderers apply (`fontSize`). */
style?: TextStyle
/** CSS for the web. */
webStyle?: WebStyle
}
DotPulseMotion
Fractions of one cycle and the paint at its dimmest point.
interface DotPulseMotion {
/** Full brightness as a fraction of the CSS keyframes and the native cycle, after zero. */
readonly peakAt: number
/** Return to dim paint in the CSS keyframes and native cycle, after the peak and at or before one. */
readonly restAt: number
/** Delay between dots as a fraction of a cycle, in the CSS animation and native driver. */
readonly stagger: number
/** Opacity from zero to one at rest, set by the stylesheet and the native view animation. */
readonly dimOpacity: number
/** Scale from zero to one at rest, set by the stylesheet and the native view animation. */
readonly dimScale: number
}
PulseDotsProps
Three decorative dots drawn in the inherited text colour.
interface PulseDotsProps {
/** Dot diameter, applied to the span in CSS px and the native view in dp. */
size: number
/** Duration of one CSS animation cycle on web or one native loop iteration on device, in ms. */
durationMs: number
}
PressableProps
Something the user activates (native Pressable). A string child renders as the web tag's own
text and inside a native Text.
interface PressableProps<Node = unknown>
extends ElementProps, InteractionProps, MousePressProps, ElementDragProps {
/** The web tag. */
as: PressableTag
/** Lets a surrounding drag surface handle direct contact while focus and assistive activation stay on this control. */
passDragToParent?: boolean
/** A button's type: always set it, a button inside a form submits it by default. */
type?: 'button' | 'submit' | 'reset'
/** Web-only: the form field name a submit button sends. */
name?: string
/** Web-only: the value a submit button sends. */
value?: string
/** Web-only: the id of the form the button belongs to. */
form?: string
/** Whether it is disabled. */
disabled?: boolean
/** A browser double-click, device double tap, or device assistive action. */
secondaryAction?: BoxProps['secondaryAction']
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
title?: string
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** Content: elements, or a string or number. */
children?: Node
}
ElementLinkProps
A link (native Pressable with the link role): an app path navigates through the router, a
URL on another origin opens outside the app. A string child renders as the link's text.
interface ElementLinkProps<Node = unknown> extends ElementProps, InteractionProps {
/** Destination: an app path (`/settings?tab=billing`) or a URL. */
to: string
/** Replace the current history entry instead of pushing one. */
replace?: boolean
/** State stored with the new history entry. */
state?: unknown
/**
* Where a URL opens on the web: a browsing-context keyword or name (`_self`, `_blank`, `_parent`,
* `_top`, or a frame's name). On a device a URL opens outside the app whatever its target.
*/
target?: string
/** Relationship of a URL to the page (`'noopener noreferrer'`). */
rel?: string
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
title?: string
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** Content: elements, or a string or number. */
children?: Node
}
TextFieldKeyEvent
Keyboard input received by a browser text field or native TextInput.
interface TextFieldKeyEvent extends KitKeyboardEvent {
/** The browser reports IME-owned keystrokes, including legacy key code 229. Device key events omit it. */
readonly isComposing?: boolean
}
TextFieldBaseProps
Props common to a browser text field or text area and the native TextInput.
interface TextFieldBaseProps extends ElementProps, Omit<InteractionProps, 'onKeyDown'> {
/** `input` for one line, `textarea` for several. */
as: 'input' | 'textarea'
/**
* The kind of text (`input` only). A device takes a date or time as text in the web's value
* format (`YYYY-MM-DD`, `HH:MM`, `YYYY-MM-DDTHH:MM`), so a form receives the same value.
*/
type?:
| 'text'
| 'email'
| 'password'
| 'search'
| 'number'
| 'tel'
| 'url'
| 'date'
| 'time'
| 'datetime-local'
/** The on-screen keyboard to show. */
inputMode?: 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'
/** The field's text. */
value?: string
/** The text of a field whose text the caller does not hold, when it mounts. */
defaultValue?: string
/** Text shown while the field is empty. */
placeholder?: string
/** Whether the user can edit the text. */
readOnly?: boolean
/** Whether it is disabled. */
disabled?: boolean
/** Whether a form refuses to submit while the field is empty. */
required?: boolean
/** Longest text the field accepts. */
maxLength?: number
/** Shortest text a form accepts in the field. */
minLength?: number
/** Web-only: a pattern a form checks the text against. */
pattern?: string
/** Visible lines (`textarea` only). */
rows?: number
/** Web-only: visible columns (`textarea` only). */
cols?: number
/** Web-only: how a form sends the text's line breaks (`textarea` only). */
wrap?: 'hard' | 'soft' | 'off'
/**
* Grows the field with its text, between these line counts (`textarea` only): the field is
* `minRows` lines tall when nearly empty and scrolls past `maxRows`.
*/
autoGrow?: { minRows: number; maxRows?: number }
/** Tooltip text (native: the accessibility label when there is no `aria-label`). */
title?: string
/** The autofill hint. */
autoComplete?: string
/** Web spell checking. Native passes the boolean on devices with a spell-check control. */
spellCheck?: boolean
/** Web autocorrection hint. Native maps `'on'` and `'off'` to a boolean. */
autoCorrect?: 'on' | 'off'
/** Web return-key label. Native uses the hint when the platform supports it. */
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'
/** Moves focus to the field when it mounts. */
autoFocus?: boolean
/** Selects the field's text on focus in the browser and on a device. */
selectTextOnFocus?: boolean
/** Consumes nonempty plain-text paste before insertion and length limits on web and native. */
onPasteText?: (text: string) => void
/** Field name. */
name?: string
/**
* The text changed. Read `event.target.value` or use `TextFieldProps.onValueChange`.
*/
onChange?: EventHandler<KitFieldChangeEvent>
/** The text changed, with the new text. */
onValueChange?: (value: string) => void
/** Browser key-down with composition state, or a key delivered by the device's TextInput. */
onKeyDown?: EventHandler<TextFieldKeyEvent>
/** The text changed: fires with `TextFieldProps.onChange` on each edit, on both renderers. */
onInput?: FormEventHandler
/** Layout, paint and text styles both renderers apply. */
style?: TextStyle
/** Web-only paint (a field's border and outline resets). */
webStyle?: WebStyle
}
FieldBounds
Inclusive bounds and step for a number or calendar-date field.
interface FieldBounds<T> {
/** HTML minimum attribute. Native uses it as an inclusive lower bound and step base. */
min?: T
/** HTML maximum attribute. Native uses it as an inclusive upper bound. */
max?: T
/** Increment on both renderers, in days for dates. 'any' disables step validation. */
step?: number | 'any'
}
RangeFieldProps
A numeric range rendered by the browser's range input or the device's adjustable slider.
interface RangeFieldProps extends ElementProps, InteractionProps {
/** Optional position of the fixed web type attribute. Native always uses a slider. */
type?: 'range'
/** Lower bound. The browser and device use 0 when it is omitted. */
min?: number
/** Upper bound. The browser and device use 100 when it is omitted. */
max?: number
/** Controlled value. The browser and device clamp and align it to their range. */
value?: number
/** Initial and reset value when uncontrolled. The browser and device otherwise use the midpoint. */
defaultValue?: number
/** Allowed value spacing. Both renderers default to 1. Use `'any'` for continuous values. */
step?: number | 'any'
/** Disables pointer and keyboard edits and excludes the field from forms on both renderers. */
disabled?: boolean
/** Field name used for form submission on the browser and device. */
name?: string
/** Called with the numeric value of each user edit on the browser and device. */
onValueChange?: (value: number) => void
/** Layout and paint applied by both the browser and device. */
style?: BoxStyle
/** CSS layered over `style` in the browser. The device applies the subset it can draw. */
webStyle?: WebStyle
}
FileFieldHandle
Opens the chooser from an external button on either renderer.
interface FileFieldHandle {
/** Starts a file pick. Call from the activation handler of a button. */
pick(): void
}
FileFieldProps
A browse target that delivers an ordered batch of selected files.
interface FileFieldProps<Node = unknown> extends ElementProps {
/** Content of the browse target. */
children?: Node
/** Comma-separated extensions, MIME types, MIME wildcards or `*`. */
accept?: string
/** Deliver all accepted files. Defaults to delivering the first accepted file. */
multiple?: boolean
/** Inclusive per-file limit in bytes. */
maxSize?: number
/** Prevents opening the chooser or delivering files. */
disabled?: boolean
/** Receives a nonempty batch of accepted files in selection order. */
onValueChange(files: readonly PickedFile[]): void
/** Receives a nonempty batch of files rejected by the type or size filter. */
onRejected?(files: readonly PickedFile[]): void
/** Receives a failure to open the chooser or read its selection. */
onPickError?(error: Error): void
/** Tab order of the browse target. Defaults to 0 when enabled and -1 when disabled. */
tabIndex?: number
/** Layout and paint applied by both the browser and device. */
style?: BoxStyle
/** CSS layered over `style` in the browser. */
webStyle?: WebStyle
/** Use separately rendered buttons and open the chooser through its handle. */
externalTrigger?: boolean
/** Web-only: hide the chooser with inline display:none instead of the hidden attribute. */
webInputDisplayNone?: boolean
/** Web-only enhancement of the browse target. */
webDrop?: {
/** Use another element as the drop target. Null waits for its ref to mount. */
target?: ElementHandle | null
/** Reports when an enabled drag enters or the drag leaves or drops. */
onActiveChange?: (active: boolean) => void
/** Overrides the chooser's multiple setting for drops alone. */
multiple?: boolean
/** Reject the entire drop if any file fails the type or size filter. */
rejectBatch?: boolean
/** Receives drops separately from chooser selections when provided. */
onValueChange?: (files: readonly PickedFile[]) => void
}
}
SelectFieldOption
One selectable row in the browser's select and the device's option list.
interface SelectFieldOption {
/** Value reported on selection and submitted by either renderer. */
value: string
/** Plain text shown by the browser and by the device. */
label: string
/** Both renderers keep the row visible but exclude it from edits and form entries. */
disabled?: boolean
/** Reflects this option's initial selection as a web reset attribute. Device uses the field value. */
webDefaultSelected?: true
}
SelectFieldGroup
A browser optgroup and the corresponding device list section.
interface SelectFieldGroup {
/** The browser's optgroup label and the device's noninteractive heading. */
label: string
/** Options in display and submission order on both renderers. */
options: readonly SelectFieldOption[]
}
FormAreaHandle
The form element's focus and submission methods.
interface FormAreaHandle extends ElementHandle {
/** Attempts submission through normal form validation. */
requestSubmit(): void
}
FormAreaProps
A form and its submission, validation and reset handlers.
interface FormAreaProps<Node = unknown> extends ElementProps {
/** The web tag. */
as: 'form'
/** Web-only: browser submission destination. */
action?: string
/** Web-only: browser submission method. */
method?: 'get' | 'post' | 'dialog'
/** Submits even if a field fails validation. */
noValidate?: boolean
/** Whether browser autofill is enabled for the form. */
autoComplete?: 'on' | 'off'
/** Receives the event and the same entries as `new FormData(form)` on the web. */
onSubmit?: (event: KitEvent, entries: FormEntries) => void
/** Fires before uncontrolled fields return to their defaults. Calling preventDefault cancels reset. */
onReset?: FormEventHandler
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** The form's content. */
children?: Node
}
FieldsetProps
Groups controls and disables them together when necessary.
interface FieldsetProps<Node = unknown> extends ElementProps {
/** The web tag. */
as: 'fieldset'
/** Disables the form controls inside it. */
disabled?: boolean
/** The group name. */
name?: string
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** The group's content. */
children?: Node
}
CheckFieldHandle
A checkbox or radio's state and activation methods.
interface CheckFieldHandle extends ElementHandle {
/** Activates the control as a user click or press would. */
click(): void
/** The checked state at the time the handle is read. */
readonly checked: boolean
}
TableBoxProps
A table, a group of rows, or a row.
interface TableBoxProps<Node = unknown> extends ElementProps, InteractionProps {
as: TableBoxTag
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** The table parts this element contains. */
children?: Node
}
ImageProps
An image (native Image).
interface ImageProps extends ElementProps {
/** Image URL. */
src: string
/** Text alternative; an empty string marks a decorative image. */
alt: string
/** Rendered width. */
width?: number
/** Rendered height. */
height?: number
/** Tooltip text. */
title?: string
/** Called once the image has loaded. */
onLoad?: () => void
/** Called when the image fails to load (a broken URL, no network). */
onError?: () => void
/** Layout and paint both renderers apply. */
style?: BoxStyle & { objectFit?: 'cover' | 'contain' | 'fill' | 'none' }
/** Web-only paint. */
webStyle?: WebStyle
}
ScrollOffset
The physical scroll position, in CSS pixels on web or density-independent pixels on device.
interface ScrollOffset {
/** Distance from the content's left edge on both renderers, including in RTL layouts. */
readonly x: number
/** Distance from the content's top edge on both renderers. */
readonly y: number
}
ScrollAreaProps
A container that scrolls its children (native ScrollView).
interface ScrollAreaProps<Node = unknown> extends ElementProps {
/** The web tag. */
as: BoxTag
/** Axes enabled on device, default vertical. On web the authored overflow styles set the axes. */
direction?: 'vertical' | 'horizontal' | 'both'
/** Supplies both offsets when either changes on the web host or its native scroll view. */
onScroll?: (offset: ScrollOffset) => void
/** Focus order on the scroll area's outer frame. */
tabIndex?: InteractionProps['tabIndex']
/** Layout and paint both renderers apply. */
style?: BoxStyle
/** Web-only paint. */
webStyle?: WebStyle
/** Child elements. */
children?: Node
}
SvgPaintProps
Paint props every SVG shape takes.
interface SvgPaintProps {
/** Fill colour or `'none'`. */
fill?: string
/** Fill opacity, 0 to 1. */
fillOpacity?: number
/** Stroke colour or `'none'`. */
stroke?: string
/** Stroke width. */
strokeWidth?: number
/** Stroke opacity, 0 to 1. */
strokeOpacity?: number
/** Stroke end caps. */
strokeLinecap?: 'butt' | 'round' | 'square'
/** Stroke corners. */
strokeLinejoin?: 'miter' | 'round' | 'bevel'
/** Dash pattern. */
strokeDasharray?: string | number
/** Dash offset. */
strokeDashoffset?: number
/** Opacity, 0 to 1. */
opacity?: number
/** SVG transform (`'rotate(-90 12 12)'`). */
transform?: string
/** ClassMap classes. */
className?: string
}
SvgStyle
SVG inline paint and hit-testing supported by both renderers.
interface SvgStyle extends Omit<SvgPaintProps, 'className' | 'transform'> {
/** The CSS hit-testing mode on web and the shape's native hit-testing mode. */
pointerEvents?: 'auto' | 'none'
}
SvgElementProps
Identity, interaction and paint shared by an SVG canvas and its shapes.
interface SvgElementProps extends ElementProps, SvgPaintProps {
/** DOM tab order. On a device, a nonnegative value supplies a focusable target. */
tabIndex?: number
/** DOM click. On a device, draws a shape that can be pressed. */
onClick?: MouseEventHandler
/** DOM key down. Native routes focused activation through the supplied key handler. */
onKeyDown?: KeyboardEventHandler
/** Inline SVG paint and hit-testing, applied by the browser and on a device. */
style?: SvgStyle
/** Additional CSS, applied after `style` by the browser. Shape CSS is omitted on a device. */
webStyle?: WebStyle
}
SvgDefsProps
Definitions in the enclosing SVG's ID namespace on both renderers.
interface SvgDefsProps<Node = unknown> {
/** Definition elements drawn through references on web and native. */
children: Node
}
SvgClipPathProps
Geometry referenced by url(#id) as a clipping region.
interface SvgClipPathProps<Node = unknown> extends SvgDefsProps<Node> {
/** Local ID used by the browser's and device's SVG clipping engines. */
id: string
}
SvgGradientStop
One gradient stop. Equal offsets retain their input order on both renderers.
interface SvgGradientStop {
/** A fraction or percentage such as `'50%'`, passed to each renderer's stop. */
offset: ElementLength
/** CSS colour, including `currentColor`, which native resolves to the inherited ink. */
stopColor: string
/** Opacity from zero to one for the browser and native stop. */
stopOpacity?: number
}
SvgLinearGradientProps
A named linear paint server and its stops.
interface SvgLinearGradientProps {
/** Local ID used by paint references on web and native. */
id: string
/** Horizontal start in the selected coordinate system, on web and native. */
x1?: ElementLength
/** Vertical start in the selected coordinate system, on web and native. */
y1?: ElementLength
/** Horizontal end in the selected coordinate system, on web and native. */
x2?: ElementLength
/** Vertical end in the selected coordinate system, on web and native. */
y2?: ElementLength
/** Coordinate system for the gradient on both renderers. */
gradientUnits?: 'objectBoundingBox' | 'userSpaceOnUse'
/** In-order stop elements for the browser's SVG painter and react-native-svg. */
stops: readonly SvgGradientStop[]
}
SvgPatternProps
A named, repeating SVG tile.
interface SvgPatternProps<Node = unknown> extends SvgDefsProps<Node> {
/** Local ID used by paint references on web and native. */
id: string
/** Tile's horizontal origin for the browser and native SVG painter. */
x?: ElementLength
/** Tile's vertical origin for the browser and native SVG painter. */
y?: ElementLength
/** Tile width for the browser and native SVG painter. */
width: ElementLength
/** Tile height for the browser and native SVG painter. */
height: ElementLength
/** Coordinate system for the tile's origin and size, on both renderers. */
patternUnits?: 'objectBoundingBox' | 'userSpaceOnUse'
}
SvgImageProps
An image positioned in SVG user space.
interface SvgImageProps extends SvgElementProps {
/** Literal browser URL. Native resolves relative URLs against the public document URL. */
href: string
/** Horizontal origin on web and native. */
x?: ElementLength
/** Vertical origin on web and native. */
y?: ElementLength
/** Image viewport width on web and native. */
width: ElementLength
/** Image viewport height on web and native. */
height: ElementLength
/** Alignment and fit of the image in its viewport on both renderers. */
preserveAspectRatio?: string
}
SvgMetadata
Descriptive SVG children. They precede geometry on web and name the native graphic.
interface SvgMetadata {
/** Browser `<title>` and the device's fallback accessible name. */
title?: string
/** Browser `<desc>` and the device's accessible description. */
description?: {
/** ID that `aria-describedby` can reference on either renderer. */
id?: string
/** Description drawn as SVG metadata on web and spoken by the device. */
text: string
}
}
SvgProps
An SVG canvas (native react-native-svg Svg).
interface SvgProps<Node = unknown> extends SvgElementProps, ElementDragProps {
/** Rendered width. */
width?: number | `${number}%`
/** Rendered height. */
height?: number | `${number}%`
/** The user coordinate system (`'0 0 24 24'`). */
viewBox?: string
/**
* World-space rectangle painted inside a transformed native canvas layer. The native SVG
* viewport is positioned at this rectangle and draws it as its view box. The scale of the
* enclosing transform lets the native drawing use screen-sized raster dimensions. Browsers keep
* the authored SVG attributes and can paint past its bounds with visible overflow.
*/
nativeViewport?: Readonly<
ElementBox & {
/** Positive scale of the enclosing transform, defaulting to 1. */
scale?: number
}
>
/** How the view box fits the element. */
preserveAspectRatio?: string
/** Whether the canvas takes keyboard focus (web). */
focusable?: boolean
/** The SVG namespace attribute (web; a device ignores it). */
xmlns?: string
/** CSS for the web, and the style a device can draw of it. */
webStyle?: WebStyle
/** Descriptive SVG children on web, and name and description for native accessibility. */
metadata?: SvgMetadata
/** The browser's `shape-rendering` presentation hint. The device uses its SVG painter. */
webShapeRendering?: 'auto' | 'optimizeSpeed' | 'crispEdges' | 'geometricPrecision'
/** Language metadata emitted as `translate` on web and consumed before native drawing. */
translate?: 'yes' | 'no'
/** Shapes. */
children?: Node
}
SvgMarkupProps
An SVG canvas drawn from inner SVG markup (an icon set's prebuilt glyph; native react-native-svg
SvgXml). The markup is trusted: it comes from a bonded set, never from a user.
interface SvgMarkupProps extends Omit<SvgProps, 'children' | 'drag' | 'metadata'> {
/** The markup inside the `<svg>` element. */
markup: string
}
SvgPathProps
An SVG path.
interface SvgPathProps extends SvgElementProps {
/** Path data. */
d: string
/** Which areas the path fills. */
fillRule?: 'nonzero' | 'evenodd'
/** Which areas the path clips. */
clipRule?: 'nonzero' | 'evenodd'
}
SvgRectProps
An SVG rectangle.
interface SvgRectProps extends SvgElementProps {
/** Left edge. */
x?: number
/** Top edge. */
y?: number
/** Width. */
width: ElementLength
/** Height. */
height: ElementLength
/** Corner radius on x. */
rx?: number
/** Corner radius on y. */
ry?: number
/** Web `<title>` and `<desc>` inside this rectangle, mapped to its device focus target. */
metadata?: SvgMetadata
/** Web presentation attribute and native hit testing. Inline `style.pointerEvents` wins. */
pointerEvents?: SvgStyle['pointerEvents']
/** Web mouse entry or native hover into this rectangle when pointing hardware delivers it. */
onMouseEnter?: InteractionProps['onMouseEnter']
}
SvgCircleProps
An SVG circle.
interface SvgCircleProps extends SvgElementProps {
/** Centre x. The web and native SVG defaults are zero. */
cx?: number
/** Centre y. The web and native SVG defaults are zero. */
cy?: number
/** Radius. */
r: number
}
SvgEllipseProps
An SVG ellipse.
interface SvgEllipseProps extends SvgElementProps {
/** Centre x. */
cx: number
/** Centre y. */
cy: number
/** Radius on x. */
rx: number
/** Radius on y. */
ry: number
}
SvgLineProps
An SVG line.
interface SvgLineProps extends SvgElementProps {
/** Start x. */
x1: number
/** Start y. */
y1: number
/** End x. */
x2: number
/** End y. */
y2: number
}
SvgPolyProps
An SVG polyline or polygon.
interface SvgPolyProps extends SvgElementProps {
/** Points (`'0,0 10,10'`). */
points: string
}
SvgGroupProps
An SVG group.
interface SvgGroupProps<Node = unknown> extends SvgElementProps, ElementDragProps {
/** Local clipping region reference for the web or native SVG painter. */
clipPath?: `url(#${string})`
/** Shapes. */
children?: Node
}
SvgTextProps
SVG text.
interface SvgTextProps<Node = unknown> extends SvgElementProps {
/** Anchor x. */
x?: number
/** Anchor y. */
y?: number
/** Horizontal anchor. */
textAnchor?: 'start' | 'middle' | 'end'
/** SVG baseline on the web. Native maps explicit baselines to `alignmentBaseline`. */
dominantBaseline?: 'auto' | 'alphabetic' | 'middle' | 'central'
/** Font size. */
fontSize?: number
/** Font weight. */
fontWeight?: 'normal' | 'bold' | number
/** CSS font-family on web. The device selects an available family or its system font. */
fontFamily?: string
/** Text. */
children?: Node
}
NativeGridClasses
A CSS grid's classes (NativeClassSplit.grid), by breakpoint variant: '' at the base
size, then sm, md, … (UIClassMapNativeSplit.nativeBreakpoints). A device has no grid
layout, so a native element lays its children out from these.
interface NativeGridClasses {
/**
* Its columns: a count of equal columns (`grid-cols-3` is 3), or a CSS track list
* (`grid-cols-[1fr_2fr]` is `'1fr 2fr'`). No entry at the base size is one column.
*/
columns: Readonly<Record<string, number | string>>
/**
* Its explicit rows: a count of equal rows (`grid-rows-3`) or a CSS track list
* (`grid-rows-[auto_1fr]`). No entry: rows only as its items need them.
*/
rows?: Readonly<Record<string, number | string>>
/** The gap between its columns, in pixels (`gap-4` and `gap-x-4` are 16). */
columnGap: Readonly<Record<string, number>>
/** The gap between its rows, in pixels. */
rowGap: Readonly<Record<string, number>>
/** How its items sit in their rows (`items-center`); stretched when it sets none. */
alignItems: Readonly<Record<string, 'start' | 'end' | 'center' | 'stretch' | 'baseline'>>
}
NativeClassSplit
A class string divided for a native renderer, which has no CSS cascade (see
UIClassMapNativeSplit).
interface NativeClassSplit {
/** Classes the native view itself applies (no display class: `NativeClassSplit.display`). */
view: string
/**
* The text classes in effect for the element's text, as the CSS cascade would give them (text
* properties only: `visibility`, `cursor` and other inherited CSS properties do not pass down): the
* inherited ones the element's own text classes (colour, font, size, line height, letter
* spacing, alignment, case, decoration, white space) do not override, then its own. A native
* container hands them to the text inside it.
*/
text: string
/**
* The display the classes give the element at its base size (no responsive or state variant), or
* `null` when they set none: `flex`/`inline-flex` make its children flex items, `inline` and
* `inline-*` put it in a line with its inline siblings, `block` takes it out of one and
* `contents` lets a fieldset's children participate directly in its parent's layout.
*/
display:
| 'block'
| 'inline'
| 'inline-block'
| 'flex'
| 'inline-flex'
| 'grid'
| 'inline-grid'
| 'contents'
| 'none'
| null
/** The vertical alignment requested for a native table cell. */
verticalAlign?: 'middle'
/**
* The lines the element's text is clamped to with an ellipsis (`truncate` is 1,
* `line-clamp-3` is 3), or `null`. The clamp is the element's own: it is not inherited.
*/
lines: number | null
/**
* The font weight `NativeClassSplit.text` sets at its base size (`font-bold` is 700), or
* `null` when it sets none (the platform's normal weight). A `<strong>` draws `bolder` than it.
*/
weight: number | null
/**
* The line height in pixels for a field that grows by lines, keyed by breakpoint like the grid
* classes (`''` at the base size). A bond can omit this if it does not resolve text metrics.
*/
lineHeight?: Readonly<Record<string, number>>
/**
* Whether the classes set the element's width or height (`w-5`, `h-5`, `size-5`, at any
* breakpoint). On the web a class beats a replaced element's `width` and `height` attributes, so
* a native image or drawing takes those attributes only for the sizes its classes leave unset.
*/
sized?: { width: boolean; height: boolean }
/**
* Classes the element gives its descendants with one tag, as a CSS descendant selector does
* (`[&_p]:leading-relaxed` is `{ p: 'leading-relaxed' }`): left out of `view` and `text`, and
* applied by each descendant element whose tag it names, after that element's own classes.
*/
descendants?: Readonly<Record<string, string>>
/**
* The element's grid when `NativeClassSplit.display` is `grid` or `inline-grid`, else
* `null`. Its column and span classes are left out of `view`.
*/
grid?: NativeGridClasses | null
/**
* The columns the element spans as a grid item, by breakpoint variant (`col-span-2` is
* `{ '': 2 }`; `col-span-full` is every column).
*/
span?: Readonly<Record<string, number | 'full'>>
}
UIClassMapNativeSplit
The ClassMap member a device ClassMap (the nativewind bond) adds so native elements can do what the CSS cascade does on the web. Web ClassMaps leave it out.
interface UIClassMapNativeSplit {
/**
* Divides a class string for a native element.
*
* @param className - The element's classes.
* @param inheritedText - The text classes in effect for its container's text.
* @param data - The element's `data-*` attributes by name without the prefix (`{ state: 'open' }`):
* a class with a `data-[state=open]:` variant applies only when they match, as on the web.
* @returns The view classes, the text classes in effect for its own text, and its display.
*/
splitForNative?(
className: string,
inheritedText?: string,
data?: Readonly<Record<string, string | undefined>>,
): NativeClassSplit
/**
* The text classes a browser's stylesheet gives a `<button>` (its text is centred), which a
* native button hands to its text beneath the button's own classes.
*/
nativeButtonText?: string
/**
* The text classes the web's stylesheet gives the document (`html`, `body`), which every text
* inherits there: native text starts from them.
*/
nativeRootText?: string
/**
* Lets the native styling runtime supply resolved text colour to paint computed in JavaScript.
* The browser applies its own CSS cascade.
*
* @param classes - Text classes after native inheritance and overrides.
* @param render - Draws the renderer's element with the resolved colour, if any.
* @returns The renderer's element wrapped by the native styling runtime.
*/
renderNativeTextColor?(classes: string, render: (color: string | undefined) => unknown): unknown
/**
* The tags the web's stylesheet makes blocks although a browser draws them inline (Tailwind's
* reset makes `img` and `svg` blocks): a native image or drawing with one of these tags stacks
* like a block unless a class puts it in a line (`inline`, `inline-block`).
*/
nativeBlockTags?: readonly string[]
/**
* The window width, in pixels, from which each breakpoint variant applies (`sm:` from 640):
* a native grid picks its columns and gaps by it.
*/
nativeBreakpoints?: Readonly<Record<string, number>>
}
KitFieldChangeEvent
Both targets expose the field's string value during the callback.
interface KitFieldChangeEvent extends KitEvent {
/** The edited field, or its value snapshot on a device. */
readonly target: EventTarget & { value: string }
/** The field handling the change. */
readonly currentTarget: KitFieldChangeEvent['target']
}
OverlayPosition
The positioned surface's origin, and the side it ended up on.
interface OverlayPosition {
top: number
left: number
placement: TooltipPlacement
}
OverlayTarget
A mounted element that a layer can use for focus or ownership.
interface OverlayTarget {
readonly current: ElementHandle | null
}
OverlayFocusOptions
Initial focus and focus restoration for a blocking layer.
interface OverlayFocusOptions {
trap: true
initial?: OverlayTarget
restore: 'opener' | OverlayTarget | false
}
OverlayLayerOptions
Registration for an overlay, independent of where its surface is presented.
interface OverlayLayerOptions {
open: boolean
kind: OverlayLayerKind
surface: OverlayTarget
anchor?: OverlayTarget
dismissKey?: boolean
dismissBackdrop?: boolean
/** Dismiss outside the given elements on press start or activation. */
outside?: { inside: readonly OverlayTarget[]; phase: 'start' | 'activate' }
focus?: OverlayFocusOptions
lockScroll?: boolean
onDismiss?: (reason: OverlayDismissReason) => void
}
OverlayAnchorGeometry
Placement and collision policy for an anchored layer, in renderer-local units.
interface OverlayAnchorGeometry {
placement: TooltipPlacement
align?: 'start' | 'center' | 'end'
offset: number
padding: number
collision: 'none' | 'shift' | 'flip-shift'
}
UIProvider
Identifies the bonded UI styling library. Providers set name
to indicate which library is active (e.g. "tailwind", "bootstrap").
interface UIProvider {
/**
* Identifier for the styling library (e.g. `"tailwind"`, `"ionic"`).
*/
name: string
}
MoleculeSpinnerTimings
The mark's timings, in CSS duration strings. Swap cycle → glint cycle.
interface MoleculeSpinnerTimings {
/** One full 3-phase atom-swap cycle (also drives bond fades + glints). */
dur: string
/** Whole-figure rotation. Keep at two swap cycles for the intended feel. */
spin: string
/** Bond gradient flow period (one full translate across the figure). */
flow: string
}
MoleculeSpinnerColors
Gradient-mode colors. Any CSS color string, including var() forms.
interface MoleculeSpinnerColors {
/** Bond base / glint tail color. */
blue?: string
/** Flow highlight / glint head color at rest. */
light?: string
/** Glint ignition color while an atom is in flight. */
peach?: string
}
MoleculeSpinnerMarkOptions
Options for moleculeSpinnerMarkSvg.
interface MoleculeSpinnerMarkOptions {
/** Motion timings; defaults to the shipped design (2.5s / 5s / 3s). */
timings?: Partial<MoleculeSpinnerTimings>
/** `gradient` (default) or `mono` — plain `currentColor` outline, no defs. */
paint?: 'gradient' | 'mono'
/** Gradient-mode colors; default the `var(--mol-spin-*, fallback)` set. */
colors?: MoleculeSpinnerColors
/**
* Gradient id for url() references. Must be unique per rendered instance
* on a page. Defaults to `mol-spinner-gradient`.
*/
gradientId?: string
/** Pixel size baked into width/height; omit when CSS sizes the svg. */
size?: number
/** Class attribute for the svg element. */
className?: string
/** Inline style attribute (already serialized, e.g. `color:re$d`). */
style?: string
/** Announce as `role="status"` with this label; omit for `aria-hidden`. */
ariaLabel?: string
}
CSSProperties
Framework-agnostic CSS properties. Mirrors React.CSSProperties but without React dependency.
interface CSSProperties {
[key: string]: string | number | undefined
}
KitEvent
The event a web UI kit hands a component's handler: the members shared by the web kits. React's kit
passes React's event (so stopPropagation() stops React parent handlers), the other web kits pass the DOM event;
both satisfy this type. A handler that needs a member only one of them has (nativeEvent, composedPath(),
isComposing) takes the component's ref element (see BaseProps) and listens on it.
type is left out on purpose: kits report different event types for the same moment (a text field's
onChange is React's 'change' and the DOM's 'input').
interface KitEvent {
/** The element the event started on. */
readonly target: EventTarget | null
/** The element of the component the handler was passed to. */
readonly currentTarget: EventTarget | null
/** Whether a handler already called `KitEvent.preventDefault`. */
readonly defaultPrevented: boolean
/** Cancels the browser's default action (a form's submit, a checkbox's toggle). */
preventDefault(): void
/** Stops handlers of ancestor components of the same kit. */
stopPropagation(): void
}
KitModifierKeys
The modifier keys held during a mouse or keyboard event.
interface KitModifierKeys {
/** Alt (Option) was held. */
readonly altKey: boolean
/** Control was held. */
readonly ctrlKey: boolean
/** Meta (Command, Windows) was held. */
readonly metaKey: boolean
/** Shift was held. */
readonly shiftKey: boolean
}
KitMouseEvent
A mouse event as every kit hands it to a handler.
interface KitMouseEvent extends KitEvent, KitModifierKeys {
/** The button that changed state (0 main, 1 auxiliary, 2 secondary). */
readonly button: number
/** The buttons held, as a bit mask. */
readonly buttons: number
/** The pointer's x position in the viewport. */
readonly clientX: number
/** The pointer's y position in the viewport. */
readonly clientY: number
/** The pointer's x position in the document. */
readonly pageX: number
/** The pointer's y position in the document. */
readonly pageY: number
/** The click count of a click event. */
readonly detail: number
/** The element the pointer came from or went to, for enter and leave events. */
readonly relatedTarget: EventTarget | null
}
KitKeyboardEvent
A keyboard event as every kit hands it to a handler.
interface KitKeyboardEvent extends KitEvent, KitModifierKeys {
/** The key's value (`'Enter'`, `'a'`). */
readonly key: string
/** The physical key (`'KeyA'`). */
readonly code: string
/** Whether the key is held down and auto-repeating. */
readonly repeat: boolean
}
KitFocusEvent
A focus event as every kit hands it to a handler.
interface KitFocusEvent extends KitEvent {
/** The element losing focus (on focus) or gaining it (on blur). */
readonly relatedTarget: EventTarget | null
}
BaseProps
Base props shared by all components.
Ref element: a component that renders one main element gives the caller that element, the one
that takes className and style. Each UI kit hands it over in its framework's own way: React
and Solid a ref, Vue a template ref's $el, Svelte bind:ref, Angular the component's
element() signal. It is empty while the element is not rendered (a closed Tooltip, Dropdown or
Modal). A component's own doc names the element when it is not the outermost one.
interface BaseProps {
/**
* Additional CSS class name(s).
*/
className?: string
/**
* Inline styles.
*/
style?: CSSProperties
/**
* Test ID for automated testing.
*/
testId?: string
/**
* Automation ID for AI agents and E2E tests. Maps to the `data-mol-id`
* HTML attribute. Use `molId()` from `./automation.js` to generate
* semantic IDs. (Tooling only — screen readers do not expose `data-*`
* attributes; accessible names come from labels/`aria-*`.)
*/
automationId?: string
/**
* Disables the controls the component renders: a disabled Button, Input, Textarea, Select,
* Checkbox, Switch, RadioGroup, Tabs, Accordion or Pagination takes no input, a disabled
* Dropdown never opens, and a disabled Card never calls `onClick` (an interactive one is
* announced as disabled and leaves the tab order). A component that renders no control
* (Badge, Spinner, Skeleton, a layout box) ignores it.
*/
disabled?: boolean
}
HTMLElementProps
Base props for HTML elements. Framework bindings should extend this with framework-specific attributes.
interface HTMLElementProps extends BaseProps, Pick<ElementProps, 'lang'> {
id?: string
title?: string
tabIndex?: number
role?: ElementRole
'aria-label'?: string
'aria-labelledby'?: string
'aria-describedby'?: string
'aria-hidden'?: boolean
'aria-disabled'?: boolean
'aria-expanded'?: boolean
'aria-selected'?: boolean
'aria-checked'?: boolean | 'mixed'
'aria-pressed'?: boolean | 'mixed'
'aria-invalid'?: boolean
'aria-required'?: boolean
'aria-readonly'?: boolean
'aria-busy'?: boolean
'aria-live'?: 'off' | 'polite' | 'assertive'
onClick?: MouseEventHandler
onDoubleClick?: MouseEventHandler
onMouseEnter?: MouseEventHandler
onMouseLeave?: MouseEventHandler
onFocus?: FocusEventHandler
onBlur?: FocusEventHandler
onKeyDown?: KeyboardEventHandler
onKeyUp?: KeyboardEventHandler
onKeyPress?: KeyboardEventHandler
}
InputElementProps
Base props for input elements.
interface InputElementProps extends HTMLElementProps {
name?: string
value?: string | number | readonly string[]
defaultValue?: string | number | readonly string[]
placeholder?: string
required?: boolean
readOnly?: boolean
autoFocus?: boolean
autoComplete?: string
maxLength?: number
minLength?: number
pattern?: string
/** Web change event. Prefer the control's value callback for shared web and native code. */
onChange?: ChangeEventHandler
onInput?: FormEventHandler
}
ButtonElementProps
Base props for button elements.
interface ButtonElementProps extends HTMLElementProps {
/**
* Defaults to `'button'` in every framework binding, so a button never submits a
* form by accident. A form's primary action must set `type="submit"`: Enter then
* submits the form, and tests that select `button[type="submit"]` find it.
*/
type?: 'button' | 'submit' | 'reset'
name?: string
value?: string
form?: string
}
TextareaElementProps
Base props for textarea elements.
interface TextareaElementProps extends HTMLElementProps {
name?: string
value?: string
defaultValue?: string
placeholder?: string
required?: boolean
readOnly?: boolean
autoFocus?: boolean
rows?: number
cols?: number
maxLength?: number
minLength?: number
wrap?: 'hard' | 'soft' | 'off'
/** Web change event. `TextareaProps.onValueChange` also works on native. */
onChange?: EventHandler<KitFieldChangeEvent>
onInput?: FormEventHandler
}
SelectElementProps
Base props for select elements.
interface SelectElementProps extends HTMLElementProps {
name?: string
required?: boolean
autoFocus?: boolean
multiple?: boolean
/** Web change event. `SelectProps.onValueChange` also works on native. */
onChange?: EventHandler<KitFieldChangeEvent>
}
FormElementProps
Base props for form elements.
interface FormElementProps extends HTMLElementProps {
action?: string
method?: 'get' | 'post'
encType?: string
target?: string
noValidate?: boolean
autoComplete?: 'on' | 'off'
onSubmit?: FormEventHandler
onReset?: FormEventHandler
}
ButtonProps
Props for the Button component.
interface ButtonProps extends ButtonElementProps {
/**
* Button content.
*/
children?: Children
/**
* Visual variant.
*/
variant?: ButtonVariant
/**
* Color scheme.
*/
color?: ColorVariant
/**
* Button size.
*/
size?: ButtonSize
/**
* Whether the button is in a loading state.
*/
loading?: boolean
/**
* Loading text to display.
*/
loadingText?: string
/**
* Whether the button takes full width.
*/
fullWidth?: boolean
/**
* Icon to display before the label.
*/
leftIcon?: Children
/**
* Icon to display after the label.
*/
rightIcon?: Children
}
InputProps
Props for the Input component (text field, email, password, etc.).
Ref element: the native <input>.
interface InputProps extends InputElementProps, Pick<TextFieldProps, 'onValueChange'> {
/** The edited field's text is available as `event.target.value`. */
onChange?: EventHandler<KitFieldChangeEvent>
/**
* Input type.
*/
type?: InputType
/**
* Input size.
*/
size?: Size
/**
* Horizontal text alignment inside the input (see
* `InputClassOptions.align`). Defaults to the bond's own style.
*/
align?: 'left' | 'center'
/**
* Label text.
*/
label?: string
/**
* Error message.
*/
error?: string
/**
* Hint/help text.
*/
hint?: string
/**
* Element to display on the left.
*/
leftElement?: Children
/**
* Element to display on the right.
*/
rightElement?: Children
/**
* Whether to show a clear button.
*/
clearable?: boolean
/**
* Called when the clear button is clicked.
*/
onClear?: () => void
/**
* Accessible label for the clear button.
* @default 'Clear'
*/
clearLabel?: string
}
FloatingInputProps
Props for the FloatingInput component: an input whose placeholder is also its label, drawn above the text.
Ref element: the native <input>.
interface FloatingInputProps extends InputElementProps, Pick<TextFieldProps, 'onValueChange'> {
/**
* Input type.
*/
type?: InputType
}
TextareaProps
Props for the Textarea component.
Ref element: the native <textarea>.
interface TextareaProps extends TextareaElementProps, Pick<TextFieldProps, 'onValueChange'> {
/**
* Text size tier (see `TextareaClassOptions.size`) — pass the same
* `size` as a neighboring Input for identical font sizes.
*/
size?: Size
/**
* Label text.
*/
label?: string
/**
* Error message.
*/
error?: string
/**
* Hint/help text.
*/
hint?: string
/**
* Whether the textarea auto-resizes.
*/
autoResize?: boolean
/**
* Minimum number of rows.
*/
minRows?: number
/**
* Maximum number of rows.
*/
maxRows?: number
}
SelectOption
A single option in a Select dropdown.
interface SelectOption<T = string> {
/**
* Option value.
*/
value: T
/**
* Display label.
*/
label: string
/**
* Whether the option is disabled.
*/
disabled?: boolean
/**
* Option group (for grouped selects).
*/
group?: string
}
SelectProps
Props for the Select dropdown component (single or multi-select).
Ref element: the native <select>.
interface SelectProps<T = string> extends SelectElementProps {
/**
* Select options.
*/
options: SelectOption<T>[]
/**
* Current value.
*/
value?: T
/**
* Called with the selected value on web and native.
*/
onValueChange?: (value: T) => void
/**
* Select size.
*/
size?: Size
/**
* Label text.
*/
label?: string
/**
* Placeholder text.
*/
placeholder?: string
/**
* Error message.
*/
error?: string
/**
* Hint/help text.
*/
hint?: string
/**
* Whether to allow clearing the selection.
*/
clearable?: boolean
}
CheckboxProps
Props for the Checkbox component.
Ref element: the native <input type="checkbox">.
interface CheckboxProps extends InputElementProps, Pick<CheckFieldProps, 'onCheckedChange'> {
/**
* Checkbox label.
*/
label?: Children
/**
* Whether the checkbox is checked.
*/
checked?: boolean
/**
* Whether the checkbox is in an indeterminate state.
*/
indeterminate?: boolean
/**
* Checkbox size.
*/
size?: Size
/**
* Error message.
*/
error?: string
}
RadioOption
A single option in a RadioGroup.
interface RadioOption<T = string> {
/**
* Option value.
*/
value: T
/**
* Display label.
*/
label: Children
/**
* Whether the option is disabled.
*/
disabled?: boolean
}
RadioGroupProps
Props for the RadioGroup component.
interface RadioGroupProps<T = string> extends BaseProps {
/**
* Radio options.
*/
options: RadioOption<T>[]
/**
* Current value.
*/
value?: T
/**
* Change handler.
*/
onChange?: (value: T) => void
/**
* Radio size.
*/
size?: Size
/**
* Group label.
*/
label?: string
/**
* Shared `name` attribute for the group's radio inputs (used for native
* form submission). When omitted, a unique per-instance name is generated
* so separate groups never merge — the visible `label` is deliberately
* NOT used as the name, because two groups with the same label (e.g. two
* "Size" pickers) would otherwise form ONE native radio group and
* deselect each other.
*/
name?: string
/**
* Layout direction.
*/
direction?: 'horizontal' | 'vertical'
/**
* Error message.
*/
error?: string
}
SwitchProps
Props for the Switch/Toggle component.
Ref element: the role="switch" button.
interface SwitchProps extends InputElementProps, Pick<CheckFieldProps, 'onCheckedChange'> {
/**
* Switch label.
*/
label?: Children
/**
* Whether the switch is on.
*/
checked?: boolean
/**
* Switch size.
*/
size?: Size
/**
* Color when on.
*/
color?: ColorVariant
}
ModalProps
Props for the Modal/Dialog component.
Ref element: the dialog (role="dialog"), empty while closed.
interface ModalProps extends HTMLElementProps {
/**
* Whether the modal is open.
*/
open: boolean
/**
* Called when the modal should close.
*/
onClose: () => void
/**
* Modal title.
*/
title?: string
/**
* Modal content.
*/
children?: Children
/**
* Modal size.
*/
size?: ModalSize
/**
* Whether to show a close button.
*/
showCloseButton?: boolean
/**
* Whether clicking the overlay closes the modal.
*/
closeOnOverlayClick?: boolean
/**
* Whether pressing Escape closes the modal.
*/
closeOnEscape?: boolean
/**
* Footer content (typically action buttons).
*/
footer?: Children
/**
* Whether the modal is centered vertically.
*/
centered?: boolean
/**
* Whether to prevent body scroll when open.
*/
preventScroll?: boolean
/**
* Accessible label for the close button.
* @default 'Close'
*/
closeLabel?: string
/**
* The control that takes focus when the modal opens, such as the field a dialog exists to fill.
* Without it, focus goes to the first focusable control, or to the dialog when it has none. The
* modal reads it once the open dialog is in the document, so a control rendered in the
* children can be named here.
*/
initialFocus?: OverlayTarget
}
SpinnerProps
Props for the Spinner/loading indicator component.
interface SpinnerProps extends BaseProps {
/**
* Spinner size.
*/
size?: Size
/**
* Spinner color.
*/
color?: ColorVariant | string
/**
* Loading label (for accessibility).
*/
label?: string
/**
* Spinner thickness.
*/
thickness?: number
}
AvatarProps
Props for the Avatar component.
interface AvatarProps extends HTMLElementProps {
/**
* Image source URL.
*/
src?: string
/**
* Alt text for the image.
*/
alt?: string
/**
* Name for fallback initials.
*/
name?: string
/**
* Avatar size.
*/
size?: Size | number
/**
* Whether the avatar is rounded.
*/
rounded?: boolean
/**
* Fallback element when no image.
*/
fallback?: Children
}
BadgeProps
Props for the Badge component (status labels, counts, tags).
interface BadgeProps extends HTMLElementProps {
/**
* Badge content.
*/
children?: Children
/**
* Badge color.
*/
color?: ColorVariant
/**
* Badge variant.
*/
variant?: 'solid' | 'outline' | 'subtle'
/**
* Badge size.
*/
size?: Size
/**
* Whether the badge is rounded.
*/
rounded?: boolean
}
TooltipProps
Props for the Tooltip component (hover/focus popover with informational text).
Ref element: the role="tooltip" box, empty while hidden.
interface TooltipProps extends HTMLElementProps {
/**
* Tooltip content.
*/
content: Children
/**
* Element that triggers the tooltip.
*/
children: Children
/**
* Tooltip placement.
*/
placement?: TooltipPlacement
/**
* Delay before showing (ms).
*/
delay?: number
/**
* Whether the tooltip has an arrow.
*/
hasArrow?: boolean
}
CardProps
Props for the Card container component (elevated, outlined, or filled surface).
interface CardProps extends HTMLElementProps {
/**
* Card content.
*/
children?: Children
/**
* Card variant.
*/
variant?: 'elevated' | 'outlined' | 'filled'
/**
* Whether the card is interactive (clickable).
*/
interactive?: boolean
/**
* Padding size.
*/
padding?: Size | 'none'
}
CardSectionProps
Props of a card's header, title, description, content and footer.
interface CardSectionProps extends ElementProps {
/** Tooltip text. */
title?: string
/** CSS for the web. */
style?: CSSProperties
/** Contents. */
children?: Children
}
ContainerProps
Props for the Container layout component.
interface ContainerProps extends HTMLElementProps {
/**
* Container content.
*/
children?: Children
/**
* Maximum width.
*/
maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full' | string
/**
* Whether to center the container.
*/
centered?: boolean
/**
* Horizontal padding.
*/
paddingX?: Size | string
}
FlexProps
Flex container props.
interface FlexProps extends HTMLElementProps {
/**
* Flex content.
*/
children?: Children
/**
* Flex direction.
*/
direction?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
/**
* Justify content.
*/
justify?: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'
/**
* Align items.
*/
align?: 'start' | 'end' | 'center' | 'baseline' | 'stretch'
/**
* Flex wrap.
*/
wrap?: 'wrap' | 'nowrap' | 'wrap-reverse'
/**
* Gap between items.
*/
gap?: Size | string | number
}
GridProps
Grid container props.
interface GridProps extends HTMLElementProps {
/**
* Grid content.
*/
children?: Children
/**
* Number of columns.
*/
columns?: number | string
/**
* Number of rows.
*/
rows?: number | string
/**
* Gap between items.
*/
gap?: Size | string | number
/**
* Column gap.
*/
columnGap?: Size | string | number
/**
* Row gap.
*/
rowGap?: Size | string | number
}
SpacerProps
Props for the Spacer layout component (adds whitespace between elements).
interface SpacerProps extends BaseProps {
/**
* Space size.
*/
size?: Size | string | number
/**
* Whether the spacer is horizontal.
*/
horizontal?: boolean
}
FormProps
Props for the Form component (wraps inputs with submission handling and validation).
interface FormProps extends FormElementProps {
/**
* Form content.
*/
children?: Children
/**
* Submit handler with form data.
*/
onFormSubmit?: (data: Record<string, unknown>) => void | Promise<void>
/**
* Whether the form is submitting.
*/
submitting?: boolean
}
FormFieldProps
Form field wrapper props.
interface FormFieldProps extends HTMLElementProps {
/**
* Field content.
*/
children?: Children
/**
* Field label.
*/
label?: string
/**
* Field name.
*/
name?: string
/**
* Error message.
*/
error?: string
/**
* Hint/help text.
*/
hint?: string
/**
* Whether the field is required.
*/
required?: boolean
}
AlertProps
Props for the Alert component.
interface AlertProps extends HTMLElementProps {
/**
* Alert content.
*/
children?: Children
/**
* Alert title.
*/
title?: string
/**
* Alert status/type.
*/
status?: ColorVariant
/**
* Alert variant.
*/
variant?: 'solid' | 'subtle' | 'outline' | 'left-accent'
/**
* Whether the alert is dismissible.
*/
dismissible?: boolean
/**
* Called when dismissed.
*/
onDismiss?: () => void
/**
* Icon to display.
*/
icon?: Children
/**
* Accessible label for the dismiss button.
* @default 'Dismiss'
*/
dismissLabel?: string
}
ToastProps
Props for the Toast/notification component.
interface ToastProps extends HTMLElementProps {
/**
* Toast content.
*/
children?: Children
/**
* Toast title.
*/
title?: string
/**
* Toast description.
*/
description?: string
/**
* Toast status/type.
*/
status?: ColorVariant
/**
* Duration in milliseconds (0 for persistent).
*/
duration?: number
/**
* Whether the toast is dismissible.
*/
dismissible?: boolean
/**
* Called when dismissed.
*/
onDismiss?: () => void
/**
* Toast position.
*/
position?: 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left'
/**
* Accessible label for the close button.
* @default 'Close'
*/
closeLabel?: string
}
TabItem
A single tab in a Tabs component.
interface TabItem<T = string> {
/**
* Tab value/id.
*/
value: T
/**
* Tab label.
*/
label: Children
/**
* Tab content.
*/
content?: Children
/**
* Whether the tab is disabled.
*/
disabled?: boolean
/**
* Icon to display.
*/
icon?: Children
}
TabsProps
Props for the Tabs component (switchable tabbed content panels).
interface TabsProps<T = string> extends BaseProps {
/**
* Tab items.
*/
items: TabItem<T>[]
/**
* Current active tab.
*/
value?: T
/**
* Default active tab.
*/
defaultValue?: T
/**
* Change handler.
*/
onChange?: (value: T) => void
/**
* Tab variant.
*/
variant?: 'line' | 'enclosed' | 'soft-rounded' | 'solid-rounded'
/**
* Tab size.
*/
size?: Size
/**
* Whether tabs are fitted (take full width).
*/
fitted?: boolean
}
AccordionItem
A single item in an Accordion component.
interface AccordionItem<T = string> {
/**
* Item value/id.
*/
value: T
/**
* Item header/trigger.
*/
header: Children
/**
* Item content.
*/
content: Children
/**
* Whether the item is disabled.
*/
disabled?: boolean
}
AccordionProps
Props for the Accordion component.
interface AccordionProps<T = string> extends BaseProps {
/**
* Accordion items.
*/
items: AccordionItem<T>[]
/**
* Expanded item(s).
*/
value?: T | T[]
/**
* Default expanded item(s).
*/
defaultValue?: T | T[]
/**
* Change handler.
*/
onChange?: (value: T | T[]) => void
/**
* Whether multiple items can be expanded.
*/
multiple?: boolean
/**
* Whether items can be collapsed.
*/
collapsible?: boolean
}
TableColumn
Table column definition.
interface TableColumn<T> {
/**
* Column key (data property).
*/
key: keyof T | string
/**
* Column header.
*/
header: Children
/**
* Custom cell renderer.
*/
render?: (value: unknown, row: T, index: number) => Children
/**
* Column width.
*/
width?: string | number
/**
* Whether the column is sortable.
*/
sortable?: boolean
/**
* Text alignment.
*/
align?: 'left' | 'center' | 'right'
}
TableProps
Props for the Table component.
Ref element: the <table>.
interface TableProps<T> extends HTMLElementProps {
/**
* Table data.
*/
data: T[]
/**
* Column definitions.
*/
columns: TableColumn<T>[]
/**
* Row key extractor.
*/
rowKey?: keyof T | ((row: T) => string | number)
/**
* Whether to show borders.
*/
bordered?: boolean
/**
* Whether rows are striped.
*/
striped?: boolean
/**
* Whether rows are hoverable.
*/
hoverable?: boolean
/**
* Table size.
*/
size?: Size
/**
* Empty state content.
*/
emptyContent?: Children
/**
* Loading state.
*/
loading?: boolean
/**
* Sort configuration.
*/
sort?: { key: string; direction: 'asc' | 'desc' }
/**
* Sort change handler.
*/
onSort?: (key: string, direction: 'asc' | 'desc') => void
/**
* Row click handler.
*/
onRowClick?: (row: T, index: number) => void
}
PaginationProps
Props for the Pagination component (page navigation with current page, total, page size, and change callbacks).
interface PaginationProps extends BaseProps {
/**
* Current page (1-indexed).
*/
page: number
/**
* Total number of pages.
*/
totalPages: number
/**
* Page change handler.
*/
onChange: (page: number) => void
/**
* Number of sibling pages to show.
*/
siblings?: number
/**
* Number of boundary pages to show.
*/
boundaries?: number
/**
* Pagination size.
*/
size?: Size
/**
* Whether to show first/last buttons.
*/
showFirstLast?: boolean
/**
* Whether to show previous/next buttons.
*/
showPrevNext?: boolean
/**
* Accessible labels for pagination controls.
*/
labels?: {
nav?: string
first?: string
previous?: string
next?: string
last?: string
goToPage?: (page: number) => string
}
}
SkeletonProps
Props for the Skeleton loading placeholder component.
interface SkeletonProps extends BaseProps {
/**
* Skeleton width.
*/
width?: string | number
/**
* Skeleton height.
*/
height?: string | number
/**
* Whether the skeleton is circular.
*/
circle?: boolean
/**
* Border radius.
*/
borderRadius?: string | number
/**
* Animation type.
*/
animation?: 'pulse' | 'wave' | 'none'
}
SeparatorProps
Props for the Separator/Divider component.
interface SeparatorProps extends BaseProps {
/**
* Separator orientation.
*/
orientation?: 'horizontal' | 'vertical'
/**
* Whether the separator is decorative only.
*/
decorative?: boolean
}
DropdownItem
Dropdown menu item.
interface DropdownItem<T = string> {
/**
* Item value/id.
*/
value: T
/**
* Display label.
*/
label: Children
/**
* Whether the item is disabled.
*/
disabled?: boolean
/**
* Icon to display.
*/
icon?: Children
/**
* Keyboard shortcut display.
*/
shortcut?: string
/**
* Whether this is a separator.
*/
separator?: boolean
/**
* Nested items (for submenus).
*/
items?: DropdownItem<T>[]
}
DropdownProps
Props for the Dropdown menu component.
Ref element: the role="menu" element, empty while closed (testId and automationId go to the trigger).
interface DropdownProps<T = string> extends BaseProps {
/**
* Dropdown trigger element.
*/
trigger: Children
/**
* Dropdown items.
*/
items: DropdownItem<T>[]
/**
* Called when an item is selected.
*/
onSelect?: (value: T) => void
/**
* Dropdown placement.
*/
placement?:
'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'right'
/**
* Whether the dropdown is open (controlled).
*/
open?: boolean
/**
* Called when open state changes.
*/
onOpenChange?: (open: boolean) => void
/**
* Menu alignment.
*/
align?: 'start' | 'center' | 'end'
/**
* Menu width.
*/
width?: 'trigger' | 'auto' | number | string
}
PageShellProps
Props for the PageShell component — authenticated page wrapper with navigation.
interface PageShellProps extends BaseProps {
/** Sidebar content (navigation links). */
sidebar?: Children
/** Top bar content (breadcrumbs, user menu). */
topbar?: Children
/** Whether the sidebar is collapsed. */
sidebarCollapsed?: boolean
/** Callback when sidebar toggle is clicked. */
onSidebarToggle?: () => void
/** Main content. */
children?: Children
}
EmptyStateProps
Props for the EmptyState component — shown when a list or section has no data.
interface EmptyStateProps extends BaseProps {
/** Icon or illustration to display. */
icon?: Children
/** Main heading text. */
title: string
/** Description text. */
description?: string
/** Primary action button (e.g., "Create first item"). */
action?: Children
}
PageHeaderProps
Props for the PageHeader component — consistent page title area.
interface PageHeaderProps extends BaseProps {
/** Page title. */
title: string
/** Page description. */
description?: string
/** Action buttons (e.g., "Create", "Export"). */
actions?: Children
/** Breadcrumb trail. */
breadcrumbs?: Array<{ label: string; href?: string }>
}
ButtonClassOptions
Options for resolving button CSS classes via UIClassMap.
interface ButtonClassOptions {
variant?: ButtonVariant
color?: ColorVariant
size?: ButtonSize
fullWidth?: boolean
}
InputClassOptions
Options for resolving input CSS classes via UIClassMap.
interface InputClassOptions {
error?: boolean
size?: Size
/**
* Horizontal text alignment inside the input. Bonds may default to a
* centered aesthetic (e.g. the Tailwind bond's floating-label style);
* `'left'` opts a specific field out — e.g. a form field sitting next to
* left-aligned textareas.
*/
align?: 'left' | 'center'
}
TextareaClassOptions
Options for textarea class resolution.
interface TextareaClassOptions {
error?: boolean
/**
* Text size tier, matching `InputClassOptions.size` — a same-`size`
* input + textarea pair renders identical font sizes. Bonds default to
* their historic textarea size when omitted.
*/
size?: Size
}
SelectClassOptions
Options for resolving select CSS classes via UIClassMap.
interface SelectClassOptions {
error?: boolean
size?: Size
}
CheckboxClassOptions
Options for resolving checkbox CSS classes via UIClassMap.
interface CheckboxClassOptions {
error?: boolean
}
RadioClassOptions
Options for resolving radio CSS classes via UIClassMap.
interface RadioClassOptions {
error?: boolean
}
SwitchClassOptions
Options for switch class resolution.
interface SwitchClassOptions {
size?: Size
/**
* Color used for the checked/on track. Reuses the same semantic color
* scale as `ButtonClassOptions.color`/`BadgeClassOptions.variant`.
* @default 'primary'
*/
color?: ColorVariant
}
LabelClassOptions
Options for label class resolution.
interface LabelClassOptions {
required?: boolean
}
CardClassOptions
Options for resolving card CSS classes via UIClassMap.
interface CardClassOptions {
variant?: 'default' | 'elevated' | 'outline' | 'ghost'
}
BadgeClassOptions
Options for resolving badge CSS classes via UIClassMap.
interface BadgeClassOptions {
variant?: ColorVariant
size?: Size
}
AlertClassOptions
Options for resolving alert CSS classes via UIClassMap.
interface AlertClassOptions {
variant?: 'default' | 'info' | 'success' | 'warning' | 'error'
}
AvatarClassOptions
Options for resolving avatar CSS classes via UIClassMap.
interface AvatarClassOptions {
size?: Size
}
ModalClassOptions
Options for resolving modal/dialog CSS classes via UIClassMap.
interface ModalClassOptions {
size?: ModalSize
}
SpinnerClassOptions
Options for resolving spinner CSS classes via UIClassMap.
interface SpinnerClassOptions {
size?: Size
}
ToastClassOptions
Options for toast class resolution.
interface ToastClassOptions {
variant?: 'default' | 'success' | 'warning' | 'error' | 'info'
}
SeparatorClassOptions
Options for resolving separator CSS classes via UIClassMap.
interface SeparatorClassOptions {
orientation?: 'horizontal' | 'vertical'
}
AccordionClassOptions
Options for resolving accordion CSS classes via UIClassMap.
interface AccordionClassOptions {
variant?: string
}
TabsClassOptions
Options for resolving tabs (tabsList/tabsTrigger/tabsContent) CSS
classes via UIClassMap. Active vs inactive trigger styling is NOT one of
these options — it is expressed as data-[state=active] CSS attribute
selectors baked into the returned class string, driven by the
data-state="active"|"inactive" attribute the framework binding already
sets on the trigger element (see @molecule/app-ui-react's Tabs).
interface TabsClassOptions {
/**
* Visual style: underline indicator, bordered/filled boxes, a soft-bg
* pill, or a solid-bg pill.
*/
variant?: 'line' | 'enclosed' | 'soft-rounded' | 'solid-rounded'
size?: Size
}
PaginationClassOptions
Options for pagination item class resolution.
interface PaginationClassOptions {
active?: boolean
size?: Size
}
ContainerClassOptions
Options for container class resolution.
interface ContainerClassOptions {
size?: Size | '2xl' | 'full'
}
FlexClassOptions
Options for flex class resolution.
interface FlexClassOptions {
direction?: 'row' | 'col' | 'row-reverse' | 'col-reverse'
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'
wrap?: 'wrap' | 'nowrap' | 'wrap-reverse'
/** Named tokens or Tailwind spacing scale index (e.g. `3` → `gap-3`). */
gap?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number
}
GridClassOptions
Options for grid class resolution.
interface GridClassOptions {
cols?: number
/** Named tokens or Tailwind spacing scale index (e.g. `10` → `gap-10`). */
gap?: 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | number
/**
* Mobile-first responsive collapse. When omitted (the default), a grid of
* `cols >= 2` starts at a single column on small screens and steps up to
* `cols` at larger breakpoints, so cards don't overflow on mobile. Pass
* `false` for a FIXED `cols`-column grid at every viewport width. Ignored
* for `cols <= 1` (always single-column) and by ClassMap bonds without a
* breakpoint system (e.g. NativeWind).
*/
responsive?: boolean
}
UIClassMap
UIClassMap interface — the contract for styling-agnostic class resolution.
Each styling library (Tailwind, Bootstrap, etc.) provides its own UIClassMap
implementation. Component resolvers accept GENERIC variant names from
@molecule/app-ui types and map to library-specific classes internally.
Framework UI packages (@molecule/app-ui-react, etc.) call getClassMap()
at render time to resolve classes without knowing which styling library
is active.
interface UIClassMap extends UIClassMapNativeSplit {
cn(...classes: ClassMapValue[]): string
button(opts?: ButtonClassOptions): string
input(opts?: InputClassOptions): string
textarea(opts?: TextareaClassOptions): string
select(opts?: SelectClassOptions): string
checkbox(opts?: CheckboxClassOptions): string
radio(opts?: RadioClassOptions): string
checkFieldMark?: (
mark: 'checked' | 'mixed' | 'radio',
controlClasses?: string,
) => { path: string; className: string }
switchBase(opts?: SwitchClassOptions): string
switchThumb(opts?: SwitchClassOptions): string
label(opts?: LabelClassOptions): string
card(opts?: CardClassOptions): string
badge(opts?: BadgeClassOptions): string
alert(opts?: AlertClassOptions): string
avatar(opts?: AvatarClassOptions): string
modal(opts?: ModalClassOptions): string
spinner(opts?: SpinnerClassOptions): string
toast(opts?: ToastClassOptions): string
separator(opts?: SeparatorClassOptions): string
accordion(opts?: AccordionClassOptions): string
pagination(opts?: PaginationClassOptions): string
tabsList(opts?: TabsClassOptions): string
tabsTrigger(opts?: TabsClassOptions): string
tabsContent(opts?: TabsClassOptions): string
tooltip(): string
progress(): string
progressBar(): string
skeleton(): string
container(opts?: ContainerClassOptions): string
flex(opts?: FlexClassOptions): string
grid(opts?: GridClassOptions): string
cardPadding(size?: Size | 'none'): string
progressHeight(size?: Size): string
progressColor(color?: ColorVariant): string
toastContainer(opts?: { position?: ToastPosition }): string
radioGroupLayout(direction?: 'horizontal' | 'vertical'): string
spacer(opts?: { size?: Size; horizontal?: boolean }): string
formError: string
formHint: string
cardHeader: string
cardTitle: string
cardDescription: string
cardContent: string
cardFooter: string
alertLeftAccent(opts?: { variant?: 'default' | 'info' | 'success' | 'warning' | 'error' }): string
accentCard(opts?: { tone?: AccentTone }): string
accentCardLabel(opts?: { tone?: AccentTone }): string
alertTitle: string
alertDescription: string
avatarImage: string
avatarFallback: string
dialogOverlay: string
dialogHeader: string
dialogFooter: string
dialogTitle: string
dialogDescription: string
dialogClose: string
dialogCloseFloating: string
dialogWrapper: string
dialogBody: string
actionSheet: string
actionSheetHeader: string
dropdownContent: string
dropdownItem: string
dropdownSeparator: string
dropdownLabel: string
table: string
tableHeader: string
tableBody: string
tableFooter: string
tableRow: string
tableHead: string
tableCell: string
tableCellWithCheckbox?: string
tableCaption: string
tooltipContent: string
toastViewport: string
toastTitle: string
toastDescription: string
toastClose: string
toastAction: string
accordionRoot: string
accordionItem: string
accordionContent: string
accordionContentInner: string
paginationRoot: string
paginationContent: string
paginationLink: string
paginationPrevious: string
paginationNext: string
paginationEllipsis: string
center: string
srOnly: string
notSrOnly: string
iconXs: string
iconSm: string
iconMd: string
buttonIconLeft: string
buttonIconRight: string
buttonSpinner: string
cardInteractive: string
alertIconWrapper: string
alertContent: string
alertDismiss: string
themeToggleButton: string
oauthDivider: string
oauthDividerLine: string
oauthDividerText: string
oauthButtonGroup: string
oauthButton: string
oauthButtonIcon: string
authFormError: string
forgotPasswordLink: string
floatingInputWrapper: string
floatingInput: string
floatingLabel: string
inputWrapper: string
inputInner: string
inputLeftElement: string
inputRightElement: string
inputClearButton: string
inputPadLeft: string
inputPadRight: string
selectNative: string
labelBlock: string
formFieldset: string
formFieldsetContents: string
formField: string
formFieldWrapper: string
controlLabel: string
controlContainer: string
controlText: string
controlDisabled: string
radioGroupLabel: string
accordionChevron: string
accordionTriggerBase: string
tabsFitted: string
tabTriggerFitted: string
tabTriggerIcon: string
paginationInteractive: string
progressWrapper: string
progressLabelContainer: string
progressLabelText: string
progressIndeterminate: string
typingPulse?: DotPulseMotion
tableWrapper: string
tableLoadingOverlay: string
tableEmptyCell: string
tableSortWrapper: string
tableSortIcon: string
tableRowStriped: string
tableRowHoverable: string
tableRowClickable: string
tableHeadSortable: string
tableBordered: string
toastIconWrapper: string
toastContentWrapper: string
dropdownTrigger: string
dropdownItemIcon: string
dropdownItemLabel: string
dropdownItemShortcut: string
dropdownItemDisabled: string
tooltipTrigger: string
avatarInitials: string
avatarFallbackIcon: string
avatarSquare: string
badgeSquare: string
skeletonTextContainer: string
skeletonCircle: string
skeletonWave: string
skeletonNone: string
textRight: string
page: string
surface: string
surfaceSecondary: string
headerBar: string
drawer: string
drawerLeft: string
textMuted: string
textSubtle: string
textPrimary: string
textOnPrimaryContainer: string
textSuccess: string
textWarning: string
textError: string
textTone(tone: ColorVariant): string
bgTone(tone: ColorVariant, opts?: { subtle?: boolean }): string
borderTone(tone: ColorVariant): string
textOnTone: string
bgScrim: string
borderB: string
borderT: string
borderR: string
borderL: string
borderAll: string
borderBPrimary: string
borderTPrimary: string
bgErrorSubtle: string
bgBorder: string
bgPrimarySubtle: string
bgPrimaryContainer: string
bgPrimary: string
bgWhite: string
italic: string
uppercase: string
trackingWide: string
gradientPrimary: string
shadowLifted: string
sectionHeading: string
formLabel: string
formLabelSmall: string
link: string
prose: string
dividerLine: string
overlay: string
footerBar: string
footerLink: string
footerButton: string
languageGrid: string
languageOption: string
languageActive: string
languagePickerTrigger: string
sp(property: SpacingProperty, scale: SpacingScale): string
sp(property: 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr', scale: SpacingScale | 'auto'): string
sp(overrides: SpacingOverrides): Record<string, string>
stack(scale: SpacingScale): string
textSize(size: TextScale): string
fontWeight(weight: FontWeightScale): string
textCenter: string
w(value: WidthValue | number): string
h(value: HeightValue | number): string
minH(value: HeightValue | number): string
minW(value: WidthValue | number): string
maxW(value: MaxWidthScale): string
shrink0: string
objectCover: string
textTruncate: string
pointerEventsAuto: string
touchTarget: string
touchTargetCompact: string
displayBlock: string
displayInlineBlock: string
displayContents: string
hiddenBelow(breakpoint: ResponsiveBreakpoint): string
hiddenFrom(breakpoint: ResponsiveBreakpoint): string
mxAuto: string
cursorPointer: string
roundedFull: string
gridRows(rows: number): string
position(value: 'relative' | 'absolute' | 'fixed' | 'sticky'): string
inset0: string
logoText: string
logoIcon: string
headerFixed: string
headerInner: string
authHeaderInner: string
authPageBody: string
authFormWrapper: string
authField: string
authAfterSubmit: string
authButtonRow: string
authBackButton: string
authSubmitButton: string
authLoginSignup: string
authLoginSubmit: string
authLoginSubmitFull: string
authHidden: string
authArrowIcon: string
// … truncated — 214 more members: appLayout, flex1, oauthProviderLabel, pageShell, pageShellSidebar, pageShellSidebarCollapsed, pageShellTopbar, pageShellContent, pageShellSidebarToggle, sidebarUserCardTrigger, userMenuPopoverTrigger, userMenuPopoverPanel, userMenuPopoverHeader, userMenuPopoverSignOut, emptyState, emptyStateIcon, emptyStateTitle, emptyStateDescription, emptyStateAction, pageHeader, pageHeaderTitle, pageHeaderDescription, pageHeaderActions, pageHeaderBreadcrumbs, pageHeaderBreadcrumbItem, pageHeaderBreadcrumbSeparator, searchField, searchFieldIcon, searchFieldInput, searchFieldActions, searchFieldClear, searchStatusRow, searchTips, kbd, filterChip, filterChipNegated, filterChipRemove, resultList, resultItem, resultItemActive, resultBody, resultTitle, resultTitleMono, resultMeta, resultDescription, resultMark, resultAction, resultEmpty, iconGlyphFont, authBrandHeaderChipSquare, authBrandHeaderChipShadow, authBrandHeaderChipIcon, authBrandHeaderWordmark, authBrandHeaderTagline, authShellContainer, authShellDecoration, authShellCardSurface, authShellCardOuter, authShellHeadingEyebrow, authShellHeadingTitle, authShellHeadingSub, authShellFooter, authShellBackLink, authShellBackLinkAnchor, authShellPanel, chatbotTesterBotBar, chatbotTesterBotSelect, chatbotTesterInputRow, chatbotTesterInputField, chatbotTesterMessageList, chatbotTesterMessageBubble, chatbotTesterMessageBubbleUser, chatbotTesterMessageBubbleBot, chatbotTesterMessageTimeUser, chatbotTesterMessageTimeBot and 139 more; the full declaration is in node_modules/@molecule/app-ui/dist/types.d.ts
(Member comments are left out to fit; the full declaration is in node_modules/@molecule/app-ui/dist/types.d.ts.)
Types
ElementMeasureTarget
Which part of a registered element to measure, in window coordinates.
type ElementMeasureTarget =
/** The element's own rendered frame on web and device. */
| 'frame'
/** The browser's first child element, falling back to the registered frame on either renderer. */
| 'content-start'
ElementZoomSample
An incremental zoom gesture in the element's outer frame (the SVG viewport for a group).
type ElementZoomSample =
| {
readonly kind: 'wheel'
readonly at: ElementZoomPoint
readonly deltaY: number
/** Wheel delta unit: 0 for pixels, 1 for lines, and 2 for pages. */
readonly deltaMode: 0 | 1 | 2
}
| {
readonly kind: 'pinch'
readonly from: ElementZoomPoint
readonly at: ElementZoomPoint
/** Current contact distance divided by the preceding distance. */
readonly factor: number
}
ElementLength
A length both renderers accept: pixels as a number, or a percentage of the parent.
type ElementLength = number | `${number}%`
WebStyle
An element's webStyle: CSS for the web (resets of browser defaults such as a button's border
and outline, cursors, shadows, or a consumer's style a kit component passes on). The web kit
applies it after style. The native kit applies only the keys TextStyle names whose
values a device can draw (width: 200, not width: '10rem'), so layout a feature means for
both renderers belongs in style, which the compiler holds to that subset.
type WebStyle = CSSProperties
ElementRole
Roles a feature gives an element (an explicit role overrides the one its as implies).
type ElementRole =
| 'alert'
| 'alertdialog'
| 'application'
| 'article'
| 'banner'
| 'blockquote'
| 'button'
| 'caption'
| 'cell'
| 'checkbox'
| 'code'
| 'columnheader'
| 'combobox'
| 'complementary'
| 'contentinfo'
| 'definition'
| 'deletion'
| 'dialog'
| 'directory'
| 'document'
| 'emphasis'
| 'feed'
| 'figure'
| 'form'
| 'generic'
| 'grid'
| 'gridcell'
| 'group'
| 'heading'
| 'img'
| 'insertion'
| 'link'
| 'list'
| 'listbox'
| 'listitem'
| 'log'
| 'main'
| 'marquee'
| 'math'
| 'menu'
| 'menubar'
| 'menuitem'
| 'menuitemcheckbox'
| 'menuitemradio'
| 'meter'
| 'navigation'
| 'none'
| 'note'
| 'option'
| 'paragraph'
| 'presentation'
| 'progressbar'
| 'radio'
| 'radiogroup'
| 'region'
| 'row'
| 'rowgroup'
| 'rowheader'
| 'scrollbar'
| 'search'
| 'searchbox'
| 'separator'
| 'slider'
| 'spinbutton'
| 'status'
| 'strong'
| 'subscript'
| 'superscript'
| 'switch'
| 'tab'
| 'table'
| 'tablist'
| 'tabpanel'
| 'term'
| 'textbox'
| 'time'
| 'timer'
| 'toolbar'
| 'tooltip'
| 'tree'
| 'treegrid'
| 'treeitem'
DataAttributes
data-* attributes: data-mol-id becomes the native testID; the rest are web-only.
type DataAttributes = { [key: `data-${string}`]: string | number | boolean | undefined }
AriaBoolean
A boolean ARIA value, as React DOM takes one: true/false, or the attribute's own spelling
'true'/'false' (aria-hidden="true"). A device reads 'false' as false.
type AriaBoolean = boolean | 'true' | 'false'
ForwardedElementProps
Pass-through props of each element variant after the component's own keys are removed.
type ForwardedElementProps<P, Owned extends PropertyKey = never> = P extends unknown
? Omit<P, 'as' | Owned>
: never
BoxTag
Web container tags and their native view counterparts, including paragraphs with controls.
type BoxTag =
| 'div'
| 'span'
| 'p'
| 'section'
| 'header'
| 'footer'
| 'main'
| 'aside'
| 'nav'
| 'article'
| 'ul'
| 'ol'
| 'li'
| 'dl'
| 'dd'
| 'figure'
| 'address'
InlineKind
How a component takes part in a line of a container that is not a flex container: inline text
(it renders a text element that joins the line), an inline box (a button, a badge, an icon:
it sits in the line beside text), or null for a block. The web reads this from CSS; React
Native has no inline layout, so the native kit is told (registerInline in each React kit).
type InlineKind = 'text' | 'box' | null
TextTag
Web tags a TextProps element renders.
type TextTag =
| 'div'
| 'span'
| 'p'
| 'h1'
| 'h2'
| 'h3'
| 'h4'
| 'h5'
| 'h6'
| 'strong'
| 'em'
| 'small'
| 'code'
| 'pre'
| 'kbd'
| 'mark'
| 'dt'
| 'dd'
| 'li'
| 'figcaption'
TextProps
Text (native Text); h1–h6 read as headings on native.
type TextProps<Node = unknown> =
| (TextCommonProps<Node> & { as: TextTag })
| (TextCommonProps<Node> & {
as: 'label'
/** The id of the control this label names and activates. */
htmlFor?: string
})
| (TextCommonProps<Node> & {
as: 'time'
/** The machine-readable date or time. */
dateTime?: string
})
PressableTag
Web tags a PressableProps element renders.
type PressableTag = 'button' | 'div' | 'span' | 'li'
AnchorProps
A literal anchor with no router. Web keeps the browsing context (target) and link
relationship (rel), which have no device equivalent. Both renderers call onClick before
the default action and honor preventDefault().
type AnchorProps<Node = unknown> = Omit<ElementLinkProps<Node>, 'to' | 'replace' | 'state'> & {
/**
* The literal `href` on the web. A device passes absolute URLs to the OS, resolves relative
* URLs against the app's configured public document URL, and stays on the current screen for
* `'#'`. A relative URL with no configured base reports a diagnostic on press.
*/
href: string
}
TextFieldProps
Web and native text fields accept bounds only on number and date inputs.
type TextFieldProps = TextFieldBaseProps &
(
| { min?: never; max?: never; step?: never }
| ({ as: 'input'; type: 'number' } & FieldBounds<number>)
| ({ as: 'input'; type: 'date' } & FieldBounds<string>)
)
SelectFieldProps
A single or multiple select with the same option and value contract on web and device.
type SelectFieldProps = SelectFieldCommonProps &
(
| ({
/** The browser select and the device list allow one selected option. */
multiple?: false
/** Reports the selected string on user edits in either renderer. */
onValueChange?: (value: string) => void
} & SelectFieldValue<string>)
| ({
/** The browser select and the device list allow multiple selected options. */
multiple: true
/** Reports every selected string in option order on a user edit in either renderer. */
onValueChange?: (values: readonly string[]) => void
} & SelectFieldValue<readonly string[]>)
)
FormEntryValue
A successful control's value, including files from a web form.
type FormEntryValue = string | Blob
FormEntries
A form's successful controls in order, with repeated names preserved.
type FormEntries = ReadonlyArray<readonly [name: string, value: FormEntryValue]>
CheckFieldProps
A checkbox, or a radio whose checked state is owned by its group.
type CheckFieldProps =
| (CheckFieldCommonProps & {
type: 'checkbox'
checked?: boolean
defaultChecked?: boolean
/** Draws the mixed state. */
indeterminate?: boolean
})
| (CheckFieldCommonProps & {
type: 'radio'
checked: boolean
defaultChecked?: never
indeterminate?: never
})
TableBoxTag
The table and row container tags.
type TableBoxTag = 'table' | 'thead' | 'tbody' | 'tfoot' | 'tr'
TableCellProps
A data cell or a header cell, with optional row or column scope on headers.
type TableCellProps<Node = unknown> =
| (TableCellCommonProps<Node> & { as: 'td'; scope?: never })
| (TableCellCommonProps<Node> & { as: 'th'; scope?: 'col' | 'row' })
OverlayDismissReason
Why the platform requested that an overlay close.
type OverlayDismissReason = 'escape' | 'back' | 'outside' | 'backdrop'
OverlayLayerKind
Modal layers block dismissal below them. Toast layers are passive.
type OverlayLayerKind = 'modal' | 'popover' | 'tooltip' | 'toast'
Children
Framework-agnostic child content.
Use unknown to allow any framework's node type (ReactNode, VNode, etc.).
type Children = unknown
EventHandler
Framework-agnostic event handler. An unannotated handler's event is E. It is declared as a
method (as React types its own handlers), so TypeScript compares its parameter both ways: a
handler written for the event a kit passes, such as (event: Event) => void on the Vue, Solid,
Svelte and Angular kits or (event: React.ChangeEvent<HTMLInputElement>) => void on React's,
is accepted too.
type EventHandler<E extends KitEvent = KitEvent> = {
handle(event: E): void
}['handle']
event— The event, as the kit hands it (seeKitEvent).
MouseEventHandler
Framework-agnostic mouse event handler.
type MouseEventHandler = EventHandler<KitMouseEvent>
KeyboardEventHandler
Framework-agnostic keyboard event handler.
type KeyboardEventHandler = EventHandler<KitKeyboardEvent>
FocusEventHandler
Framework-agnostic focus event handler.
type FocusEventHandler = EventHandler<KitFocusEvent>
ChangeEventHandler
Framework-agnostic change event handler.
type ChangeEventHandler = EventHandler<KitEvent>
FormEventHandler
Framework-agnostic form event handler.
type FormEventHandler = EventHandler<KitEvent>
Size
Standard size scale used across all molecule UI components (buttons, inputs, badges, etc.).
type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
ButtonSize
Button size variants (extends Size with 'icon' for square icon-only buttons).
type ButtonSize = Size | 'icon'
ColorVariant
Semantic color variants used across components for status indication.
type ColorVariant = 'primary' | 'secondary' | 'success' | 'warning' | 'error' | 'info'
ButtonVariant
Button visual variant styles.
type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'link'
InputType
Allowed HTML input type attribute values for the Input component.
type InputType =
| 'text'
| 'email'
| 'password'
| 'number'
| 'tel'
| 'url'
| 'search'
| 'date'
| 'time'
| 'datetime-local'
ModalSize
Modal size variants including full-screen.
type ModalSize = 'sm' | 'md' | 'lg' | 'xl' | 'full'
TooltipPlacement
Position where a tooltip renders relative to its trigger element (top, bottom, left, right, and corner variants).
type TooltipPlacement =
'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'
ClassMapValue
Class value types accepted by the UIClassMap cn() function.
Supports strings, booleans, arrays, and conditional objects.
type ClassMapValue =
| string
| number
| boolean
| undefined
| null
| ClassMapValue[]
| Record<string, boolean | undefined | null>
SpacingScale
Abstract spacing scale. Each styling library maps these to its own units. For Tailwind: 0 → 0, 1 → 0.25rem, 4 → 1rem, 8 → 2rem, etc.
type SpacingScale = 0 | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 4 | 5 | 6 | 8 | 10 | 12 | 16 | 20 | 24
TailwindArbitraryBracket
Tailwind arbitrary value in bracket notation (e.g. [440px], [65%]).
type TailwindArbitraryBracket = `[${string}]`
SpacingProperty
CSS spacing property shorthand (padding/margin with direction).
type SpacingProperty =
'p' | 'px' | 'py' | 'pt' | 'pb' | 'pl' | 'pr' | 'm' | 'mx' | 'my' | 'mt' | 'mb' | 'ml' | 'mr'
SpacingOverrides
Compound spacing specification for conflict-free overrides.
Pass to sp() to get a style object (for use on the style prop).
More specific properties override less specific ones:
pr overrides px overrides p (same cascade as CSS shorthand).
Returns Record<string, string> so it is compatible with any framework's
inline style API without requiring a React-specific import.
type SpacingOverrides = Partial<Record<SpacingProperty, SpacingScale>>
ResponsiveBreakpoint
Viewport breakpoints for responsive visibility (hiddenBelow/hiddenFrom):
sm ≈ 640px, md ≈ 768px, lg ≈ 1024px, xl ≈ 1280px (each ClassMap
bond maps them to its own breakpoints).
type ResponsiveBreakpoint = 'sm' | 'md' | 'lg' | 'xl'
TextScale
Text size scale from extra-small to 4xl.
type TextScale = 'xs' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl'
FontWeightScale
Font weight scale.
type FontWeightScale = 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold'
MaxWidthScale
Max-width scale for constraining content.
type MaxWidthScale =
| 'none'
| 'xs'
| 'sm'
| 'md'
| 'lg'
| 'xl'
| '2xl'
| '3xl'
| '4xl'
| '5xl'
| '6xl'
| '7xl'
| 'full'
| 'screen-2xl'
| TailwindArbitraryBracket
WidthValue
Width value — fractional, keyword, or numeric (mapped to spacing scale).
type WidthValue =
| 'full'
| '1/2'
| '1/3'
| '2/3'
| '1/4'
| '3/4'
| 'auto'
| 'screen'
| 'fit'
| TailwindArbitraryBracket
HeightValue
Height value — fractional, keyword, or numeric (mapped to spacing scale).
type HeightValue =
'full' | 'screen' | 'auto' | '1/2' | '1/3' | '2/3' | '1/4' | '3/4' | TailwindArbitraryBracket
ToastPosition
Toast position values for screen placement.
type ToastPosition = 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left'
AccentTone
Tones of an accent bar: the semantic colors, the brand primary, or custom (the --mol-accent variable).
type AccentTone = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'error' | 'custom'
ClassMapOverrides
Overrides for extending a UIClassMap.
Can be a partial map of token replacements, or a function that receives the base ClassMap and returns overrides (useful for extending resolver functions while preserving the base behavior).
type ClassMapOverrides = Partial<UIClassMap> | ((base: UIClassMap) => Partial<UIClassMap>)
Classes
ToastCountdown
Auto-dismisses once, pausing independently for hover and focus.
class ToastCountdown {
private readonly pauses = new Set<'hover' | 'focus'>()
private duration = 0
private remaining = 0
private startedAt?: number
private timer?: ReturnType<typeof setTimeout>
private dismissed = false
constructor(private readonly onDismiss: () => void) {}
/** Sets the duration on mount or when it changes. Zero stays open until dismissed. */
start(duration: number): void {
this.stop()
this.duration = duration
this.remaining = duration
this.resume()
}
/** Suspends the countdown until every active reason for pausing has left. */
setPaused(reason: 'hover' | 'focus', paused: boolean): void {
if (paused) {
this.pauses.add(reason)
if (this.startedAt !== undefined) {
this.remaining = Math.max(0, this.remaining - (Date.now() - this.startedAt))
this.stop()
}
} else if (this.pauses.delete(reason)) {
this.resume()
}
}
/** Hides the notification once, whether a timer or a control dismissed it. */
readonly dismiss = (): void => {
if (this.dismissed) return
this.dismissed = true
this.stop()
this.onDismiss()
}
/** Cancels the timer during unmount or before restarting it. */
readonly stop = (): void => {
clearTimeout(this.timer)
this.timer = undefined
this.startedAt = undefined
}
/** Schedules the remaining time once a visible toast has no active pause. */
private resume(): void {
if (this.duration <= 0 || this.dismissed || this.pauses.size > 0 || this.timer !== undefined)
return
this.startedAt = Date.now()
this.timer = setTimeout(this.dismiss, this.remaining)
}
}
Functions
molId(component, context, qualifier)
Generate a semantic automation ID for a component.
function molId(component: string, context: string, qualifier?: string): string
component— Component type (e.g., 'button', 'input', 'card')context— Context within the page (e.g., 'login', 'product', 'settings')qualifier— Optional qualifier (e.g., 'submit', 'cancel', item ID)
Returns: The joined automation ID string.
molIdProps(id)
Generate the props object for spreading onto an element.
function molIdProps(id: string): Record<string, string>
id— The automation ID string.
Returns: An object with the data-mol-id attribute set.
molSelector(id)
Playwright/testing selector for finding elements by automation ID.
function molSelector(id: string): string
id— The automation ID to find.
Returns: A CSS attribute selector string.
molSelectorPrefix(prefix)
Playwright/testing selector for finding elements by partial automation ID. Useful for finding all elements of a type: molSelectorPrefix('button-login')
function molSelectorPrefix(prefix: string): string
prefix— The automation ID prefix to match.
Returns: A CSS attribute prefix selector string.
isFieldChangeEvent(event)
Narrows a raw event delivered directly by a text or select field.
function isFieldChangeEvent(event: KitEvent): event is KitFieldChangeEvent
event— The event received by the field's listener.
Returns: Whether both targets are the field and expose its string value.
fieldLayout(cm)
The classes for the two wrappers a closed form control (Input, Select, Textarea) puts
around its native element.
Both wrappers are flex columns. On the web, a control's top and bottom margins collapse through a block wrapper: the wrapper's neighbours move instead of the control, and a label above the control changes where the control's margin shows up. React Native keeps the margins inside. A column keeps them inside on every renderer, so a field sits at the same place in a browser and on a device.
rootgoes on the outer wrapper: the field's full-width column, which holds the label, the control's row and the error or hint line.innergoes on the row that holds the control and its adornments (a leading icon, a clear button), which the row positions.Textareahas no adornments and usesrootalone.
A caller's className, style, ref and test id stay on the control itself. Moving them to a
wrapper would move the caller's border, focus ring and typography with them. A wrapper that
takes arbitrary children (FormField) keeps the plain inputWrapper token.
function fieldLayout(cm: UIClassMap): { root: string; inner: string }
cm— The ClassMap the control renders with.
Returns: root, the outer wrapper's classes, and inner, the control row's classes.
calculateOverlayPosition(anchor, surface, viewport, geometry)
Positions an anchored surface. All inputs use the same coordinate space. When flipping is enabled, the less obstructed side wins and ties keep the requested side.
function calculateOverlayPosition(
anchor: ElementBox,
surface: Pick<ElementBox, 'width' | 'height'>,
viewport: ElementBox,
{ placement, align, offset, padding, collision }: OverlayAnchorGeometry,
): OverlayPosition
anchor— Bounds of the reference element.surface— Dimensions of the surface to position.viewport— Available bounds before applying padding.geometry— Placement, gap, padding and collision policy.
Returns: Coordinates in the input space and the resolved placement.
setProvider(provider)
Registers a UI provider as the active singleton.
function setProvider(provider: UIProvider): void
provider— The UI provider implementation to bond.
getProvider()
Retrieves the bonded UI provider, or undefined if none is configured.
function getProvider(): UIProvider | undefined
Returns: The bonded UI provider, or undefined.
hasProvider()
Checks whether a UI provider is currently bonded.
function hasProvider(): boolean
Returns: true if a UI provider is bonded.
setClassMap(classMap)
Registers a UIClassMap as the active styling resolver. Called at app startup to wire a styling library (e.g. Tailwind, Bootstrap).
function setClassMap(classMap: UIClassMap): void
classMap— The UIClassMap implementation to bond.
getClassMap()
Retrieves the bonded UIClassMap, throwing if none is configured. Use this to resolve styling-agnostic class names in components.
function getClassMap(): UIClassMap
Returns: The bonded UIClassMap implementation.
hasClassMap()
Checks whether a UIClassMap is currently bonded.
function hasClassMap(): boolean
Returns: true if a UIClassMap is bonded.
moleculeSpinnerMarkSvg(options)
The molecule spinner mark as a complete SVG element string (SMIL-animated, framework-agnostic). See the module docblock for usage and gotchas.
function moleculeSpinnerMarkSvg(options?: MoleculeSpinnerMarkOptions): string
options— Paint, timings, size, gradient id and a11y shape.
Returns: A <svg>…</svg> markup string.
extendClassMap(base, overrides)
Creates a new UIClassMap by extending a base ClassMap with overrides.
Overrides can be a plain object (for replacing specific tokens/resolvers) or a function that receives the base map (for extending resolvers while preserving base behavior).
function extendClassMap(base: UIClassMap, overrides: ClassMapOverrides): UIClassMap
base— The base UIClassMap to extendoverrides— Token overrides (object or function returning object)
Returns: A new UIClassMap with overrides applied
Constants
MOL_ID_ATTR
The HTML attribute name for automation IDs.
const MOL_ID_ATTR: 'data-mol-id'
DEFAULT_TYPING_PULSE
The motion both renderers use when the ClassMap omits its typing pulse.
const DEFAULT_TYPING_PULSE: DotPulseMotion
Available Providers
| Provider | Package |
|---|---|
| Angular UI | @molecule/app-ui-angular |
| NativeWind | @molecule/app-ui-nativewind |
| React UI | @molecule/app-ui-react |
| React Native UI | @molecule/app-ui-react-native |
| Solid UI | @molecule/app-ui-solid |
| Svelte UI | @molecule/app-ui-svelte |
| Tailwind UI | @molecule/app-ui-tailwind |
| Tailwind Glass | @molecule/app-ui-tailwind-glass |
| Vue UI | @molecule/app-ui-vue |
Injection Notes
Requirements
Peer dependencies:
@molecule/app-bond^1.0.1@molecule/app-filesystem^1.1.0@molecule/app-i18n^1.0.1
Runtime Dependencies
@molecule/app-bond@molecule/app-filesystem@molecule/app-i18n
Style through getClassMap — NEVER write raw CSS/Tailwind class names in a
component. const cm = getClassMap() returns the resolver; use its helpers (cm.flex,
cm.surface, cm.textSize(size), the component helpers like cm.button/cm.card, and
cm.cn(...) to compose) and pass the result to className. Class-name STRINGS live only in
the ClassMap bond (@molecule/app-ui-tailwind), so swapping the styling library touches
only the bond — a literal "flex p-4" in a component defeats that and is the #1 styling
mistake.
A stylesheet the request supplies (a theme CSS, a CSS framework, a design export with its
own class names) is used by those class names written directly in className — ClassMap
governs molecule's own utilities, not a supplied stylesheet's contract; never wrap,
re-generate or rename its classes.
- Read a field's text with
onChange={(e) => setVal(e.target.value)}. Input, Textarea and Select expose a string value. UseonValueChange={setVal}to receive the value directly. To annotate a shared handler, importKitFieldChangeEventfrom@molecule/app-ui. Buttondefaults totype="button". A form's primary action needstype="submit", or Enter does nothing and tests that selectbutton[type="submit"]miss it (X1 RealWorld runs failed 15 browser tests on one Settings button).- Inline styles must not fight ClassMap. An inline
stylehas higher specificity and SILENTLY overrides the class controlling the same property (e.g.style={{ background }}killscm.surface). Use inline only for what ClassMap can't express (a specific pixel width, an SVG attribute, a one-off accent color). - Check what a class resolves to before using it — read the bond definition, don't guess
a helper name or option value; an invalid
cm.*value is a type error or a silent no-op. - Every interactive element needs a stable
data-mol-id— spreadmolIdProps(or setMOL_ID_ATTRviamolId) so AI agents and tests can target it. tabsList/tabsTrigger/tabsContentare resolver functions, not static strings — callcm.tabsList(opts)/cm.tabsTrigger(opts)/cm.tabsContent(opts)with an optionalTabsClassOptions(variant/size). Active-tab styling stays adata-stateattribute selector the caller sets, not one of these options.cm.switchBase(opts)also accepts acolor(SwitchClassOptions) alongsidesize.
Translations
Translation strings are provided by @molecule/app-locales-ui.