@molecule/app-section-divider-angular
Feature · section-divider · App (browser) · v1.1.2 · Apache-2.0
Centered-label section divider ("OR", "Today") with flanking lines
npm install @molecule/app-section-divider-angularHow it works
@molecule/app-section-divider-angular is a ready-made section-divider feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { Component } from '@angular/core'
import { SectionDivider } from '@molecule/app-section-divider-angular'
@Component({
selector: 'app-example',
standalone: true,
imports: [SectionDivider],
template: `
<div mol-section-divider>OR</div>
<div mol-section-divider [align]="'start'">Today</div>
`,
})
export class Example {}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular horizontal divider with optional centered label — the counterpart
of @molecule/app-section-divider-react: the same props and the same DOM
for the same input.
Exports SectionDivider, common as "OR" between auth options, "Today"
between feed days, "—" between sections. The label is projected content —
translate it upstream.
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 { Component } from '@angular/core'
import { SectionDivider } from '@molecule/app-section-divider-angular'
@Component({
selector: 'app-example',
standalone: true,
imports: [SectionDivider],
template: `
<div mol-section-divider>OR</div>
<div mol-section-divider [align]="'start'">Today</div>
`,
})
export class Example {}
Type
feature
Installation
npm install @molecule/app-section-divider-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
SectionDividerProps
Props accepted by SectionDivider — the same props
@molecule/app-section-divider-react accepts. The label is projected
content in Angular (an input cannot carry a node), so children is typed
unknown: pass it in the host template, not as a value.
interface SectionDividerProps {
/** Centered label text, projected as the element's default content. */
children?: unknown
/** Where to align the label. Defaults to `'center'`. */
align?: 'start' | 'center' | 'end'
/** Extra classes. */
className?: string
}
Classes
SectionDivider
SectionDivider component.
Horizontal divider with an optional centered label, common as "OR" between
auth options, "Today" between feed days, "—" between sections. The host IS
the outer <div> (div[mol-section-divider]), matching React's root
exactly; the label is the projected default content, wrapped in the same
span React renders. The label wrapper lives in the template unconditionally
(projected nodes need an always-mounted capture point) and is detached from
the DOM when React would not render it — {children && …}. align
positions the label: 'center' (default) draws lines on both sides,
'start' / 'end' put the label at that edge with a single line filling
the rest. The lines' declarations are written through the CSSOM
([style.border-top] / [style.opacity]), exactly where React's inline
style lands: currentColor at 20% opacity, so they inherit the local text
color in both themes.
@Component({
selector: 'div[mol-section-divider]',
standalone: true,
hostDirectives: [MolPlacement],
inputs: ['align', 'className'],
host: {
role: 'separator',
'aria-orientation': 'horizontal',
'[class]': 'classes()',
},
template: `@if (showsLeadingLine()) {
<span
[class]="lineClasses()"
aria-hidden="true"
[style.border-top]="lineColor()"
[style.opacity]="lineOpacity()"
></span>
}
<span [class]="labelClasses()" #labelSlot><ng-content></ng-content></span>
@if (showsTrailingLine()) {
<span
[class]="lineClasses()"
aria-hidden="true"
[style.border-top]="lineColor()"
[style.opacity]="lineOpacity()"
></span>
}`,
})
export class SectionDivider {
/** Where the label sits. Defaults to `'center'` at read time. */
align?: 'start' | 'center' | 'end'
/** Extra classes on the outer `<div>`. */
className?: string
/** The label capture span (always in the template; detached when empty). */
@ViewChild('labelSlot') labelSlot?: ElementRef<HTMLSpanElement>
constructor() {
usePlacement((hasContent) => this.syncLabel(hasContent))
}
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* Computes the divider class list (`cm.flex({ align: 'center', gap: 'sm' })`
* + `className`, through `cn()` exactly as React computes it).
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().flex({ align: 'center', gap: 'sm' }), this.className)
}
/**
* The label span's class (`cm.textSize('xs')` + `cm.fontWeight('semibold')`).
* @returns The class string.
*/
labelClasses(): string {
return this.cm().cn(this.cm().textSize('xs'), this.cm().fontWeight('semibold'))
}
/**
* A flanking line's class (`cm.flex1`), through `cn()` so a token that is a
* function in the bonded map resolves to its string — Angular's `[class]`
* binding takes strings only.
* @returns The class string.
*/
lineClasses(): string {
return this.cm().cn(this.cm().flex1)
}
/**
* React's `align` default parameter: a later-bound write of `undefined`
* must not erase the `'center'` default.
* @returns The alignment.
*/
alignment(): 'start' | 'center' | 'end' {
return this.align ?? 'center'
}
/**
* Whether the line before the label renders (`align` `'center'` or `'end'`).
* @returns True when a leading line shows.
*/
showsLeadingLine(): boolean {
const align = this.alignment()
return align === 'center' || align === 'end'
}
/**
* Whether the line after the label renders (`align` `'center'` or `'start'`).
* @returns True when a trailing line shows.
*/
showsTrailingLine(): boolean {
const align = this.alignment()
return align === 'center' || align === 'start'
}
/**
* The flanking line's border declaration (`currentColor` so it inherits the
* text color).
* @returns The `border-top` value.
*/
lineColor(): string {
return '1px solid currentColor'
}
/**
* The flanking line's opacity.
* @returns The opacity value.
*/
lineOpacity(): string {
return '0.2'
}
/**
* Keeps the label wrapper in the DOM exactly while React renders it, at the
* position Angular put it.
*
* @param hasContent - Reads whether a slot has content.
*/
private syncLabel(hasContent: SlotReader): void {
const span = this.labelSlot?.nativeElement
setElementPresent(span, hasContent(span))
}
}
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.13.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-angular^1.1.0
Runtime Dependencies
-
@angular/common -
@angular/core -
@angular/platform-browser -
@molecule/app-angular -
@molecule/app-ui -
@molecule/app-ui-angular -
Requires a bonded ClassMap (frame uses
cm.flex, lines usecm.flex1) — rendering throws otherwise. No i18n dependency (the label is projected content — translate it upstream). -
alignpositions the label:'center'(default) draws lines on both sides;'start'/'end'put the label at that edge with a single line filling the rest. -
Lines use
currentColorat 20% opacity, so they inherit the local text color in both light and dark themes.