@solid-primitives/styles
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Solid Primitives styles

@solid-primitives/styles

size version stage

Collection of reactive primitives focused on styles.

  • createRemSize - Create a reactive signal of css rem size in pixels.

Installation

npm install @solid-primitives/styles
# or
yarn add @solid-primitives/styles
# or
pnpm add @solid-primitives/styles

createRemSize

Creates a reactive signal with value of the current rem size in pixels, and tracks it's changes.

How to use it

It takes no arguments and returns a number signal.

import { createRemSize } from "@solid-primitives/styles";

const remSize = createRemSize();
console.log(remSize()); // 16

createEffect(() => {
  console.log(remSize()); // remSize value will be logged on every change to the root font size
});

useRemSize

This primitive provides a singleton root variant that will reuse signals, HTML elements and the ResizeObserver instance across all dependents that use it.

It's behavior is the same as createRemSize.

import { useRemSize } from "@solid-primitives/styles";

const remSize = useRemSize();
console.log(remSize()); // 16

Server fallback

When using this primitive on the server, it will return a signal with a value of 16 by default. You can override this value by calling the setServerRemSize helper with a new value, before calling createRemSize or useRemSize.

import { setServerRemSize, createRemSize } from "@solid-primitives/styles";

setServerRemSize(10);

const remSize = createRemSize();
console.log(remSize()); // 10 instead of 16 (only on the server!)

Demo

TODO

Changelog

See CHANGELOG.md

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.105-beta.00beta
0.1.03,395latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.03,395
0.0.1143,129
0.0.1130
0.0.1121
0.0.1113,914
0.0.1101,637
0.0.1091
0.0.10878
0.0.1071
0.0.1060
0.0.1050
0.0.105-beta.00
0.0.1041
0.0.1032
0.0.102143
0.0.10186
0.0.1000

Package Sidebar

Install

npm i @solid-primitives/styles

Weekly Downloads

11,492

Version

0.1.0

License

MIT

Unpacked Size

8.91 kB

Total Files

5

Last publish

Collaborators

  • davedbase
  • lexlohr
  • thetarnav.