Convert Figma logo to code with AI

mattlewis92 logoangular-calendar

A flexible calendar component for angular 15.0+ that can display events on a month, week or day view.

2,717
863
2,717
95

Top Related Projects

Full-sized drag & drop event calendar in JavaScript

Full-sized drag & drop JavaScript event calendar with resource & timeline views

A complete AngularJS directive for the Arshaw FullCalendar.

Angular powered Bootstrap

Quick Overview

Angular Calendar is a flexible and customizable calendar component for Angular applications. It provides a range of features for displaying and managing events, including day, week, and month views. The library is designed to be easily integrated into Angular projects and offers extensive customization options.

Pros

  • Highly customizable with numerous configuration options
  • Supports multiple calendar views (day, week, month)
  • Responsive design that works well on both desktop and mobile devices
  • Regular updates and active community support

Cons

  • Learning curve for advanced customizations
  • Large bundle size when including all features
  • Limited built-in internationalization support
  • Some users report performance issues with large datasets

Code Examples

  1. Basic calendar setup:
import { CalendarModule } from 'angular-calendar';

@NgModule({
  imports: [
    CalendarModule.forRoot()
  ]
})
export class MyModule {}
  1. Displaying a calendar with events:
<mwl-calendar-month-view
  [viewDate]="viewDate"
  [events]="events"
  (dayClicked)="dayClicked($event.day)">
</mwl-calendar-month-view>
  1. Customizing event colors:
events = [
  {
    start: new Date(),
    title: 'Custom event',
    color: {
      primary: '#ad2121',
      secondary: '#FAE3E3'
    }
  }
];

Getting Started

  1. Install the package:

    npm install angular-calendar
    
  2. Import the module in your app.module.ts:

    import { CalendarModule, DateAdapter } from 'angular-calendar';
    import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';
    
    @NgModule({
      imports: [
        CalendarModule.forRoot({
          provide: DateAdapter,
          useFactory: adapterFactory,
        })
      ]
    })
    export class AppModule {}
    
  3. Use the calendar component in your template:

    <mwl-calendar-month-view
      [viewDate]="viewDate"
      [events]="events">
    </mwl-calendar-month-view>
    
  4. Define the necessary properties in your component:

    viewDate: Date = new Date();
    events = [];
    

Competitor Comparisons

Full-sized drag & drop event calendar in JavaScript

Pros of FullCalendar

  • More comprehensive feature set, including support for various calendar views (month, week, day, list)
  • Framework-agnostic, can be used with any JavaScript framework or vanilla JS
  • Extensive documentation and large community support

Cons of FullCalendar

  • Steeper learning curve due to its extensive API and configuration options
  • Larger file size, which may impact page load times
  • Requires more setup and configuration for Angular integration

Code Comparison

FullCalendar (vanilla JS):

document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');
  var calendar = new FullCalendar.Calendar(calendarEl, {
    initialView: 'dayGridMonth'
  });
  calendar.render();
});

Angular Calendar:

import { CalendarModule, DateAdapter } from 'angular-calendar';
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';

@NgModule({
  imports: [
    CalendarModule.forRoot({ provide: DateAdapter, useFactory: adapterFactory })
  ]
})
export class MyModule {}

Both libraries offer powerful calendar functionality, but FullCalendar provides a more comprehensive solution at the cost of complexity, while Angular Calendar offers a more streamlined experience specifically tailored for Angular applications.

Full-sized drag & drop JavaScript event calendar with resource & timeline views

Pros of calendar

  • Lightweight and framework-agnostic, making it more versatile for different projects
  • Simpler API and easier to customize for basic calendar needs
  • Smaller bundle size, potentially leading to faster load times

Cons of calendar

  • Less feature-rich compared to angular-calendar's extensive functionality
  • Limited documentation and community support
  • Lacks built-in integrations with popular frameworks like Angular

Code Comparison

calendar:

