Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

add-to-calendar-button

add2cal118.9kELv22.8.1TypeScript support: included

A convenient JavaScript snippet, which lets you create beautiful buttons, where people can add events to their calendars.

react, javascript, css, microsoft, apple, google, angular, widget, generator, component, vue, calendar, event, vanilla-js, free, snippet, outlook, add-to-calendar, add-to-calendar-button, add-event

readme

Add to Calendar Button

Code Quality npm Installations Total npm Installations per Month jsDelivr npm Hits


Your next Add to Calendar Button

The convenient JavaScript Web Component, which lets you reliably create beautiful buttons, where people can add events to their calendars.

#1 Product of the Day on ProductHunt



For everybody, who wants to include a button at their website or app, which enables users to easily add a specific event to their calendars. It's main goal is to keep this process as easy as possible at maximum compatibility. Simply define your button configuration and everything else is automatically generated by the script. Supporting calendars at Apple, Google, Microsoft (365, Outlook, Teams), Yahoo, and generic iCal.

Supported Calendars: Apple (via iCal), Google, Microsoft (365, Outlook, Teams), Yahoo, generic iCal

The script, since it is a web component, integrates easily with any usual HTML webpage (VanillaJS way) as well as popular JavaScript frameworks and libraries like Angular, React, Vue, Svelte, and more.

Supported Technology: Angular, React, Vue, Svelte, and every other project that can load JavaScript

Works with all modern browsers (Chrome, Edge, Firefox, Safari) on Windows, Mac, Android, and iOS as well as rather restricted webview environments like the Instagram in-app browser.





▶️ Demo

See add-to-calendar-button.com for a live demo and playground.




✨ Features

Simple and convenient integration of 1 or many buttons, configurable directly within the HTML code.

Supported Calendars

  • Google Calendar.
  • Apple Calendar.
  • Yahoo Calender.
  • Microsoft 365, Outlook, and Teams.
  • Automatically generated iCal/ics files (for all other calendars and cases).

Event Types

  • Timed and all-day events.
  • One-time, multi-date, recurring.
  • Calendar subscription.
  • Most robust time zone and daylight saving management (via our own TimeZones iCal Library).
  • Dynamic dates (like "today + 3").

Look

  • Beautiful and adjustable UI.
  • Light and dark mode.
  • Multiple themes.

Accessibility

  • Optimized and adjustable UX (for desktop and mobile).
  • Dynamic dropdown positioning.
  • Taking care of all those edge cases, where some scenarios do not support specific setups (like WebView blocking downloads); utilizing beautiful user guidance workarounds.
  • Auto-generated Schema.org rich (structured) data for better SEO.
  • Full support for mouse, touch, or keyboard input (W3C WAI compliant).
  • Supporting 20+ languages, incl. RTL text for Arabic & Persian; but also custom labels and text blocks (i18n).

And much more

  • Well documented code, to easily understand the processes and build on top of it.
  • No external service or backend dependencies.
  • Fully GDPR, CCPA, and LGPD compliant by design - without the need of signing some data processing agreement.
  • FREE and easy.



🚀 Go PRO

  • ics file generation and hosting for better compatibility.
  • RSVP, incl. automatic updates sent to attendees, GDPR features, and more.
  • More customization - all no-code.
  • API, webhooks, and more technical toys.
  • Share events among all kinds of channels - email, social media, ...

Check the details at add-to-calendar-pro.com!




📦 Installation / Setup

Option 1: simple (CDN)

You can use the jsDelivr CDN and load the respective script directly into your website.

Place the script tag inside the <head> section.

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

Option 2: npm

Install the package using the following npm command:

npm install add-to-calendar-button

Import the module into your project/component

import 'add-to-calendar-button';

Based on your framework/library, you might need to make minor adjustments to the respective config.

Find detailed installation guides for the most common ones, like React, Angular, Vue, Svelte, or Astro at add-to-calendar-button.com/#installation.




🎛️ Configuration

A button can be easily created by using the respective custom element.

<add-to-calendar-button></add-to-calendar-button>
<!-- OR simply ... -->
<add-to-calendar-button />

You can then configure the button by simply adding the options as attributes to it. Boolean values (true/false) can be set as optionName="true" or simply by adding optionName to the tag. Not setting it at all would be automatically translate to "false".


Structure (PRO)

<add-to-calendar-button proKey="prokey-of-your-event" />

Minimal structure (no PRO)

Mind that for auto-generating rich snippets, a location would be mandatory as well.

Calendar type options and time zone information are not required, but recommended.

<add-to-calendar-button
  name="Add the title of your event"
  startDate="2022-02-21"
  options="['Google']"
  timeZone="America/Los_Angeles"
/>

A more powerful example (no PRO)

