Vue-croppa is a straightforward, highly customizable, and mobile-friendly image cropping component specifically designed for Vue 2.0 applications. It enables users to select an image, move, zoom, and crop it directly within the browser, supporting touch gestures for mobile devices and handling EXIF orientation. The current stable version is 1.3.8. While the package has seen consistent bug fixes and minor feature additions (like `auto-sizing` and `passive` mode) in its 1.x series, its focus on Vue 2.0 suggests a maintenance cadence rather than active feature development for newer Vue versions. Its key differentiators include simplicity of use, extensive customization options via props, and built-in mobile support for common cropping interactions.
npm install vue-croppaVerified import paths — ran on the pinned version, not inferred.
This quickstart initializes a Vue application with the croppa component. It demonstrates how to integrate the component, bind it with `v-model`, and programmatically access its API to generate and upload a cropped image as a Blob.
Ensure `v-model` is correctly bound to an empty object, e.g., `data: { myCroppa: {} }`, to correctly access the component's API methods.To enable automatic replacement on drag and drop, explicitly set `:replace-drop="true"` on the `<croppa>` component.
Use `Vue.use(Croppa, { componentName: 'my-custom-cropper' });` to register the component with a different name.If you need fixed dimensions, ensure `auto-sizing` is `false` (its default). For responsive behavior, set `:auto-sizing="true"` and manage the container's dimensions via CSS.
Consider using alternative image cropper libraries that are explicitly built for Vue 3 if you are working on a Vue 3 project.
Implement SSR-specific checks or dynamically import the component only on the client-side. For Nuxt.js, use `<client-only><croppa ...></client-only>` or register the component as a client-side plugin.
Ensure `myCroppa: {}` is defined in your component's `data` property, and any calls to `myCroppa` methods are made after the component is mounted or after an image has been loaded (e.g., in a method triggered by user interaction).Ensure `Vue.use(Croppa)` is called only once, typically in your main `main.js` or `app.js` file. If using multiple Vue apps, register it separately for each, or customize the component name to avoid clashes.