Chakra Rem-to-Units Helper

May 27, 2025 ยท View on GitHub

Convert rem values into Chakra UI spacing units with smart completions in VS Code.

โœจ Features

  • ๐Ÿ”„ Instantly convert rem values to Chakra spacing units
  • โšก Smart inline completions as you type
  • ๐Ÿง  Supports decimals like 1.5rem, 2.25rem
  • ๐Ÿงฉ Works in JavaScript, TypeScript, HTML, CSS, and React files
  • โœ… Minimal syntax required โ€” just type rc3, press Ctrl+Space, and select the suggestion

Cursor must be at starting line when pressing Ctrl+Space, if you write rc2 the cursor whould be behind the "r".

๐Ÿ’ก Usage

Just type a value like this:

  • rc2

Then trigger completions (e.g. Ctrl+Space), and you'll see suggestions like:

8 (chakra units, 2rem = 8 chakra size tokens)

It will replace the full matched text (rc2, rc3, etc.) with the equivalent Chakra value (e.g., 8, 12).

๐Ÿ”ง Chakra Calculation Logic

This extension assumes:

  • 1rem = 16px
  • Chakra spacing unit base = 4px

So:

rem2 โ†’ (2 _ 16) / 4 = 8
rem1.5 โ†’ (1.5 _ 16) / 4 = 6

๐Ÿ›  Supported Languages

  • JavaScript
  • TypeScript
  • JavaScript React (.jsx)
  • TypeScript React (.tsx)
  • HTML
  • CSS

๐Ÿ“ฆ Installation

  1. Search for Chakra Rem-to-Units Helper in the Extensions tab
  2. Click Install
  3. Start typing remX or rcX in your files
  4. Trigger completions with Ctrl+Space

๐Ÿงช Example

Before:

padding: rem2;

After:

padding: 8;

๐Ÿค Contributions

PRs and issues welcome!


ยฉ 2025 โ€“ Chakra Rem-to-Units Helper