Add to Calendar Button – JavaScript Calendar Links

Category: Date & Time , Javascript , Recommended | October 1, 2026
Authorjekuer
Last UpdateOctober 1, 2026
LicenseMIT
Views4,806 views
Add to Calendar Button – JavaScript Calendar Links

Add-to-Calendar Button is a JavaScript web component for creating event buttons that open Google Calendar, Apple Calendar, Outlook, Microsoft 365, Microsoft Teams, Yahoo Calendar, or an iCal file.

It works as a custom <add-to-calendar-button> element in HTML and also exposes a JavaScript API for custom triggers.

Features

  • Calendar links for Apple, Google, iCal, Microsoft 365, Microsoft Teams, Outlook.com, and Yahoo.
  • Timed, all-day, recurring, and multi-date events.
  • Calendar subscription links through an external ICS calendar.
  • Built-in button styles, dark mode, custom CSS variables, external CSS, and ::part styling hooks.
  • Localized labels with RTL language handling.
  • Generated Schema.org event data and configurable ICS metadata.
  • Custom trigger support through atcb_action().
  • Tracking data through the element attribute and browser data layer.

How to use it

1. Install Add-to-Calendar Button

Load the latest JavaScript from a CDN.

<script src="https://cdn.jsdelivr.net/npm/add-to-calendar-button@3" async defer></script>

Or install & import it via NPM

npm install add-to-calendar-button
import 'add-to-calendar-button';

Import necessary styles and languages.

import 'add-to-calendar-button';
import 'add-to-calendar-button/styles/3d';
import 'add-to-calendar-button/i18n/de';

2. Create a basic Add to Calendar button

<add-to-calendar-button
  name="Launch Party"
  start-date="2026-10-15"
  start-time="18:00"
  end-time="20:00"
  time-zone="America/Los_Angeles"
  location="123 Demo Street"
  options="'apple','google','ical','ms365','msteams','outlookcom','yahoo'"
></add-to-calendar-button>

3. Create an all-day event

Omit start-time and end-time for an all-day event.

<add-to-calendar-button
  name="Conference Day"
  start-date="2026-10-20"
  end-date="2026-10-20"
  options="'apple','google','ical','outlookcom'"
></add-to-calendar-button>

4. Create a recurring event

<add-to-calendar-button
  name="Weekly Standup"
  start-date="2026-10-05"
  start-time="09:00"
  end-time="09:30"
  time-zone="America/New_York"
  options="'apple','google','ical'"
  recurrence="weekly"
  recurrence-by-day="MO"
  recurrence-count="12"
></add-to-calendar-button>

5. Open the menu on click

<add-to-calendar-button
  name="Product Demo"
  start-date="2026-10-12"
  options="'google','outlookcom'"
  trigger="click"
></add-to-calendar-button>

6. Use your own trigger button

Use atcb_action() when your project needs a custom button or a programmatic trigger. JavaScript configuration objects use camelCase.

import { atcb_action } from 'add-to-calendar-button';
const config = {
  name: 'Launch Party',
  startDate: '2026-10-15',
  startTime: '18:00',
  endTime: '20:00',
  timeZone: 'America/Los_Angeles',
  options: ['google', 'ical']
};
const button = document.querySelector('#calendar-button');
button.addEventListener('click', () => atcb_action(config, button));

Full configuration options

Boolean HTML options can be written as bare attributes, such as inline or subscribe. The JavaScript configuration form uses camelCase equivalents.

Event parameters

AttributeType / DefaultDescription
nameString, requiredEvent title. It also acts as the series name for multi-date events.
descriptionStringEvent description. Pseudo tags such as [p], [strong], [br], lists, headings, and [url] are available.
start-dateString, YYYY-MM-DDStart date. Required unless dates or subscription mode supplies the date context.
start-timeString, HH:MMStart time. An event with no start/end times is treated as all-day.
end-dateString, YYYY-MM-DDEnd date. Defaults to the start date when omitted.
end-timeString, HH:MMEnd time.
time-zoneString, default GMTEvent time zone. currentBrowser uses the browser time zone.
use-user-tzBoolean, default falseConverts the event time and time zone to the visitor’s time zone.
locationStringEvent location or online-event URL.
statustentative, confirmed, cancelled; default confirmediCalendar event status.
sequenceNumber, default 0Positive event revision sequence.
availabilitybusy or freeOverrides calendar availability where the destination service honors it.
uidStringUnique ICS event ID. A random value is generated when omitted.
organizerString, NAME|EMAILOrganizer data for rich event data and generated ICS files.
attendeeString, NAME|EMAIL or emailOne attendee for event update workflows. An organizer is required when this option is used.
datesArray of objectsDefines a multi-date event series. Root-level values override matching values inside date entries, with documented exceptions for series names and UIDs.
recurrenceRRULE string or daily, weekly, monthly, yearlyDefines recurrence. Multi-date mode and recurrence cannot be used together. Recurrence can remove Yahoo, Microsoft, and Google-on-iOS destinations when those services cannot process the rule; iCal becomes the fallback when necessary.
recurrence-intervalNumber, default 1Interval between recurrence iterations.
recurrence-untilString, UTC timestampSets an end date for recurrence.
recurrence-countNumberMaximum number of recurrence instances.
recurrence-by-dayStringWeekday rule such as MO, WE,FR, or 3MO.
recurrence-by-month-dayStringNumbered monthly date rule.
recurrence-by-monthString, 1-12Month rule for yearly recurrence.
recurrence-weekstartWeekday code, default MOFirst weekday used by the recurrence rule.
subscribeBoolean, default falseChanges the button from a single event to a hosted calendar subscription. Set ics-file; name and start-date are retained for the subscription setup. Microsoft Teams and Yahoo are disabled for subscriptions.
ics-fileString URLUses an existing ICS file or hosted calendar and skips dynamic ICS generation.
ical-file-nameString, default event-to-save-in-my-calendarFile name used for generated ICS downloads.

