Packages

@capsizecss/core

4.1.3 · 12 Nov 2025MIT205.9k / weekRepositoryHomepagenpmAtom feed

Your version

3.0.0

major23 Aug 2021Where it was published

3.1.1 is the newest release of 3.x.

In short

1 breaking

  • Breaking

    The capsize package has been moved to its own organisation on npm called @capsizecss. This will allow an official ecosystem of tooling to be added over time.

Release note

Major Changes

  • Breaking

    The capsize package has been moved to its own organisation on npm called @capsizecss. This will allow an official ecosystem of tooling to be added over time.

Features

createStyleObject

Accepts capsize `options` and returns a JS object representation of the capsize styles that is compatible with most css-in-js frameworks.

This replaces the default export of the previous version (see migration guide below).

```ts
import { createStyleObject } from '@capsizecss/core';

const capsizeStyles = createStyleObject({
  fontSize: 18,
  fontMetrics: {
    // ...
  }
});

<div
  css={{
    // fontFamily: '...' etc,
    ...capsizeStyles,
  }}
>
  My capsized text 🛶
</div>
```

createStyleString

Accepts capsize `options` and returns a string representation of the capsize styles that can then be templated into a HTML `style` tag or appended to a stylesheet.

```ts
import { createStyleString } from '@capsizecss/core';

const capsizedStyleRule = createStyleString('capsizedText', {
  fontSize: 18,
  fontMetrics: {
    // ...
  }
});

document.write(`
  <style type="text/css">
    ${capsizedStyleRule}
  </style>
  <div class="capsizedText">
    My capsized text 🛶
  </div>
`);
```

precomputeValues

Accepts capsize `options` and returns all the information required to create styles for a specific font size given the provided font metrics. This is useful for integrations with different styling solutions.

Breaking Change Migration Guide

API changes

There is no longer a default export, this behaviour is now available via the `createStyleObject` named export.

```diff
- import capsize from 'capsize';
+ import { createStyleObject } from '@capsizecss/core';

- const styles = capsize({
+ const styles = createStyleObject({
  fontSize: 18,
  fontMetrics: {
    // ...
  }
});
```

Import changes

Both the `getCapHeight` function and `FontMetrics` type still exist, but the package name will need to be updated.

```diff
- import { getCapHeight, FontMetrics } from 'capsize';
+ import { getCapHeight, FontMetrics } from '@capsizecss/core';
```

Removals

The `CapsizeOptions` type has been removed, you can infer this from the first argument passed to `createStyleObject` using TypeScripts built-in `Parameters` utility:

```diff
- import type { CapsizeStyles } from 'capsize';
+ import type { createStyleObject } from '@capsizecss/core';

+ type CapsizeOptions = Parameters<typeof createStyleObject>[0];
```

The `CapsizeStyles` type has been removed, you can infer this from `createStyleObject` using TypeScripts built-in `ReturnType` utility:

```diff
- import type { CapsizeStyles } from 'capsize';
+ import type { createStyleObject } from '@capsizecss/core';

+ type CapsizeStyles = ReturnType<typeof createStyleObject>;
```

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.