COMPONENT REFERENCEVisual control

Chip

A selectable pill that can also be dismissed.

kind: chipJavaScript + C#Implemented

What it does

A selectable pill that can also be dismissed.

This is a visual component. Drag it from Toolbox, or double-click to insert it.

Set it up

  1. Add Chip from Toolbox.
  2. Set its Name to sample for the examples below. Names are case-sensitive.
  3. Configure the component-specific properties below.
  4. Open the Events inspector to add a handler: methods go in event.js, imports and subscriptions in script.js. Right-click View Events or View Script to edit either file. Use View CSS for scoped styles and View Custom Properties for JSON values.
  5. Save sources, save the project, and open a fresh Preview. Scripts execute in Preview.

JavaScript example

These examples use supported inline subscriptions for brevity. The Events inspector can generate separate class methods in event.js instead.

Set removable to true to allow dismissal. chip-remove reports dismissal. Set isRemoved to false to restore it in the current Preview.

const checked = forma.bind("sample", "checked");
checked.subscribe(value => console.log("Checked:", value));
forma.on("Load", () => forma.set("sample", "checked", true));

Component properties

FieldInspector keyEditorAccepted values / rangeRuntime key
Variantvariantselectneutral, info, success, warning, dangervariant
Removableremovablecheckbox—removable
Checkedcheckedcheckbox—checked

Runtime property API

Use forma.get("sample", key), forma.set("sample", key, value), or forma.bind("sample", key). Read a binding with .value; write only when the Binding column permits it. Numbers and booleans must keep their types. Arrays are passed directly, not as JSON strings.

KeyValue typegetsetBindingMeaning / restrictions
textstringYesYesRead/writeDisplay text; use value to read live text input.
enabledbooleanYesYesRead/writeEnabled
visiblebooleanYesYesRead/writeVisible
tagstringYesYesRead/writeTag
xnumberYesYesRead/writeParent-content X coordinate. Writes are rejected for managed/docked children.
ynumberYesYesRead/writeParent-content Y coordinate. Writes are rejected for managed/docked children.
widthnumberYesYesRead/writeConfigured model width; managed layouts/custom CSS can change rendered size.
heightnumberYesYesRead/writeConfigured model height; managed layouts/custom CSS can change rendered size.
minimumWidthnumberYesYesRead/writeRange 0–1600. Invalid types are rejected; numeric values clamp.
minimumHeightnumberYesYesRead/writeRange 0–1200. Invalid types are rejected; numeric values clamp.
maximumWidthnumberYesYesRead/writeRange 0–1600. Invalid types are rejected; numeric values clamp.
maximumHeightnumberYesYesRead/writeRange 0–1200. Invalid types are rejected; numeric values clamp.
backColorstringYesYesRead/writeBackground
foreColorstringYesYesRead/writeForeground
borderStyle"none" | "solid" | "dashed" | "dotted"YesYesRead/writeBorder style
borderColorstringYesYesRead/writeBorder color
borderWidthnumberYesYesRead/writeRange 0–10. Invalid types are rejected; numeric values clamp.
borderSides"all" | "none" | "top" | "bottom" | "left" | "right" | "top,bottom" | "left,right" | "top,left,right" | "bottom,left,right"YesYesRead/writeBorder sides
borderRadiusnumberYesYesRead/writeRange 0–100. Invalid types are rejected; numeric values clamp.
opacitynumberYesYesRead/writeRange 10–100. Invalid types are rejected; numeric values clamp.
shadow"None" | "Small" | "Medium" | "Large"YesYesRead/writeShadow
cursor"default" | "pointer" | "text" | "crosshair" | "help" | "not-allowed"YesYesRead/writeCursor
fontFamily"Segoe UI" | "Arial" | "Consolas" | "Georgia"YesYesRead/writeFont family
fontSizenumberYesYesRead/writeRange 8–48. Invalid types are rejected; numeric values clamp.
fontWeight"normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"YesYesRead/writeWeight
fontStyle"normal" | "italic"YesYesRead/writeFont style
textAlign"left" | "center" | "right"YesYesRead/writeAlignment
lineHeightnumberYesYesRead/writeRange 0.5–4. Invalid types are rejected; numeric values clamp.
letterSpacingnumberYesYesRead/writeRange -5–20. Invalid types are rejected; numeric values clamp.
marginTopnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
marginRightnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
marginBottomnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
marginLeftnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
paddingTopnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
paddingRightnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
paddingBottomnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
paddingLeftnumberYesYesRead/writeRange 0–64. Invalid types are rejected; numeric values clamp.
focusablebooleanYesYesRead/writeFocusable
tabIndexnumberYesYesRead/writeRange 0–32767. Invalid types are rejected; numeric values clamp.
toolTipstringYesYesRead/writeTooltip
cssClassstringYesYesRead/writeCSS class
layoutSlotnumberYesYesRead/writeOne-based parent pane, page, or table cell.
dock"none" | "top" | "bottom" | "left" | "right" | "fill"YesYesRead/writeParent-managed edge/fill layout. Takes priority over Anchor.
anchor"none" | "top,left" | "top,right" | "bottom,left" | "bottom,right" | "top,left,right" | "bottom,left,right" | "top,bottom,left" | "top,bottom,right" | "top,bottom,left,right" | "top" | "bottom" | "left" | "right" | "top,bottom" | "left,right"YesYesRead/writeComma-separated edges; opposite edges stretch. Use exact option strings.
checkedbooleanYesYesRead/writeChecked
variant"neutral" | "info" | "success" | "warning" | "danger"YesYesRead/writeVariant
removablebooleanYesYesRead/writeRemovable
isRemovedbooleanYesYesRead/writeSupported runtime property.

