Skip to content
This repository was archived by the owner on Oct 20, 2025. It is now read-only.

Commit a2dcbbd

Browse files
committed
Support for inline dropdown
1 parent e5131d8 commit a2dcbbd

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

lib/Components/Dropdown.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<template>
22
<OnClickOutside
3-
class="relative"
3+
:style="wrapperStyle"
44
:do="hide"
55
:opened="opened"
66
>
7-
<div ref="button">
7+
<div
8+
ref="button"
9+
:style="buttonStyle"
10+
>
811
<slot
912
name="button"
1013
:toggle="toggle"
@@ -50,6 +53,11 @@ export default {
5053
default: "absolute",
5154
required: false,
5255
},
56+
inline: {
57+
type: Boolean,
58+
default: false,
59+
required: false,
60+
},
5361
disabled: {
5462
type: Boolean,
5563
default: false,
@@ -64,6 +72,22 @@ export default {
6472
};
6573
},
6674
75+
computed: {
76+
buttonStyle() {
77+
return this.inline ? { display: "inline" } : {};
78+
},
79+
80+
wrapperStyle() {
81+
const style = { position: "relative" };
82+
83+
if(this.inline) {
84+
style.display = "inline";
85+
}
86+
87+
return style;
88+
}
89+
},
90+
6791
watch: {
6892
opened() {
6993
this.popper.update();

resources/views/dropdown.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
<SpladeDropdown {{ $attributes->except('class') }} :splade-id="@js($spladeId)">
1+
<SpladeDropdown {{ $attributes->except('class')->mergeVueBinding(':inline', $inline) }} :splade-id="@js($spladeId)">
22
<template #button="dropdown">
33
<button
44
type="button"
55
aria-haspopup="true"
6-
{{ $attributes->only('class') }}
6+
{{ $attributes->only('class')->when($inline && !$attributes->has('class'), fn($attributes) => $attributes->class('inline')) }}
77
:class="{ 'cursor-not-allowed': dropdown.disabled }"
88
:disabled="dropdown.disabled"
99
@click.prevent="dropdown.toggle"

src/Components/Dropdown.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class Dropdown extends Component
1515
* @return void
1616
*/
1717
public function __construct(
18-
public string $scope = 'dropdown'
18+
public string $scope = 'dropdown',
19+
public bool $inline = false
1920
) {
2021
$this->spladeId = Str::random();
2122
}

0 commit comments

Comments
 (0)