ICS file parameters

These attributes affect generated Apple/iCal files.

AttributeType / ValuesDescription
ics-reminderString or numberReminder time in minutes before the event or an ISO 8601 duration.
ics-urlString URLCanonical event URL.
ics-categoriesString or arrayICS event categories.
ics-classpublic, private, confidentialICS event classification.
ics-priorityNumber 0-9ICS priority value.
ics-geolatitude,longitudeGeographic coordinates for the event.
ics-attachString or arrayOne or more HTTP(S) attachment URLs.
ics-exdateString or array, YYYY-MM-DDDates excluded from a recurring event. This option is root-only.
ics-createdUTC timestampStatic ICS creation timestamp. The generated-file time is used by default.
ics-updatedUTC timestampStatic ICS update timestamp. The generated-file time is used by default.

Layout and style parameters

AttributeType / DefaultDescription
optionsArrayCalendar destinations: apple, google, ical, ms365, msteams, outlookcom, yahoo.
options-mobileArrayCalendar destinations used on Android and other mobile devices.
options-iosArrayCalendar destinations used on iOS.
button-styleString, default defaultdefault, simple, 3d, flat, round, neumorphism, text, date, custom, or none.
inlineBoolean, default falseUses inline rendering for the button container.
custom-cssString URLExternal stylesheet used with button-style="custom". Custom CSS is not loaded during SSR.
style-sourceString URLBase URL for lazily loaded styles and locale assets in self-hosted browser builds.
load-all-stylesBoolean, default falsePrefetches all button style deltas for runtime style switching in script-tag integrations.
buttons-listBoolean, default falseRenders one button per calendar destination.
labelString, default Add to CalendarMain button text.
triggerhover or click; default hoverInteraction that opens the calendar list.
list-styleString, default dropdowndropdown, dropdown-static, dropup-static, overlay, or modal.
force-overlayBoolean, default falseRenders the dropdown and button above the surrounding layout.
hide-backgroundBoolean, default falseRemoves the list or modal background treatment.
hide-icon-buttonBoolean, default falseHides the main button icon.
hide-icon-listBoolean, default falseHides calendar list icons.
hide-icon-modalBoolean, default falseHides the info modal heading icon.
hide-text-label-buttonBoolean, default falseHides the main button text.
hide-text-label-listBoolean, default falseHides calendar list text.
hide-checkmarkBoolean, default falseDisables the saved-event checkmark where that indicator is active.
past-date-handlingnone, disable, hide; default noneControls non-recurring events after their date has passed.
sizeString, default 6|6|6Scale from 0 to 10, with optional large, medium, and small breakpoint values.
light-modesystem, dark, light, bodyScheme; default lightColor mode selection.
languageString, default enBuilt-in locale codes: ar, az, be, bg, bs, cs, da, de, el, en, es, et, fa, fi, fr, he, hi, hr, hu, hy, id, it, ja, ka, ko, lt, lv, mk, mt, nl, no, pl, pt, ro, ru, sk, sl, sq, sr, sv, tr, uk, vi, zh. Regional locale forms such as en_GB are accepted.
custom-labelsObjectOverrides built-in text labels.
style-lightStringCSS custom property overrides for the default/light scheme.
style-darkStringCSS custom property overrides for dark mode.

Additional parameters

AttributeType / DefaultDescription
imagesArrayImage URLs used in generated Schema.org event data.
hide-rich-dataBoolean, default falseDisables generated Schema.org event data.
identifierStringCustom unique identifier used in generated element and calendar-link IDs.
bypass-web-view-checkBoolean, default falseBypasses the iOS WebView workaround when the host app already handles ICS downloads correctly.
hide-brandingBoolean, default falseHides the project branding.
cspnonceStringNonce value applied to inline style and script tags for Content Security Policy setups.
instanceNumberIncrement this value to force the custom element to re-render.
pro-overrideBoolean, default falseLets local settings override matching Add to Calendar PRO settings.
debugBoolean, default falseReports configuration errors in the console and renders an error state.

