1.0.0 • Published 16 days ago

vue-material-time-picker v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
16 days ago

🚀 Installation

Install using your package manager of choice:

yarn add vue-material-time-picker

📺 Demo

https://matija-components.vercel.app/time-picker

⚙️ Usage

Import the component locally or define it globally and include the css file:

<template>
  <div style="display: flex">
    <time-picker v-model="time" use-seconds />
    {{ time }}
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { TimePicker } from "vue-material-time-picker";
import "vue-material-time-picker/dist/style.css";
const time = ref(null);
</script>

📃 Props

NameTypeDefaultDescription
v-modelstring/DatenullStandard two way input, HH:mm:ss format or Date
disabledbooleanfalseMakes the component uninteractable
readonlybooleanfalseMakes the component uninteractable, but without the style of the disabled variant
use-secondsbooleanfalseAdds an additional step for picking the time
automaticbooleantrueAutomatically switches to the next step when picking the time
hide-titlebooleanfalseHides the time picker title
widthnumber/string290pxSets the width of the element - can be provided as a string like "290px" or "290" or a number, defaults to 290px
full-widthbooleanfalseIgnores the previous width prop and sets the width to 100% of the parent container
colorstring#3ba13bColor of the time picker title and clock hand as well as any active element

🎺 Events

NameTypeDescription
select:hour(value: number) => voidTriggered when the hour value is selected
select:minute(value: number) => voidTriggered when the minute value is selected
select:second(value: number) => voidTriggered when the second value is selected
click:hour() => voidTriggered when the hour notation is clicked on the header
click:minute() => voidTriggered when the minute notation is clicked on the header
click:second() => voidTriggered when the second notation is clicked on the header
change(time: string) => voidTriggered when the full value is selected

🧩 Slots

header

Use this slot if you want to override the time picker header, an example being:

<time-picker v-model="time" use-seconds>
  <template
    #header="{
      hours,
      minutes,
      seconds,
      selectHours,
      selectMinutes,
      selectSeconds
    }"
  >
    <button @click="selectHours">
      {{ hours || "--" }}
    </button>
    <button @click="selectMinutes">
      {{ minutes || "--" }}
    </button>
    <button @click="selectSeconds">
      {{ seconds || "--" }}
    </button>
  </template>
</time-picker>

There are a few props being exposed:

NameTypeDefaultDescription
hoursnumber/nullnullHour portion of the time
minutesnumber/nullnullMinute portion of the time
secondsnumber/nullnullSeconds portion of the time
selectHoursfunctionN/AHelper function used for triggering the selection of the hours
selectMinutesfunctionN/AHelper function used for triggering the selection of the minutes
selectSecondsfunctionN/AHelper function used for triggering the selection of the seconds
1.0.0

16 days ago

0.0.8

7 months ago

0.0.5

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago