Pete
Pete

Reputation: 58422

v-calendar datepicker highlight attributes not changing colour

I am using v-calendar datepicker on my site and it is working well, but I'm trying to restyle the colour of the circles using the highlight attribute, but nothing seems to be working:

new Vue({
  el: "#app",
  data() {
    return {
      attrs: [{
        highlight: {
          color: '#123123',
        },
        /*
        also tried:

        highlight: {
          start: { color: '#123123' },
          base: { color: '#123123' },
          end: { color: '#123123' },
        },
        
        also tried using a preset colour like 
        
        color: 'purple' 
        
        but that also does nothing
        */
      }],
      range: {
        start: null,
        end: null
      }
    };
  },
});
@import url 'https://unpkg.com/[email protected]/lib/v-calendar.min.css';
.filter__date-range-holder {
  display: flex;
  justify-content: space-between;
  width: 95%;
}

.filter__date-range-column {
  width: calc(50% - 15px);
}

.form__row {
  position: relative;
  margin: 1.5em 0;
  background: white;
}

.form__control {
  width: 100%;
  border: 1px solid grey;
  font-size: 1rem;
  line-height: 1.5rem;
  color: black;
  padding: 0.75em;
  background: transparent;
}

.invalid .form__control {
  border-color: red;
  outline-color: red;
}

.form__control:focus {
  border-radius: 0;
}
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/lib/v-calendar.umd.min.js"></script>
<div id='app'>
  <v-date-picker v-model="range" :popover="{ visibility: 'focus' }" :attributes="attrs" is-range>
    <template #default="{ inputValue, inputEvents }">
          <div class="filter__date-range-holder">
            <div class="filter__date-range-column">
              <div class="form__row filter__date-range-row">
                <label class="form__label filter__date-range-label" for="filter-date-from">From</label>
                <input id="filter-date-from" ref="filterDateForm" type="text" name="from" class="form__control form__control--textbox" :value="inputValue.start" v-on="inputEvents.start">
              </div>
            </div>
            <div class="filter__date-range-column">
              <div class="form__row filter__date-range-row">
                <label class="form__label filter__date-range-label" for="filter-date-to">To</label>
                <input id="filter-date-to" ref="filterDateTo" type="text" name="to" class="form__control form__control--textbox" :value="inputValue.end" v-on="inputEvents.start">
              </div>
            </div>
          </div>
        </template>
  </v-date-picker>
</div>

It always stays the default blue not matter what I do. Does anyone know what I'm doing wrong or how to change the colour of the circles so it isn't the default blue (preferably to a hex colour rather than one of their presets)?

Upvotes: 2

Views: 2076

Answers (2)

Paul_S
Paul_S

Reputation: 11

There are 8 pre-defined color sets available (gray, red, orange, yellow, green, teal, blue, indigo, purple, pink).

Their wording might be a bit off here since it makes you understand that you can define your own color, but does not specify in what format it should be. if you want to apply a "custom" color, you must do it with style or class.

Tailwind example:

highlight: {
  class: 'tw-bg-amber-500 tw-opacity-60',
},

style example:

highlight: {
  style: {
    background: '#f59e0b',
    opacity: 0.6,
  },
},

Upvotes: 1

Nikola Pavicevic
Nikola Pavicevic

Reputation: 23480

You can do it with css :

.vc-highlight {
  border-color: #123123 !important;
  background-color: #123123 !important;
}

new Vue({
  el: "#app",
  data() {
    return {
      attrs: [{
        highlight: {
          color: '#123123',
        },
        /*
        also tried:

        highlight: {
          start: { color: '#123123' },
          base: { color: '#123123' },
          end: { color: '#123123' },
        },
        
        also tried using a preset colour like 
        
        color: 'purple' 
        
        but that also does nothing
        */
      }],
      range: {
        start: null,
        end: null
      }
    };
  },
});
@import url 'https://unpkg.com/[email protected]/lib/v-calendar.min.css';
.filter__date-range-holder {
  display: flex;
  justify-content: space-between;
  width: 95%;
}

.filter__date-range-column {
  width: calc(50% - 15px);
}

.form__row {
  position: relative;
  margin: 1.5em 0;
  background: white;
}

.form__control {
  width: 100%;
  border: 1px solid grey;
  font-size: 1rem;
  line-height: 1.5rem;
  color: black;
  padding: 0.75em;
  background: transparent;
}

.invalid .form__control {
  border-color: red;
  outline-color: red;
}

.form__control:focus {
  border-radius: 0;
}

.vc-highlight {
  border-color: #123123 !important;
  background-color: #123123 !important;
}
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/[email protected]/lib/v-calendar.umd.min.js"></script>
<div id='app'>
  <v-date-picker v-model="range" :popover="{ visibility: 'focus' }" :attributes="attrs" is-range>
    <template #default="{ inputValue, inputEvents }">
          <div class="filter__date-range-holder">
            <div class="filter__date-range-column">
              <div class="form__row filter__date-range-row">
                <label class="form__label filter__date-range-label" for="filter-date-from">From</label>
                <input id="filter-date-from" ref="filterDateForm" type="text" name="from" class="form__control form__control--textbox" :value="inputValue.start" v-on="inputEvents.start">
              </div>
            </div>
            <div class="filter__date-range-column">
              <div class="form__row filter__date-range-row">
                <label class="form__label filter__date-range-label" for="filter-date-to">To</label>
                <input id="filter-date-to" ref="filterDateTo" type="text" name="to" class="form__control form__control--textbox" :value="inputValue.end" v-on="inputEvents.start">
              </div>
            </div>
          </div>
        </template>
  </v-date-picker>
</div>

Upvotes: 1

Related Questions