@molecule/app-note-card-angular

Feature · note-card · App (browser) · v1.1.3 · Apache-2.0

Sticky-note style card with color, body, optional pin/archive actions

npm install @molecule/app-note-card-angular

npm · Source on GitHub

How it works

@molecule/app-note-card-angular is a ready-made note-card 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 { NoteCard } from '@molecule/app-note-card-angular'

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [NoteCard],
  template: `
    <article
      mol-note-card
      title="Meeting notes"
      body="Follow up with design team on the new dashboard layout."
      color="#fef9c3"
      [pinned]="true"
      modifiedAt="Jun 5, 2026"
      [onClick]="openNote"
    >
      <button slot="actions" type="button">Edit</button>
    </article>
  `,
})
export class App {
  openNote(): void {
    // navigate to the note…
  }
}

Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular

Reference

Angular sticky-note style card — the counterpart of @molecule/app-note-card-react: the same props and the same DOM for the same input.

Exports NoteCard — a sticky-note style card with optional color tint, pinned indicator, and bottom-right actions. Use for note-taking apps, digital post-its, dashboard quick-notes.

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.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { NoteCard } from '@molecule/app-note-card-angular'

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [NoteCard],
  template: `
    <article
      mol-note-card
      title="Meeting notes"
      body="Follow up with design team on the new dashboard layout."
      color="#fef9c3"
      [pinned]="true"
      modifiedAt="Jun 5, 2026"
      [onClick]="openNote"
    >
      <button slot="actions" type="button">Edit</button>
    </article>
  `,
})
export class App {
  openNote(): void {
    // navigate to the note…
  }
}

Type

feature

Installation

npm install @molecule/app-note-card-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

NoteCardProps

Props for NoteCard — the same props @molecule/app-note-card-react accepts. Node-valued props (title, body, modifiedAt, actions) are projected content in Angular (an input cannot carry a node): pass a string value through the input, and element content in the host template as [slot=<name>] content.

interface NoteCardProps {
  /**
   * Note title. A string or number renders as text; element content is
   * projected as `[slot=title]` content instead.
   */
  title?: unknown
  /**
   * Note body text. A string or number renders as text; element content is
   * projected as `[slot=body]` content instead.
   */
  body?: unknown
  /**
   * Background tint (CSS colour). The documented note tints (yellow
   * `#fef9c3`, green `#dcfce7`, blue `#dbeafe`, red `#fee2e2`, amber
   * `#fef3c7`) render as the theme's light tint of their tone; a colour
   * with no tone is data, applied as given.
   */
  color?: string
  /** Optional pin / starred indicator. */
  pinned?: boolean
  /**
   * Optional last-modified display. A string or number renders as text;
   * element content is projected as `[slot=modifiedAt]` content instead.
   */
  modifiedAt?: unknown
  /** Optional right-side actions (edit, archive, delete), projected as `[slot=actions]` content. */
  actions?: unknown
  /**
   * Activates the card: while it is set, an empty, transparent native button
   * covers the whole card and calls this on click — Enter and Space included,
   * natively, since the control is a real button. The button is named by the
   * title when there is one, else the body. The card's other controls (the
   * `actions` slot) sit above that button and keep their own clicks, so they
   * do not fire this.
   */
  onClick?: () => void
  /** Extra classes. */
  className?: string
}

Classes

NoteCard

NoteCard component.

Sticky-note style card with optional color tint, pinned indicator, and bottom-right actions. Use for note-taking apps, digital post-its, dashboard quick-notes. The host IS the root <article> (article[mol-note-card]), matching React's root exactly; the paper colour of a tint with no tone is applied inline through a host style binding (the CSSOM, as react-dom does).

With an onClick, an empty, transparent native button covers the whole card — React's overlay shape. It is named by the title when there is one, else the body (the per-instance NoteCard.nameId sits on whichever element carries the label). The template mounts the button through @if (onClick), so the rendered DOM follows the input exactly as React's conditional renders.

