A Visual Studio Code extension that helps you quickly generate common fluid CSS values directly in the editor.
The extension is designed for everyday front-end work such as converting fixed font sizes into fluid clamp(...) expressions, calculating percentages from desktop/mobile widths, and converting pixel font sizes to rem.
Command: Fluid: Fluid size
Use this command when you already have your default viewport settings configured in VS Code.
How it works:
- Type a numeric value such as
48,48px, or3rem. - Place the cursor on the value.
- Run
Fluid: Fluid sizefrom the Command Palette. - Enter the minimum size when prompted.
- The value is replaced with a fluid
clamp(...)expression.
The command uses these settings:
css-fluid.desktopWidthcss-fluid.mobileWidthcss-fluid.minValue
If the selected value is written in rem, the extension converts it to pixels internally and still outputs a clamp(...) expression in rem.
Example input:
font-size: 48px;Example output:
font-size: clamp(1.125rem, calc(1.125rem + 2.0000vw - 0.4875rem), 3rem);Command: Fluid: Fluid size, ask for dimensions
Use this version when you want to override the configured values for a single calculation.
How it works:
- Type a numeric value such as
48,48px, or3rem. - Place the cursor on the value.
- Run
Fluid: Fluid size, ask for dimensions. - Enter:
- desktop width
- mobile width
- minimum value
- The value is replaced with a fluid
clamp(...)expression.
This is useful when switching between projects or design systems with different breakpoints.
Command: Fluid: Desktop Percent
Calculates what percentage a number represents relative to css-fluid.desktopWidth.
Example with desktopWidth = 1920:
width: 384px;becomes:
width: 20.000%;Command: Fluid: Desktop Percent of content
Calculates what percentage a number represents relative to css-fluid.desktopContent.
This is useful when your layout is based on a centered content container rather than the full desktop viewport.
Example with desktopContent = 1400:
max-width: 350px;becomes:
max-width: 25.000%;Command: Fluid: Mobile Percent
Calculates what percentage a number represents relative to css-fluid.mobileWidth.
Example with mobileWidth = 390:
width: 39px;becomes:
width: 10.000%;Commands:
Fluid: Set DivisorFluid: Percentage by divisor
Use this when you want to calculate a percentage against a custom base value.
How it works:
- Run
Fluid: Set Divisorand enter a number. - Type a value in your code.
- Place the cursor on that value.
- Run
Fluid: Percentage by divisor.
Example with divisor 12:
width: 3;becomes:
width: 25.000%;Command: Fluid: Font pixel to rem (1rem=16px)
Converts the number under the cursor from pixels to rem using a fixed base of 16px = 1rem.
Example:
font-size: 24px;becomes:
font-size: 1.5rem;The extension works with the number under the cursor and supports values such as:
2424px1.5rem
If the text under the cursor is not numeric, the extension shows an error message.
The commands are available in these editors:
- CSS
- SCSS
- Sass
- HTML
- JSON
This extension contributes the following settings:
css-fluid.desktopWidth— desktop viewport width used for desktop percentage calculations and default fluid size calculations. Default:1920css-fluid.mobileWidth— mobile viewport width used for mobile percentage calculations and default fluid size calculations. Default:390css-fluid.minValue— default minimum value used by the fluid size command. Default:18css-fluid.desktopContent— content/container width used byFluid: Desktop Percent of content. Default:1400
You can change them in VS Code Settings by searching for css-fluid.
- Place the cursor directly on the numeric token you want to transform.
- You do not need to manually select the value first.
- Values with
pxandremsuffixes are supported. - The extension replaces the original value in place.
No additional dependencies or external services are required.
- The extension works on the word/range under the cursor, so the cursor must be placed on the target numeric value.
- The
Font pixel to remcommand always uses16px = 1rem. - The divisor used by
Percentage by divisormust be set manually before running the command.
Repository: Lovor01/css-fluid
Main implementation files:
extension.jspackage.json
MIT