Tips for customizing the appearance of date circles and text in Vue V-Calendar.io

On v-calendar.io, there is a demo showcasing the correct display where the date "2018-01-01" has a red background and dark text:


However, my display does not match that.

I have included Vue.js and v-calendar through CDN, and the page is formatted in HTML.

Here is the full code snippet:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vuejs calendar</title>
</head>
<body>
    <div id='app'>
      <v-calendar :attributes='attrs'>
      </v-calendar>
    </div>
    <!-- 1. Link Vue Javascript -->
    <script src='https://unpkg.com/vue/dist/vue.js'></script>
    <!-- 2. Link VCalendar Javascript (Plugin automatically installed) -->
    <script src='https://unpkg.com/v-calendar'></script>
    <!--3. Create the Vue instance-->
    <script>
      new Vue({
        el: '#app',
        data() {
          return {
            attrs: [
              {
                key: 'today',
                highlight: {
                  backgroundColor: '#ff8080',
                },
                // Just use a normal style
                contentStyle: {
                  color: '#fafafa',
                },
                dates: new Date(2018, 0, 1)
              },
            ],
          };
        },
      })
    </script>
  </body>
</html>

Answer №1

If you want maximum control over the style, consider using style/contentStyle or class/contentClass.

style/contentStyle

style is used for circle styles and contentStyle is used for text styles.

highlight: {
  style: {                     // Circle styles
    background: '#ff8080'
  },
  contentStyle: {              // Text styles
    color: 'black'
  }
}

class/contentClass

class and contentClass function similarly, but instead of inline styles, you create classes.

highlight: {
  class: 'date-circle',        // Circle class
  contentClass: 'date-text',   // Text class
}

CSS

.date-circle {
  background: #ff8080;
}
.date-text {
  color: black;
}

See a demonstration below:

new Vue({
  el: '#app',
  data() {
    return {
      attrs: [
        {
          highlight: {
            style: {
              background: '#ff8080'
            },
            contentStyle: {
              color: 'black'
            }
          },
          dates: new Date(2018, 0, 1)
        },
        {
          highlight: {
            class: 'date-circle',
            contentClass: 'date-text',
          },
          dates: new Date(2018, 0, 8)
        },
      ],
    };
  },
})
.date-circle {
  background: #ff8080;
}
.date-text {
  color: black;
}
<div id="app">
  <v-calendar
    :attributes="attrs"
    :from-page="{ month: 1, year: 2018 }">
  </v-calendar>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.7.10/vue.min.js"></script>
<script src="https://unpkg.com/v-calendar"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

My node.js and express application is encountering an issue where it is failing with an error indicating that a variable has not been

Currently in the process of understanding how node.js and express operate. I've successfully extracted data from my mongo database... and now I'm experimenting with transferring data between my router code and views. The locations.js file within ...

Struggling to make the JavaScript addition operator function properly

I have a button that I want to increase the data attribute by 5 every time it is clicked. However, I am struggling to achieve this and have tried multiple approaches without success. var i = 5; $(this).attr('data-count', ++i); Unfortunately, th ...

Ways to identify the current version of webpack installed

Currently in the process of utilizing Webpack to transpile and bundle multiple JS files. I am curious about determining the specific version that I am using. In this scenario, assuming that it is globally installed, how can I identify the version without ...

Remove a particular row from a database table