const calendar = new Calendar({
  id: 'calendar',
  eventsData: [
    { start: '2023-05-01', end: '2023-05-03', title: 'Event 1' },
    { start: '2023-05-05', title: 'Event 2' }
  ]
});

angular-calendar:

import { CalendarEvent } from 'angular-calendar';

events: CalendarEvent[] = [
  { start: new Date('2023-05-01'), end: new Date('2023-05-03'), title: 'Event 1' },
  { start: new Date('2023-05-05'), title: 'Event 2' }
];

The code comparison shows that calendar uses a simpler JavaScript object approach, while angular-calendar leverages TypeScript and Angular-specific structures. angular-calendar's implementation is more type-safe and integrated with the Angular ecosystem, but calendar's approach is more straightforward for basic use cases.

A complete AngularJS directive for the Arshaw FullCalendar.

Pros of ui-calendar

  • Integrates with FullCalendar, providing a rich set of features and customization options
  • Supports multiple calendars within a single view
  • Has been around longer, potentially offering more stability and community support

Cons of ui-calendar

  • Less actively maintained, with fewer recent updates
  • May have compatibility issues with newer Angular versions
  • Requires jQuery as a dependency, which can increase bundle size

Code Comparison

ui-calendar:

<div ui-calendar="calendarOptions" ng-model="eventSources"></div>

angular-calendar:

<mwl-calendar
  [events]="events"
  [view]="view"
  [viewDate]="viewDate"
  (eventClicked)="handleEvent($event)">
</mwl-calendar>

Key Differences

  • angular-calendar is more modern and actively maintained
  • angular-calendar has better TypeScript support and Angular integration
  • ui-calendar relies on FullCalendar, while angular-calendar is a standalone implementation
  • angular-calendar offers a more flexible and customizable API
  • ui-calendar may be easier to set up for those familiar with FullCalendar

Both libraries have their strengths, but angular-calendar is generally recommended for newer Angular projects due to its better integration and ongoing development.

Angular powered Bootstrap

Pros of ng-bootstrap

  • Broader scope: Offers a comprehensive set of Bootstrap components for Angular
  • Larger community and more frequent updates
  • Official Angular adaptation of Bootstrap, ensuring better compatibility

Cons of ng-bootstrap

  • Steeper learning curve due to its extensive feature set
  • Potentially larger bundle size if not using tree-shaking

Code Comparison

ng-bootstrap (Datepicker example):

<ngb-datepicker #dp [(ngModel)]="model" (navigate)="date = $event.next"></ngb-datepicker>

angular-calendar (Calendar example):

<mwl-calendar-month-view
  [viewDate]="viewDate"
  [events]="events"
  (dayClicked)="dayClicked($event.day)">
</mwl-calendar-month-view>

Summary

ng-bootstrap is a more comprehensive UI component library for Angular, offering a wide range of Bootstrap components. It's suitable for projects requiring a full set of UI elements. angular-calendar, on the other hand, is specifically focused on calendar functionality, providing a more specialized and potentially easier-to-use solution for calendar-related features. The choice between the two depends on the project's specific needs and the desired balance between feature breadth and specialization.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

angular 15.0+ calendar

Sponsorship Build Status codecov npm version License: MIT Twitter Follow

Demo

Sponsors

Table of contents

About

A calendar component for angular 15.0+ that can display events on a month, week or day view. The successor of angular-bootstrap-calendar.

Getting started

ng add (recommended)

ng add angular-calendar

Manual setup (ng add will do this all for you)

First install through npm:

npm install --save angular-calendar date-fns

Next include the CSS file in the global (not component scoped) styles of your app:

/* angular-cli file: src/styles.css */
@import "../node_modules/angular-calendar/css/angular-calendar.css";

Finally import the calendar module into your apps module:

import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { CalendarModule, DateAdapter } from 'angular-calendar';
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';

@NgModule({
  imports: [
    BrowserAnimationsModule,
    CalendarModule.forRoot({
      provide: DateAdapter,
      useFactory: adapterFactory,
    }),
  ],
})
export class MyModule {}

