Skip to content

Commit cd7b8ca

Browse files
authored
feat(VExpansionPanels): add more props for customization (#22723)
resolves #21616 closes #12039
1 parent e7b5906 commit cd7b8ca

6 files changed

Lines changed: 60 additions & 17 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
"props": {
33
"focusable": "Makes the expansion-panel headers focusable.",
44
"flat": "Removes the expansion-panel's elevation and borders.",
5+
"gap": "Sets the gap between panels. Hides the divider automatically.",
56
"modelValue": "Controls expanded panel(s). Defaults to an empty array when using **multiple** prop. It is recommended to set unique `value` prop for the panels inside, otherwise index is used instead.",
7+
"noDivider": "Hides the dividers between adjacent panels.",
68
"readonly": "Makes the entire expansion panel read only.",
7-
"static": "Remove title size expansion when selected.",
8-
"tile": "Removes the border-radius."
9+
"rounded": "Applies a border radius to the first and last panel. Since v4.1.0 accepts array of two values to customize inner radius.",
10+
"static": "Remove title size expansion when selected."
911
},
1012
"exposed": {
1113
"prev": "Open the previous panel from the currently selected panel.",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@
185185
},
186186
"VExpansionPanels": {
187187
"props": {
188-
"static": "3.4.0"
188+
"static": "3.4.0",
189+
"gap": "4.1.0",
190+
"noDivider": "4.1.0"
189191
}
190192
},
191193
"VField": {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<v-container>
3+
<v-expansion-panels
4+
:rounded="[20, 8]"
5+
gap="8"
6+
variant="accordion"
7+
static
8+
>
9+
<v-expansion-panel
10+
v-for="i in 3"
11+
:key="i"
12+
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
13+
title="Item"
14+
></v-expansion-panel>
15+
</v-expansion-panels>
16+
</v-container>
17+
</template>

packages/docs/src/pages/en/components/expansion-panels.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ There are four different variants of the expansion-panel. Accordion expansion-pa
5050

5151
<ExamplesExample file="v-expansion-panels/prop-variant" />
5252

53+
#### Gap
54+
55+
Use **gap** to add spacing between accordion panels. Can be combined with `:rounded="[outerRadius, innerRadius]"` to adjust the panels corner rounding.
56+
57+
<ExamplesExample file="v-expansion-panels/prop-rounded-gap" />
58+
5359
#### Disabled
5460

5561
Both the expansion-panel and its content can be disabled using the **disabled** prop.

packages/vuetify/src/components/VExpansionPanel/VExpansionPanel.sass

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,28 @@
5656
border-top-right-radius: inherit
5757

5858
> :not(:first-child):not(.v-expansion-panel--after-active):not(.v-expansion-panel--active)
59-
border-top-left-radius: 0
60-
border-top-right-radius: 0
59+
border-top-left-radius: var(--v-expansion-panels-inner-radius, 0)
60+
border-top-right-radius: var(--v-expansion-panels-inner-radius, 0)
6161

6262
> :not(:last-child):not(.v-expansion-panel--before-active):not(.v-expansion-panel--active)
63-
border-bottom-left-radius: 0
64-
border-bottom-right-radius: 0
63+
border-bottom-left-radius: var(--v-expansion-panels-inner-radius, 0)
64+
border-bottom-right-radius: var(--v-expansion-panels-inner-radius, 0)
6565

6666
&--variant-accordion
6767
> :first-child:not(:last-child)
68-
border-bottom-left-radius: 0
69-
border-bottom-right-radius: 0
68+
border-bottom-left-radius: var(--v-expansion-panels-inner-radius, 0)
69+
border-bottom-right-radius: var(--v-expansion-panels-inner-radius, 0)
7070

7171
> :last-child:not(:first-child)
72-
border-top-left-radius: 0
73-
border-top-right-radius: 0
72+
border-top-left-radius: var(--v-expansion-panels-inner-radius, 0)
73+
border-top-right-radius: var(--v-expansion-panels-inner-radius, 0)
7474

7575
.v-expansion-panel-title--active
7676
border-bottom-left-radius: initial
7777
border-bottom-right-radius: initial
7878

7979
> :not(:first-child):not(:last-child)
80-
border-radius: 0
80+
border-radius: var(--v-expansion-panels-inner-radius, 0)
8181

8282
&--variant-accordion
8383
.v-expansion-panel-title__overlay
@@ -150,7 +150,8 @@
150150
justify-content: space-between
151151

152152
@media (prefers-reduced-motion: no-preference)
153-
transition: .3s min-height settings.$standard-easing
153+
transition: .3s settings.$standard-easing
154+
transition-property: min-height, border-radius
154155

155156
@include tools.states('.v-expansion-panel-title__overlay', false)
156157

@@ -180,6 +181,10 @@
180181

181182
// Variants
182183
.v-expansion-panels--variant-accordion
184+
&.v-expansion-panels--no-divider
185+
> .v-expansion-panel::after
186+
opacity: 0
187+
183188
> .v-expansion-panel
184189
margin-top: 0
185190

packages/vuetify/src/components/VExpansionPanel/VExpansionPanels.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { makeVExpansionPanelProps } from './VExpansionPanel'
99
import { makeComponentProps } from '@/composables/component'
1010
import { provideDefaults } from '@/composables/defaults'
1111
import { makeGroupProps, useGroup } from '@/composables/group'
12-
import { makeRoundedProps, useRounded } from '@/composables/rounded'
12+
import { useRounded } from '@/composables/rounded'
1313
import { makeTagProps } from '@/composables/tag'
1414
import { makeThemeProps, provideTheme } from '@/composables/theme'
1515

1616
// Utilities
1717
import { toRef } from 'vue'
18-
import { genericComponent, pick, propsFactory, useRender } from '@/util'
18+
import { convertToUnit, genericComponent, pick, propsFactory, useRender } from '@/util'
1919

2020
// Types
2121
import type { PropType } from 'vue'
@@ -36,6 +36,9 @@ export type VExpansionPanelSlots = {
3636

3737
export const makeVExpansionPanelsProps = propsFactory({
3838
flat: Boolean,
39+
gap: [String, Number],
40+
noDivider: Boolean,
41+
rounded: [Boolean, Number, String, Array] as PropType<boolean | number | string | (number | string)[]>,
3942

4043
...makeGroupProps(),
4144
...pick(makeVExpansionPanelProps(), [
@@ -50,8 +53,8 @@ export const makeVExpansionPanelsProps = propsFactory({
5053
'readonly',
5154
'ripple',
5255
'static',
56+
'tile',
5357
]),
54-
...makeRoundedProps(),
5558
...makeThemeProps(),
5659
...makeComponentProps(),
5760
...makeTagProps(),
@@ -82,7 +85,10 @@ export const VExpansionPanels = genericComponent<new <TModel>(
8285
const { next, prev } = useGroup(props, VExpansionPanelSymbol)
8386

8487
const { themeClasses } = provideTheme(props)
85-
const { roundedClasses, roundedStyles } = useRounded(props)
88+
89+
const outerRounded = toRef(() => Array.isArray(props.rounded) ? props.rounded[0] : props.rounded)
90+
const innerRounded = toRef(() => Array.isArray(props.rounded) ? props.rounded[1] : undefined)
91+
const { roundedClasses, roundedStyles } = useRounded(outerRounded)
8692

8793
const variantClass = toRef(() => props.variant && `v-expansion-panels--variant-${props.variant}`)
8894

@@ -109,6 +115,7 @@ export const VExpansionPanels = genericComponent<new <TModel>(
109115
{
110116
'v-expansion-panels--flat': props.flat,
111117
'v-expansion-panels--tile': props.tile,
118+
'v-expansion-panels--no-divider': props.noDivider || !!props.gap,
112119
},
113120
themeClasses.value,
114121
roundedClasses.value,
@@ -117,6 +124,10 @@ export const VExpansionPanels = genericComponent<new <TModel>(
117124
]}
118125
style={[
119126
roundedStyles.value,
127+
{
128+
'--v-expansion-panels-inner-radius': convertToUnit(innerRounded.value),
129+
gap: props.gap ? convertToUnit(props.gap) : undefined,
130+
},
120131
props.style,
121132
]}
122133
>

0 commit comments

Comments
 (0)