Skip to content

Commit e6b6284

Browse files
committed
feat(VDivider): add content-offset prop
1 parent 8a6c279 commit e6b6284

File tree

5 files changed

+39
-2
lines changed

5 files changed

+39
-2
lines changed

packages/api-generator/src/locale/en/VDivider.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"props": {
3+
"contentOffset": "Increases content spacing from the lines. When passed as an array, the second value shifts slot content down (or right in vertical mode).",
34
"gradient": "Adds fading effect for both sides.",
45
"inset": "Adds indentation (72px) for **normal** dividers, reduces max height for **vertical**.",
56
"length": "Sets the dividers length. Default unit is px.",

packages/docs/src/data/new-in.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"VDivider": {
130130
"props": {
131131
"gradient": "3.11.0",
132+
"contentOffset": "3.11.0",
132133
"variant": "3.11.0"
133134
}
134135
},
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<template>
2+
<v-container class="d-flex flex-column gr-4">
3+
<v-divider content-offset="2rem" opacity=".7" thickness="5" variant="dotted" gradient>CHAPTER 1.4</v-divider>
4+
<v-divider :content-offset="[40, -1.5]" opacity=".7" thickness="2" variant="dashed">∞</v-divider>
5+
<v-divider :content-offset="[12, 2.5]" opacity=".7">* * *</v-divider>
6+
<v-divider color="primary" content-offset="-16" opacity="1" style="color: inherit" thickness="1">
7+
<v-avatar class="border border-primary border-opacity-100" icon="mdi-chevron-down" size="36"></v-avatar>
8+
</v-divider>
9+
</v-container>
10+
</template>

packages/docs/src/pages/en/components/dividers.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ Vertical dividers give you more tools for unique layouts.
6969

7070
By using the **thickness** prop, the thickness of the divider can be adjusted to the desired value.
7171

72+
### Slots
73+
74+
#### Default
75+
76+
When you pass any content to be placed in between dividers simply by utilizing the default slot.
77+
78+
<ExamplesExample file="v-divider/slot-default" />
79+
7280
### Misc
7381

7482
#### Portrait View

packages/vuetify/src/components/VDivider/VDivider.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { makeComponentProps } from '@/composables/component'
77
import { makeThemeProps, provideTheme } from '@/composables/theme'
88

99
// Utilities
10-
import { computed } from 'vue'
10+
import { computed, toRef } from 'vue'
1111
import { convertToUnit, genericComponent, propsFactory, useRender } from '@/util'
1212

1313
// Types
@@ -21,6 +21,7 @@ type Variant = typeof allowedVariants[number]
2121

2222
export const makeVDividerProps = propsFactory({
2323
color: String,
24+
contentOffset: [Number, String, Array] as PropType<number | string | (string | number)[]>,
2425
gradient: Boolean,
2526
inset: Boolean,
2627
length: [Number, String],
@@ -59,6 +60,19 @@ export const VDivider = genericComponent()({
5960
return styles
6061
})
6162

63+
const contentStyles = toRef(() => {
64+
const margin = Array.isArray(props.contentOffset) ? props.contentOffset[0] : props.contentOffset
65+
const shift = Array.isArray(props.contentOffset) ? props.contentOffset[1] : 0
66+
67+
return {
68+
marginBlock: props.vertical && margin ? convertToUnit(margin) : undefined,
69+
marginInline: !props.vertical && margin ? convertToUnit(margin) : undefined,
70+
transform: shift
71+
? `translate${props.vertical ? 'X' : 'Y'}(${convertToUnit(shift)})`
72+
: undefined,
73+
}
74+
})
75+
6276
useRender(() => {
6377
const divider = (
6478
<hr
@@ -104,7 +118,10 @@ export const VDivider = genericComponent()({
104118
>
105119
{ divider }
106120

107-
<div class="v-divider__content">
121+
<div
122+
class="v-divider__content"
123+
style={ contentStyles.value }
124+
>
108125
{ slots.default() }
109126
</div>
110127

0 commit comments

Comments
 (0)