In order to allow the most flexibility for all users there is a substantial amount of boilerplate required to get up and running. Please see the demos list for a series of comprehensive examples of how to use this library within your application.

Once you are up and running, to access a full list of options for each component, the individual APIs are documented here: mwl-calendar-month-view, mwl-calendar-week-view and mwl-calendar-day-view.

Please note: angular-calendar uses Scarf to collect anonymized installation analytics. These analytics help support the maintainers of this library. However, if you'd like to opt out, you can do so by setting scarfSettings.enabled = false in your project's package.json. Alternatively, you can set the environment variable SCARF_ANALYTICS=false before you install.

Documentation

To see all available API options, take a look at the auto generated documentation. You may find it helpful to view the examples on the demo page.

Breaking changes

Where possible this library will strictly adhere to semver and only introduce API breaking changes in 0.x releases or new major versions post 1.0. The only exception to this is if you are using custom templates or extending the base components to add additional functionality, whereby critical bug fixes may introduce breakages as the internal API changes.

FAQ

Is this library AoT and universal compatible?

Yes.

What major versions of angular does this library support?

Angular majorLast supported angular-calendar version
15.x and higherlatest version
14.x0.30.1
12.x - 13.x0.29.0
6.x - 11.x0.28.28
5.x0.24.1
4.x0.22.3
2.x0.9.1

No styles are appearing?

No component styles are included with each component to make it easier to override them (otherwise you’d have to use !important on every rule that you customised). Thus you need to import the CSS file separately from node_modules/angular-calendar/css/angular-calendar.css.

How come there are so many dependencies?

When building the calendar some parts were found to be reusable so they were split out into their own modules. Only the bare minimum that is required is included with the calendar, there is no extra code than if there were no dependencies. date-fns especially only imports directly the functions it needs and not the entire library.

The month, week or day view doesn’t meet my project requirements, but the other views do.

Build your own component to replace that view, and use it in place of the one this library provides. It’s impossible to provide a calendar component that meets everyones use cases, hopefully though at least some of the day / week / month view components provided can be customised with the calendars API enough to be of some use to most projects.

How come there’s no year view like the ng1 version?

As there are so many events to show on each month, it doesn’t provide a lot of value and is just an extra burden to maintain. There is nothing to stop someone from building a new lib like angular-calendar-year-view though ;)

Does this calendar work with mobile?

This library is not optimised for mobile. Due to the complex nature of a calendar component, it is non trivial to build a calendar that has a great UX on both desktop and mobile. It is recommended to build your own calendar component for mobile that has a dedicated UX. You may be able to get some degree of mobile support by setting some custom CSS rules for smaller screens on the month view and showing less days on the week view.

How do I use a custom template?

All parts of this calendar can be customised via the use of an ng-template. The recipe for applying one is as follows:

  • Find the template you would like to customise for the month, week or day view component. You can find all available custom templates by reading the documentation for each component. For this example we will pick the cellTemplate from the month view.
  • Next find the corresponding child component that will render the template by viewing the source. For our example of the month view cell it is this component
  • Now copy the template source for your chosen template into your own component and modify as your see fit.
  • Finally pass the template to the components input: <mwl-calendar-month-view [cellTemplate]="cellTemplateId" />
  • You can see an e2e working example of this here

What is the browser compatibility?

All evergreen browsers supported by angular.

Does this library require bootstrap?

No! While the demo site uses bootstrap, it isn't a requirement of this library. The styling is designed to adapt to whatever global styling your app has.

Angular 1 version

Development

Prepare your environment

Development server

Run pnpm start to start a development server on port 8000 with auto reload + tests.

Testing

Run pnpm test to run tests once or pnpm test:watch to continually run tests.

Release

  • Bump the version in package.json (once the module hits 1.0 this will become automatic)
pnpm release

NPM DownloadsLast 30 Days