MCPcopy
hub / github.com/styletron/styletron

github.com/styletron/styletron @6.1.1 sqlite

repository ↗ · DeepWiki ↗ · release 6.1.1 ↗
203 symbols 551 edges 83 files 0 documented · 0%
README

Styletron logo

test workflow

Styletron is an universal toolkit for component-oriented styling. It falls into the CSS in JS category. Styletron works great with React but can be used with other frameworks or plain JS as well.

Go to our documentation at styletron.org!

Usage with React

import { styled } from "styletron-react";

// Create a styled component by passing an element name and a style object
const RedAnchor = styled("a", { color: "red" });
<RedAnchor href="https://github.com/styletron/styletron/raw/6.1.1/foo">Hello</RedAnchor>;

// Or pass a function that takes props and returns a style object
const Panel = styled("div", props => {
  return { backgroundColor: props.$alert ? "orange" : "lightblue" };
});
<Panel $alert>Hello</Panel>;

// Do you prefer hooks?
import { useStyletron } from "styletron-react";
const [css] = useStyletron();
<a className={css({ color: "red" })} href="https://github.com/styletron/styletron/raw/6.1.1/foo">
  Hello
</a>;

Getting Started

Check the documentation to setup Styletron with Next.js, Gatsby or plain React/JS apps.

Looking for v3.x docs? | v3.x to v4.x migration guide

Design principles

  1. Component-oriented
    • Stateless, single-element styled components as base styling primitive
    • Prop interfaces for conditional/dynamic styling
  2. Embrace typed JavaScript
    • Composition of styles via (typed) JavaScript objects
    • No extra tooling (e.g. Webpack loaders, Babel plugins, etc.)
  3. Portability and flexibility
    • Portability of styled components across different rendering engines (e.g. atomic CSS)

See docs/design.md for more details.

Packages

Extension points exported contracts — how you extend this code

StandardEngine (Interface)
(no doc) [10 implementers]
packages/styletron-standard/src/index.ts
StyletronComponent (Interface)
(no doc)
packages/styletron-react/src/types.ts
Window (Interface)
(no doc)
packages/styletron-engine-atomic/src/index.ts
KeyframesPercentageObject (Interface)
(no doc)
packages/styletron-standard/src/style-types.ts
Window (Interface)
(no doc)
packages/styletron-react/src/index.tsx

Core symbols most depended-on inside this repo

renderStyle
called by 59
packages/styletron-standard/src/index.ts
styled
called by 53
packages/styletron-react/src/index.tsx
renderFontFace
called by 10
packages/styletron-standard/src/index.ts
renderKeyframes
called by 9
packages/styletron-standard/src/index.ts
withWrapper
called by 7
packages/styletron-react/src/index.tsx
getStylesheets
called by 7
packages/styletron-engine-atomic/src/server/server.ts
getStylesheets
called by 7
packages/styletron-engine-monolithic/src/server/server.ts
hashCssObject
called by 6
packages/styletron-engine-monolithic/src/css.ts

Shape

Function 109
Method 50
Class 39
Interface 5

Languages

TypeScript100%

Modules by API surface

packages/styletron-react/src/index.tsx31 symbols
packages/styletron-engine-atomic/src/server/server.ts13 symbols
packages/styletron-react/src/__tests__/tests.browser.tsx11 symbols
packages/styletron-engine-monolithic/src/server/server.ts11 symbols
packages/styletron-react/src/dev-tool.ts10 symbols
packages/styletron-engine-atomic/src/client/client.ts10 symbols
packages/styletron-engine-atomic/src/cache.ts9 symbols
packages/styletron-standard/src/index.ts7 symbols
packages/styletron-engine-monolithic/src/client/sheet.ts7 symbols
packages/styletron-engine-monolithic/src/client/__tests__/client.browser.ts7 symbols
packages/styletron-engine-atomic/src/client/__tests__/client.browser.ts7 symbols
packages/styletron-engine-monolithic/src/client/client.ts6 symbols

Dependencies from manifests, versioned

@babel/core7.18.2 · 1×
@babel/plugin-proposal-class-properties7.17.12 · 1×
@babel/plugin-transform-flow-strip-types7.17.12 · 1×
@babel/preset-env7.18.2 · 1×
@babel/preset-react7.17.12 · 1×
@babel/preset-typescript7.17.12 · 1×
@rtsao/csstype2.6.5-forked.0 · 1×
@types/jest27.5.1 · 1×
@types/react16.8.23 · 1×
@types/webpack-env1.17.0 · 1×
@typescript-eslint/eslint-plugin5.26.0 · 1×
@typescript-eslint/parser5.26.0 · 1×

For agents

$ claude mcp add styletron \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact