-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(VDatePicker): pass through slots for day, week, month to sub components #21121
base: dev
Are you sure you want to change the base?
feat(VDatePicker): pass through slots for day, week, month to sub components #21121
Conversation
There's already a slot for this: <template #day="{ item, props }">
<v-btn
v-bind="props"
:class="{ 'custom-class': item.date.getDay() % 2 == 0 }"
/>
</template> |
@KaelWD Ah, i missed that. Currently though the VDatePicker does not pass slots through to the VDatePickerMonth. Would a pull request including a change like the following (where slots are passed through) be accepted? luukvnes@d09c303#diff-e52a094feb57d0b046a8b9c49e5b4870078f419377cccff97ad7bac766cd09ab Obviously this is missing type declarations and documentions, but as an idea |
Ok yeah that should definitely be forwarded. |
<template>
<v-app>
<v-container>
<v-date-picker>
<template #day="{ item, props }">
<v-btn
v-bind="props"
:class="{ 'custom-class': item.date.getDay() % 2 == 0 }"
/>
</template>
<template #month="{ month, props }">
<v-btn
v-bind="props"
:class="{ 'custom-class': month.text == 'Jan' }"
>
{{ month.text }}
</v-btn>
</template>
<template #year="{ year, props }">
<v-btn
v-bind="props"
:class="{ 'custom-class': year.text == '2022' }"
/>
</template>
</v-date-picker>
</v-container>
</v-app>
</template>
<script>
export default {
name: 'Playground',
setup () {
return {
//
}
},
}
</script>
<style>
.custom-class {
border: 1px red solid;
}
</style>
|
Description |
cb06ca9
to
83c0d3a
Compare
Description
This change adds a new dateClass prop to the VDatePicker and VDateInput components, allowing for custom styling of individual dates in the calendar.
The dateClass prop takes a function that takes a date and returns an array of classes. These classes are added to the dates in the calender.
My particular usecase is that i want to add a red border around particular days to signify an error happening on that day. Currently the easiest way is to use document.queryselector, this is particularly a nuisance, because you have to reapply the styling anytime the component switches to the view with single dates (not months/years).
Markup: