Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #99858

    I’m trying to use carousel component as a web component to use inside a Svelte project.
    So I installed smart-carousel with npm:

    npm install @smarthtmlelements/smart-carousel

    How can I import the comonent and use it ? I tried :

    import {Carousel} from ‘@smarthtmlelements/smart-carousel’;

    But module isn’t found:

    $ npm run dev
    ‘@smarthtmlelements/smart-carousel’ is imported by src/routes/index.svelte, but could not be resolved – treating it as an external dependency

    What am I doing wrong ?
    I also tried an empty Node project from scratch that only requires @smarthtmlelements/smart-carousel and use it, but the result is the same.
    I maybe missed something in docs, but I do not clearely understand how it’s organized.


    Hi brunetton,
    To import a web component in your project, you simply need to import its file. Step by step instructions are below.
    After you install smart-carousel, create a new index.htm file:

    <!DOCTYPE html>
    <link rel="stylesheet" href="./node_modules/@smarthtmlelements/smart-core/source/styles/smart.default.css" type="text/css" />
    smart-carousel {
    width: 100%;
    height: 600px;
    <script type="module">
    import './node_modules/@smarthtmlelements/smart-core/source/smart.core.js';
    window.onload = function () {
    const carouselSquare = document.getElementById('carouselSquare');
    carouselSquare.dataSource = [
    {image: ''},
    {image: ''},
    {image: ''},
    {image: ''},
    {image: ''}
    <smart-carousel id="carouselSquare" hide-arrows auto-play slide-show loop hide-indicators hide-buttons keyboard display-mode="3d" interval="10000"></smart-carousel>

    After that, install http-server
    npm install http-server -s
    Run the http-server with the
    http-server command.
    The final step is:
    In your browser type:
    Best Wishes,
    Smart HTML Elements

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.