CodeBlock
Selectable, caret-free source code with Tree-sitter coloring and virtualized logical rows.
No language grammars are included by default. Register a linked grammar in Rust, or load one portable pack of selected Tree-sitter Wasm grammars and queries using loadLanguagePack (TypeScript) / LoadLanguagePack (Go).
Unstyled by default: text and line-number colors inherit, and the component adds no background, border, rounding, padding, or syntax/diff palette. Supply application styles and explicit colors to opt into an appearance.
#Import
bun add @quickgui/extension-editorimport { CodeBlock } from "@quickgui/extension-editor";// quickgui.config.ts
extensions: ["@quickgui/extension-editor"]#Usage
<CodeBlock
value={"export function answer(): number { return 42; }\n"}
language="typescript"
lineNumbers
wrap={false}
style={{ width: "100%", height: 280 }}
/>#Syntax highlighting
language selects a registered Tree-sitter grammar and highlight query. Captures map through syntaxTheme to foreground-only spans, so highlighting does not change layout. The Rust core parses when source or language changes; scrolling only mounts logical rows and materializes their precomputed spans. Parsing is limited to 2 MiB, individual lines over 32 KiB stay plain, and the capture count is capped.
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
CodeBlock
View sourceCodeBlock(props: CodeBlockProps): NativeNodeaccessibilityLabelstring—
Declares accessibilityLabel (optional). Reactive JSX expressions update this property in place.
stringView sourcestyleStyleProp—
Layout, typography, paint, and interaction-state styles. Arrays merge left to right.
StylePropView sourcedisabledboolean—
Declares disabled (optional). Reactive JSX expressions update this property in place.
booleanView sourceinvalidboolean—
Expose web-style invalid state; the `style.invalid` variant paints while it is set.
booleanView sourceselectedboolean—
Expose web-style selected state; the `style.selected` variant paints while it is set.
booleanView sourcegroupboolean | string—
Makes this element the group its descendants' `groupHover` and `groupActive` styles follow, like Tailwind's `group`: `true` opens an unnamed group, and a string names it so a descendant can follow it past a nearer group with `groupHover: { group: "name" }`.
boolean | stringView sourcerolestring—
tabIndexnumber—
Declares tabIndex (optional). Reactive JSX expressions update this property in place.
numberView sourcefocusOnPointerboolean—
overlayboolean—
focusTrapboolean—
restorePreviousFocusboolean—
autoFocusboolean—
aria-modalboolean—
ariaModalboolean—
Declares ariaModal (optional). Reactive JSX expressions update this property in place.
booleanView sourcedismissOnEscapeboolean—
Declares dismissOnEscape (optional). Reactive JSX expressions update this property in place.
booleanView sourcedismissOnPointerOutsideboolean—
Declares dismissOnPointerOutside (optional). Reactive JSX expressions update this property in place.
booleanView sourcetooltipstring—
tooltipPlacementPopoverPlacement—
Declares tooltipPlacement (optional). Reactive JSX expressions update this property in place.
PopoverPlacementView sourcetooltipDelaynumber—
tooltipGapnumber—
Declares tooltipGap (optional). Reactive JSX expressions update this property in place.
numberView sourcetooltipViewportMarginnumber—
Declares tooltipViewportMargin (optional). Reactive JSX expressions update this property in place.
numberView sourcehitSlopnumber | string—
Declares hitSlop (optional). Reactive JSX expressions update this property in place.
number | stringView sourcehitSlopTopnumber | string—
Declares hitSlopTop (optional). Reactive JSX expressions update this property in place.
number | stringView sourcehitSlopRightnumber | string—
Declares hitSlopRight (optional). Reactive JSX expressions update this property in place.
number | stringView sourcehitSlopBottomnumber | string—
Declares hitSlopBottom (optional). Reactive JSX expressions update this property in place.
number | stringView sourcehitSlopLeftnumber | string—
Declares hitSlopLeft (optional). Reactive JSX expressions update this property in place.
number | stringView sourcearia-labelstring—
Declares aria-label (optional). Reactive JSX expressions update this property in place.
stringView sourceariaLabelstring—
Declares ariaLabel (optional). Reactive JSX expressions update this property in place.
stringView sourceref((node: NativeNode) => void) | NativeNode—
Declares ref (optional). Reactive JSX expressions update this property in place.
((node: NativeNode) => void) | NativeNodeView sourceonClickEventHandler—
Declares onClick (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonMouseEnterEventHandler—
Declares onMouseEnter (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonMouseLeaveEventHandler—
Declares onMouseLeave (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonPointerEnterEventHandler—
Declares onPointerEnter (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonPointerLeaveEventHandler—
Declares onPointerLeave (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonPointerEventHandler—
Captured pointer stream from press through release/cancel, including outside the element.
EventHandlerView sourceonInputEventHandler—
Declares onInput (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonChangeEventHandler—
Declares onChange (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonSubmitEventHandler—
Declares onSubmit (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonDismissEventHandler—
Declares onDismiss (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonKeyDownEventHandler—
Focused key press. Declare a `tabIndex` to make an ordinary container focusable.
EventHandlerView sourceonKeyUpEventHandler—
Declares onKeyUp (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonMouseDownEventHandler—
Declares onMouseDown (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonMouseUpEventHandler—
Declares onMouseUp (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonMouseMoveEventHandler—
Declares onMouseMove (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonDoubleClickEventHandler—
onWheelEventHandler—
Declares onWheel (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonContextMenuEventHandler—
onPinchEventHandler—
Declares onPinch (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonRotateEventHandler—
Declares onRotate (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonSmartMagnifyEventHandler—
Declares onSmartMagnify (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonPressureEventHandler—
Declares onPressure (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonFocusEventHandler—
Declares onFocus (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonBlurEventHandler—
Declares onBlur (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourcekeymapKeymap—
onActionEventHandler—
draggableboolean | DragSource—
onDragStartEventHandler—
Declares onDragStart (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonDragEndEventHandler—
Declares onDragEnd (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourcedropKindsDropKind | readonly DropKind[]—
Payload kinds this element accepts, declared ahead of the native drag.
DropKind | readonly DropKind[]View sourceonDropEventHandler—
Declares onDrop (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourceonFilesDroppedEventHandler—
Declares onFilesDropped (optional). Reactive JSX expressions update this property in place.
EventHandlerView sourcevaluestring—
languageEditorLanguage—
Declares language (optional). Reactive JSX expressions update this property in place.
EditorLanguageView sourcelineNumbersboolean—
Declares lineNumbers (optional). Reactive JSX expressions update this property in place.
booleanView sourcewrapboolean—
contentPaddingContentPadding—
Declares contentPadding (optional). Reactive JSX expressions update this property in place.
ContentPaddingView sourcegutterPaddingGutterPadding—
Declares gutterPadding (optional). Reactive JSX expressions update this property in place.
GutterPaddingView sourcegutterBackgroundColorValue—
Declares gutterBackground (optional). Reactive JSX expressions update this property in place.
ColorValueView sourcegutterColorColorValue—
Declares gutterColor (optional). Reactive JSX expressions update this property in place.
ColorValueView sourcesyntaxThemeSyntaxTheme—
Declares syntaxTheme (optional). Reactive JSX expressions update this property in place.
SyntaxThemeView source