<add-to-calendar-button
  name="Add the title of your event"
  description="A nice description does not hurt"
  startDate="2022-02-21"
  endDate="2022-03-24"
  startTime="10:13"
  endTime="17:57"
  location="Somewhere over the rainbow"
  options="['Apple','Google','iCal','Microsoft365','Outlook.com','Yahoo']"
  timeZone="Europe/Berlin"
  trigger="click"
  inline
  listStyle="modal"
  iCalFileName="Reminder-Event"
/>



More ExamplesFull Configuration DocumentationPRO Version




🤗 Support it!

You like this project? It would be awesome if you would support it, so it lives on!

  • Star the repository in order to stay up-to-date and save it for later!
  • 📣 Spread the word! On Twitter/X, Medium, Discord, Facebook, ...
  • ✍️ Leave a review at ProductHunt.
  • 💌 Send us some positive feedback at the discussion board.



⚡ Changelog

npm Version Build Status

Find all changes in the dedicated file at CHANGELOG.md.



🙌 Contributing

Anyone is welcome to contribute, but mind the guidelines:

IMPORTANT NOTE: Run npm install and npm run format to auto-lint!



Copyright (c) Jens Kuerschner.

Licensed under Elastic License 2.0 (ELv2).

About open-source: We consider ourselves open-source. However, we are also aware of the controversy coming with licenses like the one selected. Therefore, and contrary to many other companies and products, we no longer use the term in any marketing statements unless it is about other pieces which really are under an official OSI license.

Speaking about the license: We love it, because it is so simple. Have a look! You are basically free to do anything unless you are not offering the tool itself as a product or service; or want to remove copyright and license stuff. In doubt, simply ask and we find a way. :)




💜 Kudos go to

...all amazing contributors:


changelog

⚡ Changelog (without patches)

Version 2

  • v2.8 : Ukranian language
  • v2.7 : Showing open seats on RSVP, better subscription handling
  • v2.6 : useUserTZ, css ::part, formatting of urls in description
  • v2.5 : PRO option and more
    • introducing PRO offering
    • ⚠️ Breaking: default branding activated in order to support this free open source project (if you do not want to support this project, use the hideBranding option to disable it)
    • ⚠️ Breaking: if you want to customize calendar option labels, you need need to do this via the customLabels option
    • ⚠️ Breaking: some inline style got moved to the css. If you use your own custom css, double-check
    • new optionsMobile und optionsIOS options to specify device-specific calendar types
    • more css var options and subtle style fixes
    • bundle-size optimization option
    • attendee optimization
    • a lot of fixes
  • v2.4 : forceOverlay, fixes
  • v2.3 : pastDateHandling, disable option, static-dropup listStyle option, date style optimized, buttonsList optimized, better iOS support, new languages
  • v2.2 : "attendee" option, lazy external css loading, fixes
  • v2.1 : Romanian language support and a bunch of fixes
  • v2.0 : "all" new version 2
    • now a universally usable web component, working basically plug and play at almost all frontend stacks
    • more customization (hide/show all parts individually) and easy styling (no longer necessary to include the css file manually)
    • updates automatically when you change any attributes
    • a lot of bug fixes and performance improvement
    • prepared for better tracking
    • full code refactoring
    • new demo page with live playground
    • using attributes instead of the innerContent JSON structure. Latter one is still supported, but not with to the full degree of the new version
    • new license: ELv2
    • potential breaks:
      • backwards compatibility for old schema.org support (< v1.10) and parameter names prior v1.4 are no longer supported
      • some rather rarely used parameters have changed (name and direction):
        • background -> hideBackground
        • checkmark -> hideCheckmark
        • richData -> hideRichData

Version 1

  • v1.18 : multi-date functionality, subscription support, busy/free option, style updates, code refactoring, timezone database update
  • v1.17 : new license (Apache-2.0 with “Commons Clause”)
  • v1.16 : custom sequence, UID, and status support; bundle size optimization
  • v1.15 : more stable time zone management via the TimeZones iCal Library, more languages, easier recurrence, better schema.org support, organizer and image information
  • v1.14 : dynamical dropdown/up, adjustable size
  • v1.13 : dark mode
  • v1.12 : style updates, sanitization, webView edge case support, text block overwrite option, change of repo ownership
  • v1.11 : 1-option support, static ics support, instagram browser support, multi-lang, hide background option, recurring events, and more
  • v1.10 : auto-generating schema.org and dropping support for its input
  • v1.9 : big code style update + linter setup
  • v1.8 : new button style
  • v1.7 : new code structure and options + tons of optimizations
  • v1.6 : supporting Microsoft Teams
  • v1.5 : update to date format and better accesibility
  • v1.4 : schema.org support (also changed some keys in the JSON!)
  • v1.3 : new license (MIT with “Commons Clause”)
  • v1.2 : inline and line break support
  • v1.1 : npm functionality
  • v1.0 : initial release