I'm facing an issue with my code. I want to be able to remove a row by clicking on a remove button within that row, but I'm unsure of how to accomplish this. <tbody id="myTable"> <?php if (!isset($_SESSION)){ ...

Converting long date format to short date format: yyyy-mm-dd

Is there a way to convert the long date format from "Sat Dec 13 2014 06:00:00 GMT+0600" to "2014-12-13" in yyyy-mm-dd format? <script> function myDate(val) { var now = new Date("<?php echo $Cnextdue;?>"); now.setDate(now.getDate() + 30*val); ...

The premature firing of the fireContentLoadedEvent in Internet Explorer is causing issues

I've encountered a strange issue with IE8 recently. My code has been functioning properly for a while and still works perfectly in Firefox, but all of a sudden Prototype has stopped calling my event listeners for dom:loaded. I typically attach them u ...

Exploring the JSON Structure in NodeJS

My current json array is structured in the following way: [{"id": 1, "meeting": "1/3/2015 12:30:00 PM", "name": "John"}, {"id": 1, "meeting": "1/3/2015 13:30:00 PM"}, "name": "John"}, {"id": 2, "meeting": "1/5/2015 7:00:00 AM"}, "name": "Peter"}, {"id": 2 ...

Troublesome glitches in jQuery?

I'm having an issue with the following code: var buggy_brand_name = ['Baby Jogger', 'Babyzen', 'Bugaboo', 'GB', 'Icandy', 'Joie', 'Maclaren', 'Mamas&Papas', 'Ma ...

Will the script src onclick change have an effect after the page is fully loaded?

Imagine you have a script that loads right away when a page loads. Now, what happens if the script src changes when you click on a button? Will the new src get executed? Here is some example code: <button> click </button> <script class=" ...

Scrollbar generation causing spacing issues in Internet Explorer

So I've been working on implementing a scrollable div with a specific code overflow: auto; However, for some reason, when viewed in Internet Explorer, the scroll creates an unexpected margin on the right side. It functions properly on both Chrome an ...

The footer is not displaying at the bottom of the page in Firefox

While the footer design is functioning well in both Chrome and IE, it seems to be encountering issues with Firefox. div.footer{ width: 100%; padding: 0px; margin-top: 200px; font-size: 0.6em; line-height: 1.2em; clear: both; po ...

Automatically resizing images in a canvas when their resolution exceeds the canvas size in HTML5

I am currently using Html5, fabric.js, and JavaScript to upload multiple images to a canvas. However, there are instances where the uploaded image size exceeds that of the canvas. I am looking for a way to ensure that the image is set to a fixed size. v ...

Struggling with AngularJs as I attempt to retrieve my Twitter timeline. It's been a challenge

Currently, I am using the code below to fetch tweets for a timeline. This snippet was originally taken from an AngularJS tutorial and worked perfectly with Twitter's search API. angular.module( 'Twitter', [ 'ngResource' ]); func ...

Using Angular to retrieve JSON data from a static file

Currently, I am attempting to implement this AngularJS example from a tutorial on Login Tutorial Example. Instead of storing the username and password as simple strings, I am trying to retrieve them from a local file. I understand that this may not be the ...

Is it possible to send cookies from Laravel to a different domain following an Ajax request?

Currently, I am delving into the world of Laravel passport package and embarking on creating a Single Page Application (SPA) using Vue.js to put it to the test. However, an issue has crossed my mind regarding saving the Token in the client browser. If I we ...

Issues encountered when dealing with floating elements and margins

Having some difficulties with aligning elements on my website. As someone who is not highly skilled in coding, I am struggling to define the width and float properties for certain classes. Despite my attempts, it seems that the elements are not positioning ...

The serialize() method in Ajax is not capturing all the data fields from an HTML form

Attempting to use the jQuery get() method to send form data from my website, I encountered an issue where only a few of the field data were actually transmitted to the server upon form submission. The Form: <form class="form-horizontal" id="addpost" ...

Adjust the left and right margins while maintaining the vertical margin spacing

Is there a way to apply horizontal margin while inheriting vertical margin without explicitly setting margin-left and margin-right? I was hoping for something like margin: inherit 20px; to be effective. Take a look at the example here: https://jsfiddle.ne ...

Violation of Content Security Policy directive has occurred

During my full-stack project development, I encountered an issue with the inclusion of the bundle.js file in my base HTML file using a simple script tag. When trying to render the page and utilize the JS functionality, I faced a content security policy vio ...

Updating a table in Javascript after deleting a specific row

Is there a way to automatically reindex rows in a table after deleting a row? For example, if I delete row 1, can the remaining rows be reordered so that they are numbered sequentially? function reindexRows(tableID) { try { var t ...