Skip to content

Commit 359a115

Browse files
committed
feat(VList): add prependSpacer prop
1 parent 8c5a2b9 commit 359a115

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"inactive": "If set, the list tile will not be rendered as a link even if it has to/href prop or @click handler.",
66
"lines": "Designates a **minimum-height** for all children `v-list-item` components. This prop uses [line-clamp](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp) and is not supported in all browsers.",
77
"link": "Applies `v-list-item` hover styles. Useful when using the item is an _activator_.",
8+
"prependSpacer": "Defines the gap between the prepend element and the element that follows it.",
89
"nav": "An alternative styling that reduces `v-list-item` width and rounds the corners. Typically used with **[v-navigation-drawer](/components/navigation-drawers)**.",
910
"subheader": "Removes the top padding from `v-list-subheader` components. When used as a **String**, renders a subheader for you.",
1011
"slim": "Reduces horizontal spacing for badges, icons, tooltips, and avatars within slim list items to create a more compact visual representation.",

packages/vuetify/src/components/VList/VList.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { makeThemeProps, provideTheme } from '@/composables/theme'
2121
import { makeVariantProps } from '@/composables/variant'
2222

2323
// Utilities
24-
import { computed, ref, shallowRef, toRef } from 'vue'
25-
import { EventProp, focusChild, genericComponent, getPropertyFromItem, omit, propsFactory, useRender } from '@/util'
24+
import { computed, ref, shallowRef, toRef, watch } from 'vue'
25+
import { convertToUnit, EventProp, focusChild, genericComponent, getPropertyFromItem, omit, propsFactory, useRender } from '@/util'
2626

2727
// Types
2828
import type { PropType } from 'vue'
@@ -92,6 +92,7 @@ export const makeVListProps = propsFactory({
9292
type: [Boolean, String] as PropType<'one' | 'two' | 'three' | false>,
9393
default: 'one',
9494
},
95+
prependSpacer: [Number, String],
9596
slim: Boolean,
9697
nav: Boolean,
9798

@@ -239,6 +240,14 @@ export const VList = genericComponent<new <
239240
}
240241
}
241242

243+
watch([contentRef, () => props.prependSpacer], () => {
244+
if (contentRef.value && props.prependSpacer) {
245+
const width = convertToUnit(props.prependSpacer)
246+
247+
if (width) contentRef.value.style.setProperty('--v-list-prepend-spacer-width', width)
248+
}
249+
}, { immediate: true })
250+
242251
useRender(() => {
243252
return (
244253
<props.tag

packages/vuetify/src/components/VList/VListItem.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
> .v-icon,
7979
> .v-tooltip
8080
~ .v-list-item__spacer
81-
width: $list-item-icon-margin-start
81+
width: var(--v-list-prepend-spacer-width, $list-item-icon-margin-start)
8282

8383
> .v-avatar ~ .v-list-item__spacer
8484
width: $list-item-avatar-margin-start

0 commit comments

Comments
 (0)