solid-css
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

solid-css

A styling tool when using solidjs to custom components

usage

css

import { Component, createSignal } from "solid-js";
import { css, StyleProvider } from "solid-css";

const className = css`
  color: red;
`;

const Child: Component<{ name: string }> = ({ name }) => {
  return (
    <div>
      My name is <span class={className()}>{name}</span>
    </div>
  );
};

export const App: Component<{ name: string }> = ({ name }) => {
  return (
    <StyleProvider>
      <Child name="Tom" />
    </StyleProvider>
  );
};

createGlobalStyles

import { Component } from "solid-js";
import { createGlobalStyles, StyleProvider } from "solid-css";

const getGlobalStyles = createGlobalStyles`
  span {
    color: green;
  }
`;

const Child: Component<{ name: string }> = ({ name }) => {
  getGlobalStyles();

  return (
    <div>
      My name is <span>{name}</span>
    </div>
  );
};

export const Global: Component<{ name: string }> = ({ name }) => {
  return (
    <StyleProvider>
      <Child name={name} />
    </StyleProvider>
  );
};

Readme

Keywords

none

Package Sidebar

Install

npm i solid-css

Weekly Downloads

0

Version

2.1.0

License

MIT

Unpacked Size

17.4 kB

Total Files

9

Last publish

Collaborators

  • liaodehui1