Socket
Socket
Sign inDemoInstall

svelte-drawer-component

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-drawer-component

[Check out the demo](https://svelte.dev/repl/32443b9fad6447fe899a60596537db31?version=3.24.1)


Version published
Maintainers
1
Install size
15.7 kB
Created

Readme

Source

Svelte Drawer

Check out the demo

A Svelte component for a drawer that slides in from the side of the screen.

Features:

  • CSS transitions
  • SSR Safe
  • Top, right, bottom, or left placement
  • Lock body scrolling when open

Usage

npm install svelte-drawer-component
<script>
    import Drawer from 'svelte-drawer-component'
    let open = false
</script>

<button on:click={() => open = true}>Open</button>

<Drawer { open } size='600px'>
    <button on:click={() => open = false}>Close</button>
</Drawer>

The open state for the drawer is handled entirely by the user. This design gives the most control and flexibility over drawer functionality and styling. This means that if you want the drawer to close when the user clicks away, you need to listen for that event.

<Drawer { open } on:clickAway={() => open = false}>
</Drawer>

For custom size and transition duration, use the props. Otherwise, if you want to style the drawer, then you can reach into the classes.

<div class='app'>
    <Drawer></Drawer>
</div>

<style>
    .app :global(.drawer .overlay) {
        background: rgba(100, 100, 100, 0.5);
    }

    .app :global(.drawer .panel) {
        background: black;
        color: white;
    }
</style>

Parameters

ParameterDefaultDescription
openfalseTwo-way binding for open state of the component
placementleftSide of screen to slide out from
sizenullPanel size (e.g. '100px', '10em', '70%', null)
duration0.2Transition duration in seconds

By default, the size of the panel is set to null and stretches to the size of its parent container.

FAQs

Last updated on 31 Jan 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc