@molecule/app-social-share-buttons-angular
Feature · social-share-buttons · App (browser) · v1.2.1 · Apache-2.0
Twitter/LinkedIn/Facebook/copy share button group
npm install @molecule/app-social-share-buttons-angularHow it works
@molecule/app-social-share-buttons-angular is a ready-made social-share-buttons 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 { SocialShareButtons } from '@molecule/app-social-share-buttons-angular'
@Component({
selector: 'article-share',
standalone: true,
imports: [SocialShareButtons],
template: `
<div
mol-social-share-buttons
[url]="'https://example.com/blog/my-post'"
[title]="'Check out this article'"
[platforms]="['twitter', 'linkedin', 'reddit', 'email', 'copy']"
size="sm"
></div>
`,
})
export class ArticleShare {}Works with: @molecule/app-angular, @molecule/app-clipboard, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular social share buttons row.
Exports <SocialShareButtons> — the Angular counterpart of
@molecule/app-social-share-buttons-react, with the same props (React names)
and the same DOM, plus the SocialPlatform union. Twitter(X)/LinkedIn/
Facebook/Reddit/email/copy button group: each network button opens that
platform's share URL in a new tab and 'copy' writes the URL to the
clipboard with "Copied!" feedback. 'x' is an alias of 'twitter' (same
intent URL). Default platforms: twitter, linkedin, facebook, copy.
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 { SocialShareButtons } from '@molecule/app-social-share-buttons-angular'
@Component({
selector: 'article-share',
standalone: true,
imports: [SocialShareButtons],
template: `
<div
mol-social-share-buttons
[url]="'https://example.com/blog/my-post'"
[title]="'Check out this article'"
[platforms]="['twitter', 'linkedin', 'reddit', 'email', 'copy']"
size="sm"
></div>
`,
})
export class ArticleShare {}
Type
feature
Installation
npm install @molecule/app-social-share-buttons-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-clipboard @molecule/app-ui @molecule/app-ui-angular
API
Interfaces
SocialShareButtonsProps
Props for SocialShareButtons — the same props the React package takes.
interface SocialShareButtonsProps {
/** URL to share. */
url: string
/** Optional share text / title. */
title?: string
/** Platforms to include (order = display order). */
platforms?: SocialPlatform[]
/** Visual size. */
size?: 'sm' | 'md'
/** Extra classes. */
className?: string
}
Types
SocialPlatform
Supported social/sharing platforms for the share-buttons widget.
type SocialPlatform = 'twitter' | 'x' | 'linkedin' | 'facebook' | 'reddit' | 'email' | 'copy'
Classes
SocialShareButtons
SocialShareButtons component.
Row of share buttons — opens each platform's share sheet in a new tab.
'copy' copies the URL to the clipboard with "Copied!" feedback. The host IS
the outer <div> (div[mol-social-share-buttons]), matching React's root
exactly. Styling routes through the ClassMap token
cm.flex({ align: 'center', gap: 'xs' }).
Copying goes through @molecule/app-clipboard's copyTextWithFallback()
(the Clipboard API where available, the legacy copy command otherwise;
false where no copy happened and the button then stays unchanged), as
in React. Platform labels each use their literal share.<platform> i18n
key and the copy feedback uses share.copied, read through the binding's
reactive useTranslation(), so a locale switch refreshes the text
(React's components re-render through useTranslation()).
@Component({
selector: 'div[mol-social-share-buttons]',
standalone: true,
imports: [Button],
inputs: ['url', 'title', 'platforms', 'size', 'className'],
host: {
'[class]': 'classes()',
},
template: `@for (platform of platformsList(); track platform) {
@if (platform === 'copy') {
<button
mol-button
[variant]="'outline'"
[size]="size ?? 'sm'"
[attr.aria-label]="label(platform)"
(click)="copy()"
>
{{ buttonLabel() }}
</button>
} @else {
<a
[href]="shareUrlFor(platform)"
target="_blank"
rel="noreferrer noopener"
[attr.aria-label]="label(platform)"
>
<button mol-button [variant]="'outline'" [size]="size ?? 'sm'">
{{ icon(platform) }}
</button>
</a>
}
}`,
})
export class SocialShareButtons implements OnDestroy {
/** URL to share. */
url?: string
/** Optional share text / title. */
title?: string
/** Platforms to include (order = display order; defaults to twitter, linkedin, facebook, copy). */
platforms?: SocialPlatform[]
/** Visual size (defaults to `'sm'` at read time). */
size?: 'sm' | 'md'
/** Extra classes on the outer wrapper. */
className?: string
/**
* Reactive translation, read in the injection context. Its `t` reads the
* locale, so the view re-renders the text on a locale switch (the static `t`
* does not).
*/
private readonly i18n = useTranslation()
/** Whether the last copy succeeded ("Copied!" is showing). */
private readonly copied = signal(false)
/** The pending feedback reset timer, cleared when the component dies. */
private timer?: ReturnType<typeof setTimeout>
/**
* The current class map.
* @returns The UIClassMap.
*/
cm(): UIClassMap {
return getClassMap()
}
/**
* The wrapper class list (React's
* `cm.cn(cm.flex({ align: 'center', gap: 'xs' }), className)`).
* @returns The class string.
*/
classes(): string {
return this.cm().cn(this.cm().flex({ align: 'center', gap: 'xs' }), this.className)
}
/**
* The platforms to render (React's `platforms` default parameter).
* @returns The platform list.
*/
platformsList(): SocialPlatform[] {
return this.platforms ?? DEFAULT_PLATFORMS
}
/**
* The platform's button glyph (React's `ICON[platform]`).
* @param platform - The platform.
* @returns The text glyph.
*/
icon(platform: SocialPlatform): string {
return ICON[platform]
}
/**
* The platform's accessible label, through ONE literal `t()` key per
* platform (a runtime-built `` `share.${platform}` `` cannot be checked
* against the locale bond). The defaults are the platforms' English names — the
* text the bond's `en.ts` holds for these keys.
* @param platform - The platform.
* @returns The label text.
*/
label(platform: SocialPlatform): string {
switch (platform) {
case 'twitter':
return this.i18n.t('share.twitter', undefined, { defaultValue: 'Twitter' })
case 'x':
return this.i18n.t('share.x', undefined, { defaultValue: 'X' })
case 'linkedin':
return this.i18n.t('share.linkedin', undefined, { defaultValue: 'LinkedIn' })
case 'facebook':
return this.i18n.t('share.facebook', undefined, { defaultValue: 'Facebook' })
case 'reddit':
return this.i18n.t('share.reddit', undefined, { defaultValue: 'Reddit' })
case 'email':
return this.i18n.t('share.email', undefined, { defaultValue: 'Email' })
case 'copy':
return this.i18n.t('share.copy', undefined, { defaultValue: 'Copy' })
}
}
/**
* The platform's share URL (React's `shareUrl(p, url, title)`).
* @param platform - The platform.
* @returns The share URL (the raw url for the copy platform).
*/
shareUrlFor(platform: SocialPlatform): string {
return shareUrl(platform, this.url ?? '', this.title)
}
/**
* The copy button's text: "Copied!" while the feedback shows, the copy glyph
* otherwise (React's `copied ? t('share.copied', …) : ICON.copy`).
* @returns The button text.
*/
buttonLabel(): string {
return this.copied()
? this.i18n.t('share.copied', undefined, { defaultValue: 'Copied!' })
: ICON.copy
}
/**
* Copies the URL, then shows the "Copied!" feedback for 1.5 s.
*/
copy(): void {
void copyTextWithFallback(this.url ?? '').then((copiedOk) => {
if (!copiedOk) return
this.copied.set(true)
this.timer = setTimeout(() => this.copied.set(false), 1500)
})
}
/** Detaches the feedback timer with the component. */
ngOnDestroy(): void {
clearTimeout(this.timer)
}
}
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.5.0 || ^4.0.0@molecule/app-clipboard^1.0.1@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-clipboard -
@molecule/app-ui -
@molecule/app-ui-angular -
Must render inside the app's i18n provider and with a ClassMap bond wired (
useTranslation()/getClassMap()throw otherwise). -
'copy'copies through@molecule/app-clipboard'scopyTextWithFallback()— the Clipboard API where available, then the legacy copy command — so it also works on plain HTTP and in iframes wherenavigator.clipboardis missing or refuses the write. When no copy happens the button stays unchanged. -
Sharing uses fixed platform intent URLs opened in a new tab; there is no Web Share API integration and no per-platform SDKs.
-
Button icons are plain text glyphs (𝕏, "in", "f", ✉, ⧉), not brand SVG logos — restyle via
classNameif brand marks are required. -
Every key ships in the companion locale bond:
share.copiedplus one literalshare.<platform>key per platform, whose English text is the platform's name (Twitter, LinkedIn, Email, Copy, …).
Translations
Translation strings are provided by @molecule/app-locales-social-share-buttons.