The card's paper is a theme tone: the documented note tints (yellow #fef9c3, green #dcfce7, blue #dbeafe, red #fee2e2, amber #fef3c7) render as the theme's light tint of the matching tone, so the card and its text (the theme's ink) follow the app theme. A color with no tone is data: it is applied as given, over the tone's paper. The accessible label of the pin indicator is the string React renders (t('noteCard.aria.pinned', undefined, { defaultValue: 'Pinned' })), read through useTranslation() so it follows a locale switch.

The node props are projected slots: title renders inside the <h3>, body inside the body <div>, modifiedAt inside its <span>, and actions bare beside it (React renders {actions} with no wrapper). String inputs render as text instead — React's truthiness branch applies: an empty string renders nothing. The always-mounted capture wrappers reconcile against that in NoteCard.reconcile.

@Component({
  selector: 'article[mol-note-card]',
  standalone: true,
  hostDirectives: [MolPlacement],
  inputs: ['title', 'body', 'color', 'pinned', 'modifiedAt', 'actions', 'onClick', 'className'],
  host: {
    '[class]': 'classes()',
    '[style.background]': 'dataTint()',
    '[style.border-radius]': "'8px'",
    '[style.position]': 'rootPosition()',
  },
  template: `@if (onClick) {
      <button
        type="button"
        (click)="handleClick()"
        [attr.aria-labelledby]="nameId"
        data-mol-id="note-card-open"
        [class]="openClasses()"
        [style]="openStyle()"
      ></button>
    }
    @if (pinned) {
      <span
        role="img"
        [attr.aria-label]="pinnedLabel()"
        style="position: absolute; top: 6px; right: 6px"
        >📌</span
      >
    }
    <h3 #titleWrap [attr.id]="titleId()" [class]="titleClasses()">
      @if (titleText()) {
        <ng-container>{{ titleText() }}</ng-container>
      }
      <ng-content select="[slot=title]"></ng-content>
    </h3>
    <div #bodyWrap [attr.id]="bodyId()" [class]="bodyClass()" style="white-space: pre-wrap">
      @if (bodyText()) {
        <ng-container>{{ bodyText() }}</ng-container>
      }
      <ng-content select="[slot=body]"></ng-content>
    </div>
    <footer #footerWrap [class]="footerClasses()">
      <span #modifiedWrap [class]="modifiedClass()">
        @if (modifiedText()) {
          <ng-container>{{ modifiedText() }}</ng-container>
        }
        <ng-content select="[slot=modifiedAt]"></ng-content
      ></span>
      <span #actionsWrap><ng-content select="[slot=actions]"></ng-content></span>
    </footer>`,
})
export class NoteCard {
  /** Note title (string/number renders as text; nodes are `[slot=title]` content). */
  title?: unknown
  /** Note body text (string/number renders as text; nodes are `[slot=body]` content). */
  body?: unknown
  /** Background tint (CSS colour). */
  color?: string
  /** Optional pin / starred indicator. */
  pinned?: boolean
  /** Optional last-modified display (string/number as text; nodes are `[slot=modifiedAt]` content). */
  modifiedAt?: unknown
  /** Optional right-side actions (`[slot=actions]` content; React renders them bare). */
  actions?: unknown
  /** Click handler; called with no arguments (React's `onClick`). */
  onClick?: () => void
  /** Extra classes. */
  className?: string

  /** The title's `<h3>` (detached when no title input and the slot is empty). */
  @ViewChild('titleWrap') titleWrap?: ElementRef<HTMLElement>
  /** The body `<div>`. */
  @ViewChild('bodyWrap') bodyWrap?: ElementRef<HTMLElement>
  /** The footer (detached when neither modifiedAt nor actions exist). */
  @ViewChild('footerWrap') footerWrap?: ElementRef<HTMLElement>
  /** The modified-at `<span>` (detached when no modifiedAt input and the slot is empty). */
  @ViewChild('modifiedWrap') modifiedWrap?: ElementRef<HTMLElement>
  /** The actions capture wrapper (revealed bare once; React renders the slot bare). */
  @ViewChild('actionsWrap') actionsWrap?: ElementRef<HTMLElement>

  /** Per-instance counter backing `NoteCard.nameId` (React numbers `useId()` ids). */
  private static nextId = 0
  /** The id the open button's `aria-labelledby` points at (on the title, else the body). */
  readonly nameId = `mol-note-card-name-${NoteCard.nextId++}`
  /** The i18n handle (locale-reactive), read in an injection context. */
  private readonly i18n = useTranslation()

  /** Whether the title renders (a text title, or a projected `[slot=title]`), written by the placement function and read by the id bindings. */
  private readonly titlePresent = signal(false)

  constructor() {
    usePlacement((hasContent) => this.reconcile(hasContent))
  }

  /** The current class map. */
  cm(): UIClassMap {
    return getClassMap()
  }

  classes(): string {
    return this.cm().cn(
      this.cm().stack(2),
      this.cm().sp('p', 3),
      this.cm().bgTone(this.tone(), { subtle: true }),
      this.cm().shadowLifted,
      this.className,
    )
  }

  /** The open button's classes: positioned over the whole card and pointer (React's overlay button). */
  openClasses(): string {
    return this.cm().cn(this.cm().position('absolute'), this.cm().inset0, this.cm().cursorPointer)
  }

  /** The open button's overlay reset (React's style object). */
  openStyle(): Record<string, string> {
    return openButtonStyle()
  }

  /** Computes the title's class (`cm.textSize('sm')` + `cm.fontWeight('bold')`). */
  titleClasses(): string {
    return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('bold'))
  }

  /** The body div's class (`cm.textSize('sm')`). */
  bodyClass(): string {
    return this.cm().textSize('sm')
  }

  footerClasses(): string {
    return this.cm().cn(
      this.cm().flex({ align: 'center', justify: 'between', gap: 'sm' }),
      this.onClick ? this.cm().position('relative') : undefined,
    )
  }

  /** The modified-at span's class (`cm.textSize('xs')`). */
  modifiedClass(): string {
    return this.cm().textSize('xs')
  }

  /** The tone whose light tint is the card's paper: the `color` input's tone, or warning when none is given (the default paper). */
  tone(): ColorVariant {
    return tintTone(this.color) ?? 'warning'
  }

  dataTint(): string | undefined {
    return tintTone(this.color) === undefined ? this.color : undefined
  }

  pinnedLabel(): string {
    return this.i18n.t('noteCard.aria.pinned', undefined, { defaultValue: 'Pinned' })
  }

  /** The card's root position: relative, so the card owns its absolute children — the open button's overlay and the pinned indicator. */
  rootPosition(): string {
    return 'relative'
  }

  private get hasLabel(): boolean {
    return this.titlePresent()
  }

  /** The title `<h3>`'s id (the open button's `aria-labelledby` target when a title renders; React's `useId()` placement). */
  titleId(): string | undefined {
    return this.onClick && this.hasLabel ? this.nameId : undefined
  }

  /** The body `<div>`'s id (the open button's `aria-labelledby` target when no title renders; React's `useId()` placement). */
  bodyId(): string | undefined {
    return this.onClick && !this.hasLabel ? this.nameId : undefined
  }

  titleText(): string {
    return typeof this.title === 'string' || typeof this.title === 'number'
      ? String(this.title)
      : ''
  }

  /** The body input's text (React's `{body}` for a text child). */
  bodyText(): string {
    return typeof this.body === 'string' || typeof this.body === 'number' ? String(this.body) : ''
  }

  /** The modifiedAt input's text (React's `{modifiedAt}` for a text child). */
  modifiedText(): string {
    return typeof this.modifiedAt === 'string' || typeof this.modifiedAt === 'number'
      ? String(this.modifiedAt)
      : ''
  }

  /** Runs the click handler the way React's overlay button forwards it (no event). */
  handleClick(): void {
    this.onClick?.()
  }

  private reconcile(hasContent: SlotReader): void {
    const title = this.titleWrap?.nativeElement
    const footer = this.footerWrap?.nativeElement
    const modified = this.modifiedWrap?.nativeElement
    const actions = this.actionsWrap?.nativeElement
    if (!title || !footer || !modified || !actions) return

    const titleShown = this.titleText() !== '' || hasContent(title)
    this.titlePresent.set(titleShown)
    const modifiedShown = this.modifiedText() !== '' || hasContent(modified)
    const footerShown = modifiedShown || hasContent(actions)
    setElementPresent(title, titleShown)
    setElementPresent(modified, modifiedShown)
    setElementPresent(footer, footerShown)
    if (!footerShown) return
    // React renders the actions bare inside the footer: the projected nodes
    // render at the capture wrapper's place, and the wrapper leaves the DOM.
    placeContent(actions, footer, actions)
    setElementPresent(actions, false)
  }
}

(Member comments are shortened to their first sentence, and the 7 longest are left out to fit; the full declaration is in node_modules/@molecule/app-note-card-angular/dist/note-card.component.d.ts.)

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.4.0
  • @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 wired ClassMap bond — getClassMap() throws before wiring.

The card's paper is a theme tone: the documented note tints (yellow #fef9c3, green #dcfce7, blue #dbeafe, red #fee2e2, amber #fef3c7) render as the theme's light tint of the matching tone, so the card and its text (the theme's ink) follow the app theme. A color with no tone is data: it is applied as given, over the tone's paper.

onClick makes the whole card clickable through a transparent native button over it — Enter and Space included, natively — named by the title when there is one, else the body; the card's inner controls (the actions slot) sit above it and keep their own clicks.

Node-valued props are projected content: title, body and modifiedAt are selected by [slot=title] / [slot=body] / [slot=modifiedAt], actions by [slot=actions]; string inputs render as text with React's truthiness branch (an empty string renders nothing).

Translations

Translation strings are provided by @molecule/app-locales-note-card.