Sticky CTA
blockmarketingSticky conversion trio that stays out of the way until scrolled for: a bottom CTA bar with offer line and social proof, a compact corner button that expands on hover or focus, and a bottom bar that doubles as a reading-progress indicator.
Installation
$pnpm dlx uipkge-ng@latest add sticky-cta$npx uipkge-ng@latest add sticky-cta$yarn dlx uipkge-ng@latest add sticky-cta$bunx uipkge-ng@latest add sticky-ctaManifest:
https://uipkge.dev/r/angular/sticky-cta.jsonInstalls to:src/app/components/blocks/sticky-cta/Variants
Loading interactive previews…
Loading interactive previews…
npm dependencies
Files installed (4)
src/app/components/blocks/sticky-cta/sticky-cta-bar.component.ts3.9 kB
// Scroll-triggered bottom CTA bar that reveals past a threshold, carrying an offer // line, inline social proof, primary + ghost actions, and a dismiss control that // stays dismissed for the session. Port of the Vue/React block 1:1. import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit, signal } from '@angular/core' import { Clock, LucideAngularModule, X } from 'lucide-angular' import { cn } from '@/lib/utils' import { UiBadgeComponent } from '@/ui/badge/badge.component' import { UiButtonComponent } from '@/ui/button/button.component' import { UiSeparatorComponent } from '@/ui/separator/separator.component' @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'ui-sticky-cta-bar, [ui-sticky-cta-bar]', standalone: true, // The block renders its own fixed root <div>: keep this wrapper out of the layout. host: { '[attr.class]': '"contents"' }, imports: [LucideAngularModule, UiBadgeComponent, UiButtonComponent, UiSeparatorComponent], template: ` <div data-slot="sticky-cta-bar" [class]="rootClass" role="region" aria-label="Trial offer" [attr.aria-hidden]="!visible()" > <div class="border-border bg-card/95 mx-auto flex max-w-4xl flex-wrap items-center gap-x-5 gap-y-3 rounded-xl border p-3 pl-4 shadow-lg backdrop-blur" > <span ui-badge variant="secondary" class="gap-1.5"> <lucide-icon [img]="Clock" class="size-3" /> Free for 14 days </span> <p class="min-w-0 grow text-sm"> <span class="font-medium">Start on the full plan.</span> <span class="text-muted-foreground"> No card, no sales call, cancel from the dashboard.</span> </p> <div class="flex items-center gap-2"> <button ui-button size="sm">Start free trial</button> <button ui-button size="sm" variant="ghost" class="hidden sm:inline-flex">Talk to us</button> <div ui-separator orientation="vertical" class="hidden h-6 sm:block"></div> <button ui-button size="icon" variant="ghost" aria-label="Dismiss this offer" (click)="dismiss()"> <lucide-icon [img]="X" class="size-4" /> </button> </div> </div> </div> `, }) export class UiStickyCtaBarComponent implements OnInit, OnDestroy { protected readonly Clock = Clock protected readonly X = X /** Scroll distance in pixels before the bar reveals. */ @Input() threshold = 480 /** sessionStorage key holding the dismissal, so it stays closed for the session. */ @Input() storageKey = 'uipkge:sticky-cta-dismissed' @Input('class') className?: string // Starts hidden so server and first client render agree — the scroll handler // is the only thing that reveals it. readonly visible = signal(false) private dismissed = false private onScrollBound: (() => void) | null = null ngOnInit(): void { if (typeof window === 'undefined') return try { this.dismissed = window.sessionStorage.getItem(this.storageKey) === '1' } catch { this.dismissed = false } this.onScrollBound = () => this.onScroll() this.onScroll() window.addEventListener('scroll', this.onScrollBound, { passive: true }) } ngOnDestroy(): void { if (typeof window !== 'undefined' && this.onScrollBound) { window.removeEventListener('scroll', this.onScrollBound) } } get rootClass(): string { return cn( 'fixed inset-x-0 bottom-0 z-50 px-4 pb-4 transition duration-200', this.visible() ? 'translate-y-0 opacity-100' : 'pointer-events-none invisible translate-y-full opacity-0', this.className, ) } onScroll(): void { this.visible.set(!this.dismissed && window.scrollY > this.threshold) } dismiss(): void { this.dismissed = true this.visible.set(false) try { window.sessionStorage.setItem(this.storageKey, '1') } catch { // Private browsing or blocked storage: dismissing still holds for this page view. } } }src/app/components/blocks/sticky-cta/sticky-cta-corner-button.component.ts2.3 kB
// Compact corner action that expands on hover or focus to reveal its label, // staying out of the content column on narrow screens. Port of the Vue/React // block 1:1. import { ChangeDetectionStrategy, Component, Input, signal } from '@angular/core' import { LucideAngularModule, MessageSquare } from 'lucide-angular' import { cn } from '@/lib/utils' import { UiBadgeComponent } from '@/ui/badge/badge.component' import { UiButtonComponent } from '@/ui/button/button.component' @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'ui-sticky-cta-corner-button, [ui-sticky-cta-corner-button]', standalone: true, // The block renders its own fixed root <div>: keep this wrapper out of the layout. host: { '[attr.class]': '"contents"' }, imports: [LucideAngularModule, UiBadgeComponent, UiButtonComponent], template: ` <div data-slot="sticky-cta-corner-button" [class]="rootClass"> <button ui-button size="lg" class="group h-12 gap-0 rounded-full pr-4 pl-4 shadow-lg" (mouseenter)="expanded.set(true)" (mouseleave)="expanded.set(false)" (focus)="expanded.set(true)" (blur)="expanded.set(false)" > <lucide-icon [img]="MessageSquare" class="size-5 shrink-0" /> <!-- Width, not display: a hidden label would not animate, and a label that pops in shifts the button under the cursor mid-click. --> <span [class]="labelClass"> Ask an engineer </span> </button> <span ui-badge variant="secondary" class="border-background pointer-events-none absolute -top-1 -right-1 size-5 justify-center rounded-full border-2 p-0 text-xs" > 1 </span> </div> `, }) export class UiStickyCtaCornerButtonComponent { protected readonly MessageSquare = MessageSquare // Expands on focus as well as hover: a keyboard user should be able to read the // label before deciding whether to activate it. readonly expanded = signal(false) @Input('class') className?: string get rootClass(): string { return cn('fixed right-5 bottom-5 z-50', this.className) } get labelClass(): string { return cn( 'overflow-hidden whitespace-nowrap transition-colors duration-200', this.expanded() ? 'ml-2 max-w-[10rem] opacity-100' : 'max-w-0 opacity-0', ) } }src/app/components/blocks/sticky-cta/sticky-cta-reading-progress.component.ts3.9 kB
// Sticky bar doubling as a reading-progress indicator: it reveals partway down a // long page and reports how much remains. Port of the Vue/React block 1:1. import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit, signal } from '@angular/core' import { ArrowRight, LucideAngularModule, X } from 'lucide-angular' import { cn } from '@/lib/utils' import { UiBadgeComponent } from '@/ui/badge/badge.component' import { UiButtonComponent } from '@/ui/button/button.component' import { UiProgressComponent } from '@/ui/progress/progress.component' import { UiSeparatorComponent } from '@/ui/separator/separator.component' @Component({ changeDetection: ChangeDetectionStrategy.Eager, selector: 'ui-sticky-cta-reading-progress, [ui-sticky-cta-reading-progress]', standalone: true, // The block renders its own fixed root <div>: keep this wrapper out of the layout. host: { '[attr.class]': '"contents"' }, imports: [LucideAngularModule, UiBadgeComponent, UiButtonComponent, UiProgressComponent, UiSeparatorComponent], template: ` <div data-slot="sticky-cta-reading-progress" [class]="rootClass" role="region" aria-label="Reading progress and trial offer" [attr.aria-hidden]="!visible()" > <ui-progress [value]="progress()" class="h-0.5 rounded-none" aria-label="Reading progress" /> <div class="mx-auto flex max-w-5xl flex-wrap items-center gap-x-5 gap-y-2 px-6 py-3"> <span ui-badge variant="secondary" class="shrink-0 tabular-nums">{{ progress() }}% read</span> <p class="min-w-0 grow text-sm"> <span class="font-medium">Finished the technical detail?</span> <span class="text-muted-foreground"> The trial runs on your real warehouse, read-only.</span> </p> <div class="flex shrink-0 items-center gap-2"> <button ui-button size="sm"> Start free <lucide-icon [img]="ArrowRight" class="ml-1.5 size-3.5" /> </button> <div ui-separator orientation="vertical" class="hidden h-5 sm:block"></div> <button ui-button size="icon" variant="ghost" class="size-7" aria-label="Dismiss" (click)="dismiss()"> <lucide-icon [img]="X" class="size-3.5" /> </button> </div> </div> </div> `, }) export class UiStickyCtaReadingProgressComponent implements OnInit, OnDestroy { protected readonly ArrowRight = ArrowRight protected readonly X = X @Input() revealAt = 15 @Input('class') className?: string // Both start at rest so server and first client paint agree; the scroll handler // is the only thing that reveals the bar or moves the progress. readonly progress = signal(0) readonly visible = signal(false) private dismissed = false private onScrollBound: (() => void) | null = null ngOnInit(): void { if (typeof window === 'undefined') return this.onScrollBound = () => this.onScroll() this.onScroll() window.addEventListener('scroll', this.onScrollBound, { passive: true }) window.addEventListener('resize', this.onScrollBound) } ngOnDestroy(): void { if (typeof window !== 'undefined' && this.onScrollBound) { window.removeEventListener('scroll', this.onScrollBound) window.removeEventListener('resize', this.onScrollBound) } } get rootClass(): string { return cn( 'border-border bg-card/95 fixed inset-x-0 bottom-0 z-50 border-t backdrop-blur transition duration-200', this.visible() ? 'translate-y-0 opacity-100' : 'pointer-events-none invisible translate-y-full opacity-0', this.className, ) } onScroll(): void { const scrollable = document.documentElement.scrollHeight - window.innerHeight const percent = scrollable > 0 ? Math.min(Math.round((window.scrollY / scrollable) * 100), 100) : 0 this.progress.set(percent) this.visible.set(!this.dismissed && percent >= this.revealAt) } dismiss(): void { this.dismissed = true this.visible.set(false) } }src/app/components/blocks/sticky-cta/index.ts0.2 kB
export { UiStickyCtaBarComponent } from './sticky-cta-bar.component' export { UiStickyCtaCornerButtonComponent } from './sticky-cta-corner-button.component' export { UiStickyCtaReadingProgressComponent } from './sticky-cta-reading-progress.component'
Raw manifest:https://uipkge.dev/r/angular/sticky-cta.json