From bf4d6a689804bc9c25a3ce4de07519989f26f1eb Mon Sep 17 00:00:00 2001 From: esaramago Date: Thu, 7 Nov 2024 16:48:50 +0000 Subject: [PATCH 1/5] Documentation for Svelte #2261 --- docs/_includes/sidebar.njk | 1 + docs/pages/frameworks/svelte.md | 85 +++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 docs/pages/frameworks/svelte.md diff --git a/docs/_includes/sidebar.njk b/docs/_includes/sidebar.njk index 11745e6579..df0958bb48 100644 --- a/docs/_includes/sidebar.njk +++ b/docs/_includes/sidebar.njk @@ -17,6 +17,7 @@
  • React
  • Vue
  • Angular
  • +
  • Svelte
  • diff --git a/docs/pages/frameworks/svelte.md b/docs/pages/frameworks/svelte.md new file mode 100644 index 0000000000..669d47476d --- /dev/null +++ b/docs/pages/frameworks/svelte.md @@ -0,0 +1,85 @@ +--- +meta: + title: Svelte + description: Tips for using Shoelace in your Svelte app. +--- + +# Svelte + +Svelte [plays nice](https://custom-elements-everywhere.com/#svelte) with custom elements, so you can use Shoelace in your Svelte apps with ease. + +## Installation + +To add Shoelace to your Svelte app, install the package from npm. + +```bash +npm install @shoelace-style/shoelace +``` + +Next, [include a theme](/getting-started/themes) and set the [base path](/getting-started/installation#setting-the-base-path) for icons and other assets. In this example, we'll import the light theme and use the CDN as a base path. + +```jsx +// main.js or main.ts +import '@shoelace-style/shoelace/dist/themes/light.css'; +import { setBasePath } from '@shoelace-style/shoelace/dist/utilities/base-path'; + +setBasePath('https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@%VERSION%/%CDNDIR%/'); +``` + +:::tip +If you'd rather not use the CDN for assets, you can create a build task that copies `node_modules/@shoelace-style/shoelace/dist/assets` into a public folder in your app. Then you can point the base path to that folder instead. +::: + +## Usage + +### QR code generator example + +```jsx +

    Live editing

    + + message = event.target.value}> + + + + {message} + + + +``` + +### Two-way Binding + +One caveat is there's currently Svelte only supports `bind:value` directive in ``, `