Fluid Responsive Design
Unlock advanced capabilities with styleframe Pro. This feature requires a Pro license to access.
Upgrade to ProFluid responsive design is a modern approach to creating layouts and typography that scale seamlessly across all screen sizes. Instead of jumping between fixed values at breakpoints, fluid design uses CSS calculation functions with viewport-relative units to create smooth, continuous transitions that adapt perfectly to any viewport width.
Styleframe's fluid design system is inspired by the Utopia Fluid Type Scale, using mathematical principles to calculate optimal sizes that maintain perfect proportions and readability across all devices.
Typography that flows naturally across every screen size
Say goodbye to cluttered breakpoint logic. Styleframe's fluid responsive design automatically scales your typography and spacing using mathematical precision.
Interactive Controls
Why Use Fluid Design?
Styleframe's fluid design composables offer several advantages over traditional responsive approaches:
- Seamless Scaling: Text and spacing adapt continuously without sudden jumps at breakpoints
- Perfect Readability: Maintains optimal character count and visual hierarchy at every screen size
- Reduced Complexity: Replace dozens of media queries with single fluid calculations
- Mathematical Consistency: Uses proven modular scales for harmonious proportions
- Performance Optimized: Complex CSS
calc()functions calculated by the browser at render time - Accessibility Friendly: Respects user preferences, zoom, and font size settings
How Fluid Design Works
Styleframe's fluid design uses CSS calc() functions with custom properties to create smooth scaling between minimum and maximum values. The system calculates a fluid breakpoint variable that represents the current viewport's scale between your min and max widths.
The fluid calculation considers:
- Minimum viewport width (typically 320px for mobile)
- Maximum viewport width (typically 1440px for desktop)
- Minimum value (size at smallest viewport)
- Maximum value (size at largest viewport)
- Fluid breakpoint (automatically calculated viewport position)
The result is a value that scales smoothly and proportionally between the minimum and maximum, adapting in real-time as the viewport changes.
Comparison: Traditional Breakpoints vs. Fluid Responsive Design
See how fluid design eliminates the need for multiple breakpoints by creating smooth, continuous scaling with a single CSS value.
/* Multiple breakpoints required */
.heading {
font-size: 24px;
}
@media (min-width: 768px) {
.heading { font-size: 28px; }
}
@media (min-width: 1440px) {
.heading { font-size: 32px; }
}
/* Single fluid value */
.heading {
font-size: var(--font-size--xl); /* Smooth scaling from 24px to 32px */
}
Composables
These composables enable you to create smooth, viewport-responsive sizing without breakpoints.
Fluid Viewport
Establish the viewport range for all fluid calculations in your design system.
Available composables:
useFluidViewport(): Define minimum and maximum viewport widths and calculate the fluid breakpoint variable
import { styleframe } from 'styleframe';
import { useFluidViewport } from '@styleframe/theme';
const s = styleframe();
// Use defaults (320px - 1440px)
useFluidViewport(s);
// Or customize the range
useFluidViewport(s, {
minWidth: 375, // Start scaling at 375px
maxWidth: 1920 // Stop scaling at 1920px
});
Learn more about the Fluid Viewport →
Clamp Function
Create individual fluid values using clamp calculations for any CSS property.
Available composables:
useFluidClamp(): Generate fluidcalc()calculations for custom properties
import { styleframe } from 'styleframe';
import { useSpacing } from '@styleframe/theme';
import { useFluidViewport, useFluidClamp } from '@styleframe/pro';
const s = styleframe();
const { variable } = s;
useFluidViewport(s);
// Create a fluid spacing variable
const { spacingLg } = useSpacing(s, {
lg: useFluidClamp(s, { min: 24, max: 48 }) // Scales from 24px to 48px
});
Learn more about Clamp Functions →
Fluid Typography
Generate complete fluid typography scales with mathematical precision using modular scales.
Available composables:
useFluidFontSize(): Create fluid font size systems that scale across viewport sizes
import { styleframe } from 'styleframe';
import { useFluidViewport, useFluidFontSize, useScale, useScalePowers } from '@styleframe/theme';
const s = styleframe();
const { fluidBreakpoint } = useFluidViewport(s);
const { scaleMinorThird, scaleMajorThird } = useScale(s);
const scaleMinPowers = useScalePowers(s, scaleMinorThird);
const scaleMaxPowers = useScalePowers(s, scaleMajorThird);
const { fontSize, fontSizeSm, fontSizeMd, fontSizeLg } = useFluidFontSize(s,
{ min: 16, max: 18 },
{
sm: { min: scaleMinPowers[-1], max: scaleMaxPowers[-1] },
md: { min: scaleMinPowers[0], max: scaleMaxPowers[0] },
lg: { min: scaleMinPowers[1], max: scaleMaxPowers[1] },
default: '@md'
},
fluidBreakpoint
);
Learn more about Fluid Typography →
Fluid Design Reference
| Composable | Purpose | Use Case |
|---|---|---|
useFluidViewport() | Set up fluid viewport ranges and breakpoint | Define min/max viewport widths |
useFluidClamp() | Create fluid calc() calculations | Custom fluid properties (spacing, sizing) |
useFluidFontSize() | Generate fluid typography scales | Complete fluid type systems |
Best Practices
- Start with sensible ranges: Choose viewport ranges that match your target devices (typically 320px-1440px)
- Use consistent scales: Stick to proven modular scales (Minor Third, Major Third, etc.) for harmonious results
- Test thoroughly: Fluid design looks different at every width—test at multiple viewport sizes
- Combine with media queries: Use fluid sizing with breakpoint-based layout changes
- Document your decisions: Explain your scale choices and viewport ranges in your theme
- Keep it simple: Not every property needs to be fluid—focus on typography and spacing first
Next Steps
Ready to implement fluid design? Start with these guides:
- New to fluid design? Begin with Clamp Function to understand the foundation
- Building fluid typography? Check out Fluid Typography for complete type systems
- Want mathematical consistency? Learn about Scales for harmonious proportions
- Combining with fixed tokens? Explore Typography for hybrid approaches
Resources
- Utopia Fluid Type Scale: The inspiration for Styleframe's fluid design system
- Modern Fluid Typography: Deep dive into fluid typography techniques
- CSS Clamp: MDN documentation on the
clamp()function