Set commands cross the native bridge asynchronously. An immediate get after set may return the previous value. Observe a binding or use the assigned value locally. Getter arrays are copies. Geometry is configured model geometry; layout and CSS may override rendered bounds.

Shared inspector fields

FieldInspector keyEditorAccepted values / rangeRuntime key
Namenametext—Designer only
ID (read-only)idtext—Designer only
Text / Titletexttext—text
Tagtagtext—tag
Lockedlockedcheckbox—Designer only
BackgroundbackColorcolor—backColor
ForegroundforeColorcolor—foreColor
Border styleborderStyleselectnone, solid, dashed, dottedborderStyle
Border colorborderColorcolor—borderColor
Border widthborderWidthnumber0–10borderWidth
Border sidesborderSidesselectall, none, top, bottom, left, right, top,bottom, left,right, top,left,right, bottom,left,rightborderSides
RadiusborderRadiusnumber0–100borderRadius
Opacity (%)opacitynumber10–100opacity
ShadowshadowselectNone, Small, Medium, Largeshadow
Cursorcursorselectdefault, pointer, text, crosshair, help, not-allowedcursor
Font familyfontFamilyselectSegoe UI, Arial, Consolas, GeorgiafontFamily
Font sizefontSizenumber8–48fontSize
WeightfontWeightselectnormal, bold, 100, 200, 300, 400, 500, 600, 700, 800, 900fontWeight
Font stylefontStyleselectnormal, italicfontStyle
AlignmenttextAlignselectleft, center, righttextAlign
Line heightlineHeightnumber0.5–4lineHeight
Letter spacingletterSpacingnumber-5–20letterSpacing
Xxnumber0–1600x
Yynumber0–1200y
Widthwidthnumber24–1600width
Heightheightnumber20–1200height
Min widthminimumWidthnumber0–1600minimumWidth
Min heightminimumHeightnumber0–1200minimumHeight
Max width (0=auto)maximumWidthnumber0–1600maximumWidth
Max height (0=auto)maximumHeightnumber0–1200maximumHeight
Margin topmarginTopnumber0–64marginTop
Margin rightmarginRightnumber0–64marginRight
Margin bottommarginBottomnumber0–64marginBottom
Margin leftmarginLeftnumber0–64marginLeft
Padding toppaddingTopnumber0–64paddingTop
Padding rightpaddingRightnumber0–64paddingRight
Padding bottompaddingBottomnumber0–64paddingBottom
Padding leftpaddingLeftnumber0–64paddingLeft
Enabledenabledcheckbox—enabled
Visiblevisiblecheckbox—visible
Focusablefocusablecheckbox—focusable
Tab indextabIndexnumber0–32767tabIndex
TooltiptoolTiptext—toolTip
CSS classcssClasstext—cssClass
Pane / tab / celllayoutSlotnumber1–100layoutSlot
Dockdockselectnone, top, bottom, left, right, filldock
Anchoranchorselectnone, top,left, top,right, bottom,left, bottom,right, top,left,right, bottom,left,right, top,bottom,left, top,bottom,right, top,bottom,left,right, top, bottom, left, right, top,bottom, left,rightanchor

Events and lifecycle

Component hooks: chip-remove.

Only applicable browser events fire: a control without text input will not produce native input events just because a handler is registered. Event names are case-insensitive. Put handlers on the component producing the event; a Timer Tick handler belongs to the Timer, or can be observed through forma.root.on("Tick", handler). See the event guide for payloads, validation, cleanup, and startup order.

Property-change payload

All components can report PropertyChanged for changed projected runtime properties. Handlers expose source/subscriber component handles; native DOM targets remain available. Input/Change can supply typed property values, while Click normally supplies identity without a property/value pair.

forma.on("PropertyChanged", ({ source, property, value, previousValue, origin }) => {
  console.log(source.name, property, previousValue, "→", value, origin);
});

Use forma.root.on(...) to observe the active form, and event.toJSON() for portable logs. Subscriptions return unsubscribe and are cleaned up with the subscribing script.

C# example

Use this in a configured Forma C# host, not in script.js. The renderer is your host's WebView2Renderer instance.

var sample = new Forma.Core.Controls.Chip
{
    Name = "sample"
};
await renderer.RenderAsync(sample);

C# model reference

These are Core constructor defaults, not necessarily the Builder’s drop-time styles or size. Appearance fields belong to Builder Appearance. C# events are not all forwarded to JavaScript.

PropertyC# typeConstructor defaultWritable
RemovableBooleanfalseYes
IsRemovedBooleanfalseNo
VariantString"neutral"Yes
CheckedBooleanfalseYes
NameStringnullYes
LayoutSlotInt321Yes
XNullable1`nullYes
YNullable1`nullYes
TextString"Chip"Yes
ValueStringnullYes
PlaceholderStringnullYes
LabelStringnullYes
ControlTypeString"chip"No

Core methods: Remove(), Restore(), GetRenderState(), HandleRuntimeEvent(runtimeEvent), Add(child), Insert(index, child), MoveChild(child, index), Remove(child).

Core events: Removed, CheckedChanged, ChildAdded, ChildRemoved, PropertyChanged.

Additional behavior notes

Inherits CheckBox. Checked defaults false, Removable false, Variant neutral. Supports neutral/info/success/warning/danger. IsRemoved is transient and omitted from saved projects. Remove() requires Removable and raises Removed once; Restore() clears removal. JS get/set/bind supports checked, variant, removable, isRemoved. Inspector exposes Checked, Variant, and Removable.

Search components, properties, and guides.

↑↓ navigate Enter open Esc close