Slider field
The slider field stores a numeric value and can be used as a substitute for the number field.
Examples
Here's an example of using the slider field in a block:
# blocks/Product.vue
<template>
<div :data-priority="priority">...</div>
</template>
<script lang="ts" setup>
import { sliderField } from '#pruvious'
defineProps({
priority: sliderField({
required: true,
max: 5,
default: 3,
marks: true,
input: false,
}),
})
</script>
Here is another example of how to use it in a collection definition:
# collections/products.ts
import { defineCollection } from '#pruvious'
export default defineCollection({
name: 'products',
mode: 'multi',
fields: {
priority: {
type: 'slider',
options: {
required: true,
max: 5,
default: 3,
marks: true,
input: false,
},
},
// ...
},
})
Options
You can specify the following options in the slider field:
Option | Description |
---|---|
| The default field value. By default, this is set to |
| A brief descriptive text displayed in code comments and in a tooltip at the upper right corner of the field. |
| Specifies whether to display an input field next to the slider. |
| The field label displayed in the UI. By default, it is automatically generated based on the property name assigned to the field. For example, maxGuests becomes Max guests. |
| Specifies whether to display the number intervals (steps) in the slider. Marks can be customized by passing an array of numbers. Defaults to |
| The maximum allowed number. Defaults to |
| The minimum allowed number. Defaults to |
| Specifies whether the field input is mandatory. The requirement check allows the value |
| Specifies the number intervals in the slider. Defaults to |
Last updated on January 8, 2024 at 19:55