javascriptfullcalendarfullcalendar-5

fullcalendar edit headerToolbar title


I have a simple fullcalendar, it has buttons in the headerToolbar

The question is, how can I change the titles in these buttons?

enter image description here enter image description here

Let's say that instead of month view it was just month, and instead of Next day, just Next.

document.addEventListener('DOMContentLoaded', function() {
  var calendarEl = document.getElementById('calendar');

  var calendar = new FullCalendar.Calendar(calendarEl, {
    timeZone: 'UTC',
    headerToolbar: {
      left: 'today prev,next',
      center: 'title',
      right: 'resourceTimelineDay,resourceTimelineMonth,resourceTimelineYear'
    },
    initialView: 'resourceTimelineDay',
    scrollTime: '08:00',
    aspectRatio: 1.5,
    editable: true,
    resourceAreaHeaderContent: 'Rooms',
    resources: 'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
    events: 'https://fullcalendar.io/api/demo-feeds/events.json?single-day&for-resource-timeline'
  });

  calendar.render();
});
html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}

#calendar {
  max-width: 1100px;
  margin: 40px auto;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/main.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/main.min.js"></script>
<div id='calendar'></div>


Solution

  • The aria-labelled or title values in full calendar are described as hints, in this example to add hints to prev , next button with the help of a option buttonHints. so just have to add it as a calendarOption to your code.

    in your example add change code as following

    document.addEventListener('DOMContentLoaded', function() {
      var calendarEl = document.getElementById('calendar');
    
      var calendar = new FullCalendar.Calendar(calendarEl, {
        timeZone: 'UTC',
        headerToolbar: {
          left: 'today prev,next',
          center: 'title',
          right: 'resourceTimelineDay,resourceTimelineMonth,resourceTimelineYear'
        },
        initialView: 'resourceTimelineDay',
        scrollTime: '08:00',
        aspectRatio: 1.5,
        editable: true,
        resourceAreaHeaderContent: 'Rooms',
        resources: 'https://fullcalendar.io/api/demo-feeds/resources.json?with-nesting&with-colors',
        events: 'https://fullcalendar.io/api/demo-feeds/events.json?single-day&for-resource-timeline',
        buttonHints: {
           next: 'next label',
           prev: 'prev label',
           month: 'month',
           day: 'day',
           week: 'week'
        }
      });
    
      calendar.render();
    });
    

    and change the values next label and prev label as you like ..

    also adding a codepen working link here.

    PS: Also updated with day, week, month navigation's labels.

    Hope it works :)