Skip to content

Atoms

Atoms are single-responsibility Angular host directives. Each atom manages exactly one concern — identity, hover state, or anchor positioning. They attach to any element and compose freely thanks to Angular 22's host directive de-duplication.

Available Atoms

AtomPackageDescription
AtomId@terse-ui/atomsGenerates and applies a unique id attribute
AtomHover@terse-ui/atoms/hoverTracks pointer hover state with data-hover attribute
AtomAnchor@terse-ui/atoms/anchorSets CSS anchor-name for anchor positioning
AtomAnchored@terse-ui/atoms/anchorPositions an element relative to an anchor
AtomOpenClose@terse-ui/atoms/open-closeManages data-open / data-closed and aria-expanded for toggleable elements
AtomOrientation@terse-ui/atoms/orientationSets data-orientation and aria-orientation for directional layouts
AtomDisabled@terse-ui/atoms/disabledUnified disabled state with data-disabled and aria-disabled
AtomEscapeKey@terse-ui/atoms/escape-keyListens for Escape key and emits a dismissal event
AtomClickOutside@terse-ui/atoms/click-outsideDetects pointer events outside the host element
AtomIntersect@terse-ui/atoms/intersectWraps IntersectionObserver with signals and data attributes
AtomClass@terse-ui/atoms/classesComposable class merging from multiple sources with pluggable reducer

How Atoms Compose

Atoms are designed to be used as hostDirectives in higher-level components and directives:

ts
@Directive({
  selector: '[myTooltipTrigger]',
  hostDirectives: [AtomId, AtomHover, AtomAnchor],
})
export class MyTooltipTrigger { }

Angular de-duplicates host directives automatically. If multiple parents include the same atom, only one instance is created per host element. This is what makes atomic composition practical — atoms stack without conflict.

Atoms can also be used standalone on any element:

html
<div atomId atomHover>...</div>

See Why Terse UI? for the full story on how host directive de-duplication enables this architecture.

Released under the MIT License.