Mixins / Authoring components
Common pitfalls when authoring components
- State rule beaten by a variant: A rule in
variantsoverridescomponents; put state styles (aria-selected) inside each variant that sets the same property. - Shorthand resetting a longhand: Writing
backgroundin a hover rule clearsbackground-clipfrom the base; use matching longhands across base and states. - Two Mounts on one element: Foldkit keeps one
OnMountper element; pass mounts through Slots so the resolver composes them, or place a custom mount on its own element. - Mount reading stale inputs: Mounts run on element creation and removal; use a
Commandor key the element when an effect depends on changingModelfields. - Rapid keypresses outrunning frames: Carry needed context in
Messageor readdocument.activeElementat press time, and callFrames.track().settle()in tests. - Markup outside Slots: Bare elements cannot be styled or checked from outside; render through Slots with CSS custom properties or data attributes for structural hints.
- No-op returning
{ ...model }: Returning a fresh object triggers unnecessary renders; return the exactmodelreference on no-ops. - Native
disabledvs.aria-disabled: Nativedisableddrops focus and Enter submission; usearia-disabledon buttons and enforce disabled checks inupdate. - Two Slots on one element: Placing two
slots.*.attrs(...)calls on one element overwritesClass; give each Slot its own element.
Next
- Learn how Slots, Styles, and Behaviors compose in Inside-out view composition.
- Explore working examples of custom assemblies in
examples/authoring. - Browse the APIs in
foldkit-mixins,foldkit-primitives,foldkit-mixins-ui, andfoldkit-bundle.