Skip to content

Commit b1c2906

Browse files
feat(VToolbar): add collapse-position prop (#17937)
resolves #11378 Co-authored-by: J-Sek <J-Sek@users.noreply.github.com>
1 parent 3347a19 commit b1c2906

File tree

5 files changed

+55
-4
lines changed

5 files changed

+55
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"absolute": "Applies position: absolute to the component.",
44
"bottom": "Aligns the component towards the bottom.",
55
"collapse": "Puts the toolbar into a collapsed state reducing its maximum width.",
6+
"collapsePosition": "Specifies side to attach the collapsed toolbar.",
67
"extended": "Use this prop to increase the height of the toolbar _without_ using the `extension` slot for adding content. May be used in conjunction with the **extension-height** prop. When false, will not show extension slot even if content is present.",
78
"extensionHeight": "Specify an explicit height for the `extension` slot.",
89
"flat": "Removes the toolbar's box-shadow.",

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@
300300
"toggle": "3.10.0"
301301
}
302302
},
303+
"VToolbar": {
304+
"props": {
305+
"collapsePosition": "3.11.0"
306+
}
307+
},
303308
"VTooltip": {
304309
"props": {
305310
"eager": "3.2.0",
Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
<template>
22
<v-card>
3-
<v-toolbar :collapse="collapse" title="Toolbar">
3+
<v-toolbar
4+
:collapse="collapse"
5+
:collapse-position="collapsePosition"
6+
title="Toolbar"
7+
>
48
<template v-slot:append>
59
<div class="d-flex ga-1">
610
<v-btn icon="mdi-magnify"></v-btn>
7-
811
<v-btn icon="mdi-dots-vertical"></v-btn>
912
</div>
1013
</template>
1114
</v-toolbar>
1215

13-
<v-card-text class="text-center pa-8">
16+
<v-card-text class="d-flex flex-column align-center">
1417
<v-btn
1518
color="surface-variant"
1619
text="Toggle"
1720
@click="collapse = !collapse"
1821
></v-btn>
22+
<span class="mt-4">Collapse position:</span>
23+
<v-chip-group v-model="collapsePosition" variant="outlined" border mandatory>
24+
<v-chip
25+
class="px-6"
26+
prepend-icon="mdi-arrow-collapse-left"
27+
selected-class="v-chip--variant-flat"
28+
text="start"
29+
value="start"
30+
label
31+
></v-chip>
32+
<v-chip
33+
append-icon="mdi-arrow-collapse-right"
34+
class="px-6 mr-0"
35+
selected-class="v-chip--variant-flat"
36+
text="end"
37+
value="end"
38+
label
39+
></v-chip>
40+
</v-chip-group>
1941
</v-card-text>
2042
</v-card>
2143
</template>
@@ -24,4 +46,14 @@
2446
import { shallowRef } from 'vue'
2547
2648
const collapse = shallowRef(true)
49+
const collapsePosition = shallowRef('start')
50+
</script>
51+
52+
<script>
53+
export default {
54+
data: () => ({
55+
collapse: false,
56+
collapsePosition: 'start',
57+
}),
58+
}
2759
</script>

packages/vuetify/src/components/VToolbar/VToolbar.sass

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@
2929
&--collapse
3030
max-width: $toolbar-collapsed-max-width
3131
overflow: hidden
32-
border-end-end-radius: $toolbar-collapsed-border-radius
32+
33+
&-end
34+
margin-inline-start: auto
35+
36+
&.v-toolbar--collapse-start
37+
border-end-end-radius: $toolbar-collapsed-border-radius
38+
39+
&.v-toolbar--collapse-end
40+
border-end-start-radius: $toolbar-collapsed-border-radius
3341

3442
.v-toolbar-title
3543
display: none

packages/vuetify/src/components/VToolbar/VToolbar.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export type Density = null | 'prominent' | 'default' | 'comfortable' | 'compact'
3232
export const makeVToolbarProps = propsFactory({
3333
absolute: Boolean,
3434
collapse: Boolean,
35+
collapsePosition: {
36+
type: String as PropType<'start' | 'end'>,
37+
default: 'start',
38+
},
3539
color: String,
3640
density: {
3741
type: String as PropType<Density>,
@@ -119,6 +123,7 @@ export const VToolbar = genericComponent<VToolbarSlots>()({
119123
<props.tag
120124
class={[
121125
'v-toolbar',
126+
`v-toolbar--collapse-${props.collapsePosition}`,
122127
{
123128
'v-toolbar--absolute': props.absolute,
124129
'v-toolbar--collapse': props.collapse,

0 commit comments

Comments
 (0)