PRO-only parameters

AttributeTypeDescription
prokeyStringConnects the element to an event managed through Add to Calendar PRO.
group-overviewBooleanShows a configured PRO event group as an event list.
group-overview-configObjectConfigures group layout and filtering through years-only, type, from, to, no-details, no-add, custom-domain, and add-via-list.

JavaScript API

FunctionDescription
atcb_action(config, triggerElement?)Opens calendar actions from a custom element or programmatic trigger.
atcb_register_locale(lang, strings)Registers a locale at runtime.
atcb_register_style(name, css)Registers a button style at runtime.
atcb_generate_ty(...)Public helper exported from the main package for PRO thank-you output.
atcb_generate_timestring(...)Formats decorated event dates into localized time strings.
atcb_decorate_data_dates(...)Normalizes and decorates event date data.

Public TypeScript types

TypeDescription
ATCBActionEventConfigConfiguration type used by the imperative action API.
AddToCalendarButtonTypePublic component configuration type.
EventDateEvent date entry type used by date-based configuration.
CustomLabelsObjectTypeType for custom label overrides.
GroupOverviewConfigType for PRO group overview configuration.
ATCBLanguagePublic locale type.

Server-side and worker entries

v3 includes dedicated exports for server-side rendering and DOM-free date utilities.

import { atcb_generate_ssr_html } from 'add-to-calendar-button/ssr';
import {
  atcb_decorate_data_dates,
  atcb_generate_timestring
} from 'add-to-calendar-button/utils';

Tracking events

Each component exposes its last interaction through atcb-last-event and pushes interaction records to the browser data layer.

  • initialization.
  • openList.
  • closeList.
  • openCalendarLink.
  • openSingletonLink.
  • openSubEventLink.
  • success.

Styling with CSS ::part

The component uses Shadow DOM. Use style-light/style-dark, a custom stylesheet, or these public ::part names for direct CSS styling:

  • atcb-button-wrapper.
  • atcb-button.
  • atcb-button-icon.
  • atcb-button-text.
  • atcb-list-wrapper.
  • atcb-list.
  • atcb-list-item.
  • atcb-list-item-close.
  • atcb-list-icon.
  • atcb-list-text.
  • atcb-modal-box.
add-to-calendar-button#event-button::part(atcb-button) {
  background: #222;
  color: #fff;
}

Important v2 to v3 migration notes

  • Change the browser CDN URL from @2 to @3.
  • Use official kebab-case HTML attributes such as start-date and button-style. JavaScript configuration objects use camelCase.
  • Use lowercase calendar option values: apple, google, ical, ms365, msteams, outlookcom, and yahoo.
  • Use lowercase event status values: tentative, confirmed, and cancelled.
  • Rename v2 created/updated to HTML ics-created/ics-updated or JavaScript icsCreated/icsUpdated. The old timestamp names are not read in v3.
  • npm projects need explicit imports for non-default styles and non-English locales.
  • Update renamed custom-labels keys when your integration overrides date.status.cancelled.cta, label.share.email.subject, label.rsvp, form.status, or form.success.
  • Review configured URLs. v3 rejects script-capable schemes such as javascript: and accepts only the documented URL schemes for calendar files, CSS, images, and event links.
  • Legacy no-pro, unstyle, and no-pro-unstyle entries are compatibility shims. New code should use the main package entry.
  • Full v3 behavior uses the Baseline 2023 browser floor, including Safari 16.4 and current evergreen browsers.

Alternatives and related resources

  • calendar-link generates calendar URLs and ICS output from JavaScript event objects when a prebuilt button component is not required.
  • Calendar.js is a full event calendar UI for displaying and managing events inside the page.

Changelog

v3.3.0 (10/01/2026)

  • Optimized rendering flows (incl. SSR hydration)

v3.2.0 (09/29/2026)

  • New option to import all styles and languages when using the npm package.

v3.1.2 (09/25/2026)

  • respect all kinds of custom labels for ssr

v3.1.1 (09/18/2026)

  • Fixing issues with the modal background

v3.1.0 (09/16/2026)

  • Fixed accessibility issues

v3.0.3 (09/14/2026)

  • Added iPadOS ics support

v3.0.2 (09/10/2026)

  • Bugfix

v3.0.1

  • Current v3 release used by the project documentation.
  • v3 standardizes the HTML API on kebab-case attributes and lowercase calendar/status values.
  • Dedicated SSR and DOM-free utility entries are available.
  • Non-default npm styles and locales use explicit imports.
  • New ICS-specific configuration is available for reminders, URLs, categories, classification, priority, geo data, attachments, excluded recurrence dates, and timestamps.

v2.15.0

  • Final v2 series used by the previous CSSScript article.

You Might Be Interested In:


Leave a Reply