Replies: 2 comments 11 replies
-
I haven’t used Solid yet, but I’ll tweet a link to this thread so maybe someone will chime in. |
Beta Was this translation helpful? Give feedback.
-
I had to figure this out for a sample extension with the Webview UI Toolkit for VS Code recently, so I think I can help! The short answer is that everything just kind of works out of the box! In the case of Shoelace, all you should need to do is: EDIT: I previously suggested that one follows the Shoelace quick start directions by installing Shoelace resources from a CDN. Based on feedback from @justinfagnani below (thanks!) it's best not to mix and match loading packages from npm (i.e. Solid) and a CDN (i.e. Shoelace). Here is a new set of directions for configuring Solid + Shoelace using only npm. (Note: These directions also assume you've started your Solid project by using one of the official Solid templates).
/* @refresh reload */
import { render } from 'solid-js/web';
import '@shoelace-style/shoelace/dist/themes/light.css';
import '@shoelace-style/shoelace/dist/components/button/button.js';
import './index.css';
import App from './App';
render(() => <App />, document.getElementById('root') as HTMLElement);
import type { Component } from 'solid-js';
import logo from './logo.svg';
import styles from './App.module.css';
const App: Component = () => {
return (
<div class={styles.App}>
<header class={styles.header}>
<img src={logo} class={styles.logo} alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<sl-button>Learn Solid</sl-button> <-- 🥳
</header>
</div>
);
};
export default App;
An important caveat when using TypeScript and JSX: If you're using TypeScript and JSX you'll have to create a type declaration file to extend the solid-js JSX.IntrinsicElements type interface to include type annotations for each of the Shoelace components you use. Without this, type errors will occur when you try to use any Shoelace component in your Solid + TypeScript + JSX component code. (Note that this file shouldn't be necessary if you're not using TypeScript or are using tagged template literals instead of JSX for your Solid component code). Basically copy-paste the following into a EDIT: Check the below discussion thread for an improved declaration code snippet that offers better type annotations for Shoelace components. import "solid-js";
declare module "solid-js" {
namespace JSX {
interface IntrinsicElements {
"sl-button": any;
// Add other component type annotations always in the format: "component-name": any;
}
}
} Hope that helps! 😊 |
Beta Was this translation helpful? Give feedback.
-
Hi , How to use in solid.js ,
Is there an example.
If it can be used in solid.js, it is really great
Beta Was this translation helpful? Give feedback.
All reactions