Skip to content

dehwyy/svelte-cropper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SvelteCropper

CropperJS component for Svelte.

Example

<script lang="ts">
    import { Cropper, type CropperInstance, type CropperDefaultProps } from "svelte-cropper"
    
    let cropper: CropperInstance | null = null
    
    let image_src = "https://svelte-cropper.vercel.app/ok.jpg"
    
    const cropper_props: CropperDefaultProps = {
        viewMode: 2, // necessary,
        // optional
        dragMode: "crop",
        initialAspectRatio: 1 // not reactive as cropper initializes on component mount
    }
    
</script>

<Cropper bind:cropper src={image_src} {cropper_props}/>

More examples

Demo

Instalation

pnpm add svelte-cropper

Options