Skip to content

SolidJS Support #160

@softmarshmallow

Description

@softmarshmallow

Solid JS frameworks support

https://www.solidjs.com/

Codegen

https://www.solidjs.com/tutorial/bindings_style

Styling

inline-style

unlike react, solidjs uses the default css property name (kebab-case) with "" - "font-size" (react: fontSize)

<div style={{
  color: `rgb(${num()}, 180, ${num()})`,
  "font-weight": 800,
  "font-size": `${num()}px`}}
>
  Some Text
</div>

styled-components
Solid offers an official wrap of styled-components implementation of its own. - solid-styled-components

differences from react: styled-compoents are..

  • use named imports (not default import)
  • use call signature instead of property signature styled.div -> styled("div")
  • has built-in css obj support -> import { css } from "solid-styled-components";
import { styled } from "solid-styled-components";

const Btn = styled("button")`
  border-radius: 4px;
`;

styled-jsx (by vercel) unofficial wrapper

https://github.com/solidjs/solid-styled-jsx

function Button() {
  const [isLoggedIn, login] = createSignal(false);
  return (
    <>
      <button className="button" onClick={() => login(!isLoggedIn())}>
        {isLoggedIn() ? "Log Out" : "Log In"}
      </button>
      <style jsx dynamic>
        {`
          .button {
            background-color: ${isLoggedIn() ? "blue" : "green"};
            color: white;
            padding: 20px;
            margin: 10px;
          }
        `}
      </style>
    </>
  );
}

States & Events

Lifecycles

Testing

Unique Elements

  • <For>
  • <Show>
  • <Switch>/<Match>
  • <Index>
  • <ErrorBoundary>
  • <Suspense>
  • <Dynamic>
  • <Protal>

Special Attributes

  • ref
  • classList
  • style
  • on:x
  • use:x
  • prop:x
  • attr:x
  • /* @once */

Runtime & Env / Editor

WIP

tsx/jsx
https://www.solidjs.com/guides/typescript#configuring-typescript

{
  "compilerOptions": {
    "jsx": "preserve",
    "jsxImportSource": "solid-js"
  }
}

Examples

  • working examples
  • realworld app examples (human written)

References

Resources

Note: Differences from react

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions