3.3.2 • Published 8 months ago

vue-forward-slots v3.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Vue Forward Slots

Need to forward slots to a child component? This package makes it easy to forward slots to a child component.

No more need for iterating over slots and passing them down to child components!

With vue forward slots 🚀

<script setup>
import MyComponent from '@/Components/MyComponent.vue'
import { ForwardSlots } from 'vue-forward-slots'
</script>

<template>
    <ForwardSlots>
        <MyComponent/> <!-- Slots will now be forwarded to MyComponent -->
    </ForwardSlots>
</template>

Old way 💩

<script setup>
import MyComponent from '@/Components/MyComponent.vue';

...

</script>

<template>
    <MyComponent>
        <template v-for="(index, name) in $slots" v-slot:[name]="data">
            <slot :name="name" v-bind="data"/>
        </template>
    </MyComponent>
</template>

Installation

npm install vue-forward-slots

Usage

Import the Component

<script setup>
import { ForwardSlots } from 'vue-forward-slots'
</script>

Forward All Slots (Except Default)

<template>
    <ForwardSlots>
        <MyComponent/>
    </ForwardSlots>
</template>

Forward Single Slot

<template>
    <ForwardSlots slot="slotname">
        <MyComponent/>
    </ForwardSlots>
</template>

Forward Specific Slots

<template>
    <ForwardSlots :slot="['slot-one', 'slot-two']">
        <MyComponent/>
    </ForwardSlots>
</template>

Forward All Slots Except Some

<template>
    <ForwardSlots :exclude="['default', 'slot-two']">
        <MyComponent/>
    </ForwardSlots>
</template>

Forward All Slots Including Default

<template>
    <ForwardSlots :exclude="[]">
        <MyComponent/>
    </ForwardSlots>
</template>

Props

PropTypeDescriptionDefault Value
slotArray, StringSpecifies slot names to forward, either as a string or an array. If omitted, all slots are forwarded (except those in exclude).[]
excludeArray, StringSpecifies slot names not to forward, either as a string or an array. The default slot is always excluded by default.['default']
3.3.2

8 months ago

3.3.1

8 months ago

3.3.0

8 months ago

3.2.3

8 months ago

3.2.2

8 months ago

3.2.1

8 months ago

3.2.0

8 months ago

3.1.4

8 months ago

3.1.3

8 months ago

3.1.2

8 months ago

3.1.1

8 months ago

3.1.0

8 months ago

3.0.7

9 months ago

3.0.6

9 months ago

3.0.5

9 months ago

3.0.4

9 months ago

3.0.3

9 months ago

3.0.2

9 months ago

3.0.1

9 months ago

3.0.0

9 months ago

2.2.0

9 months ago

2.1.1

9 months ago

2.1.0

9 months ago

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago