0.0.114 • Published 3 months ago

@solid-primitives/styles v0.0.114

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

@solid-primitives/styles

turborepo 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

0.0.114

3 months ago

0.0.113

3 months ago

0.0.112

4 months ago

0.0.111

10 months ago

0.0.109

1 year ago

0.0.110

1 year ago

0.0.106

1 year ago

0.0.105

1 year ago

0.0.104

1 year ago

0.0.103

1 year ago

0.0.108

1 year ago

0.0.107

1 year ago

0.0.105-beta.0

1 year ago

0.0.102

1 year ago

0.0.101

2 years ago

0.0.100

2 years ago