1.0.2 • Published 6 months ago

@appoly/vue-sheet v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

Vue Sheet

A flexible, accessible, and customizable Sheet component for Vue 3. Inspired by Shadcn.

Features

  • Multiple positioning options (left, right, top, bottom)
  • Customizable width and height
  • Easy to use with v-model/prop binding
  • Escape key support
  • Customizable trigger and close buttons

Dependencies

  • Vue 3.x

Installation

npm install @appoly/vue-sheet
# or
yarn add @appoly/vue-sheet

Usage

Basic Usage

<template>
  <Sheet 
    v-model:open="isOpen"
    @update:open="isOpen = $event"
    position="right"
    :can-close="canClose"
  >
    <template #trigger>
      <button>Open Sheet</button>
    </template>
    
    <div>
      <!-- Your sheet content here -->
      Sheet content
    </div>
  </Sheet>
</template>

<script setup>
import { ref } from 'vue'
import { Sheet } from '@appoly/vue-sheet'
import '@appoly/vue-sheet/dist/style.css'

const isOpen = ref(false)
const canClose = () => {
  return confirm('Are you sure you want to close the sheet?')
}
</script>

Try it out on StackBlitz

Expandable

<template>
  <Sheet
    position="left"
    expandable
    :expand-default="true"
  >
    <template #trigger>
      <button>Open Sheet</button>
    </template>
    
    <div>
      <!-- Your sheet content here -->
      Sheet content
    </div>
  </Sheet>
</template>

Try it out on StackBlitz

Custom Buttons

<template>
  <Sheet 
    position="bottom"
  >
    <template #trigger>
      <button>Open Sheet</button>
    </template>
    
    <template #maximize>
      <button>Maximize</button>
    </template>
    
    <template #minimize>
      <button>Minimize</button>
    </template>
    
    <template #close>
      <button>Close</button>
    </template>
    
    <div>
      <!-- Your sheet content here -->
      Sheet content
    </div>
  </Sheet>
</template>

Try it out on StackBlitz

Props

PropTypeDefaultDescriptionAllowed Values
positionString"right"Sheet slide direction"left", "right", "top", "bottom"
widthString"500px"Width of sheet (when left/right)CSS width values (px, %, em, rem, vw, vh)
heightString"500px"Height of sheet (when top/bottom)CSS height values (px, %, em, rem, vw, vh)
maxWidthString"90%"Maximum width of sheetPercentage values
maxHeightString"90%"Maximum height of sheetPercentage values
openBooleanfalseControl sheet open statetrue/false
closeOnEscapeBooleantrueClose sheet when Escape is pressedtrue/false
noTriggerBooleanfalseDisable default triggertrue/false
canCloseFunction() => trueCustom function to determine if the sheet can be closedFunction returning boolean
expandableBooleanfalseAllow the sheet to be expandedtrue/false
expandDefaultBooleanfalseDefault expand state (true means expanded)true/false

Slots

  • trigger: Custom trigger element
  • close: Custom close button
  • maximize: Custom maximize button
  • minimize: Custom minimize button
  • Default slot: Sheet content
1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

11 months ago

0.0.11

11 months ago

0.0.10

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago