Complete reference for Progressive Acrylic functions, parameters, and configuration options.
progressiveAcrylic(target, options)
Creates a layered acrylic effect on the specified element.
Parameter | Type | Required | Description |
---|---|---|---|
target |
HTMLElement |
✅ | The DOM element to apply the acrylic effect to |
options |
Object |
❌ | Configuration object for customizing the effect |
Returns an object with control methods:
{
update: (newOptions: Object) => void,
destroy: () => void
}
const element = document.getElementById('myElement');
const acrylic = progressiveAcrylic(element, {
blur: {
enabled: true,
maxBlur: 200,
height: '50%'
}
});
The configuration object follows this structure:
interface AcrylicOptions {
blur?: BlurLayerOptions;
luminosity?: LuminosityLayerOptions;
tint?: TintLayerOptions;
noise?: NoiseLayerOptions;
}
const defaultOptions = {
blur: {
enabled: true,
direction: 'bottom',
height: '60%',
layers: 8,
maxBlur: 40,
startOpacity: 0,
endOpacity: 1,
position: 'bottom',
curve: [0.25, 0.46, 0.45, 0.94]
},
luminosity: {
enabled: false,
brightness: 1.1,
contrast: 1.05,
saturate: 1.2,
opacity: 0.8,
blendMode: 'normal'
},
tint: {
enabled: false,
color: '#ffffff',
gradient: null,
opacity: 0.1,
blendMode: 'overlay'
},
noise: {
enabled: false,
opacity: 0.3,
blendMode: 'multiply'
}
};
Property | Type | Default | Range/Values | Description |
---|---|---|---|---|
enabled |
boolean |
true |
true | false |
Enable/disable the blur layer |
direction |
string |
'bottom' |
'top' | 'bottom' | 'left' | 'right' |
Direction of blur fade |
height |
string |
'60%' |
'10%' - '100%' |
Height of blur area |
layers |
number |
8 |
3 - 20 |
Number of blur layers |
maxBlur |
number |
40 |
0 - 1000 |
Maximum blur amount in pixels |
startOpacity |
number |
0 |
0 - 1 |
Starting opacity of gradient |
endOpacity |
number |
1 |
0 - 1 |
Ending opacity of gradient |
position |
string |
'bottom' |
'top' | 'bottom' |
Vertical position of blur area |
curve |
number[] |
[0.25, 0.46, 0.45, 0.94] |
Cubic-bezier values | Distribution curve for layers |
blur: {
enabled: true,
direction: 'top',
height: '40%',
layers: 6,
maxBlur: 150,
startOpacity: 0,
endOpacity: 0.9,
position: 'top',
curve: [0.62, 0.123, 0.92, 0.002]
}
'top'
: Blur fades upward from the bottom'bottom'
: Blur fades downward from the top'left'
: Blur fades leftward from the right'right'
: Blur fades rightward from the left'top'
: Places blur area at the top of the container'bottom'
: Places blur area at the bottom of the containerAccepts either an array of cubic-bezier values [x1, y1, x2, y2]
or predefined strings:
[0.25, 0.46, 0.45, 0.94]
: iOS-style smooth curve[0.68, -0.55, 0.265, 1.55]
: Bounce effect[0.16, 1, 0.3, 1]
: Extreme ease-out[0.7, 0, 0.84, 0]
: Sharp start, smooth endProperty | Type | Default | Range/Values | Description |
---|---|---|---|---|
enabled |
boolean |
false |
true | false |
Enable/disable the luminosity layer |
brightness |
number |
1.1 |
0 - 2 |
Brightness adjustment |
contrast |
number |
1.05 |
0 - 2 |
Contrast adjustment |
saturate |
number |
1.2 |
0 - 3 |
Saturation adjustment |
opacity |
number |
0.8 |
0 - 1 |
Layer opacity |
blendMode |
string |
'normal' |
CSS blend modes | Mix blend mode |
luminosity: {
enabled: true,
brightness: 1.2,
contrast: 1.1,
saturate: 1.3,
opacity: 0.9,
blendMode: 'overlay'
}
Common blend modes for luminosity layer:
'normal'
: Standard blending (default)'overlay'
: Enhances contrast'screen'
: Lightens the result'multiply'
: Darkens the result'lighten'
: Shows lighter pixels'darken'
: Shows darker pixelsProperty | Type | Default | Range/Values | Description |
---|---|---|---|---|
enabled |
boolean |
false |
true | false |
Enable/disable the tint layer |
color |
string |
'#ffffff' |
Hex color | Solid color overlay |
gradient |
object | null |
null |
Gradient object | Linear gradient configuration |
opacity |
number |
0.1 |
0 - 1 |
Layer opacity |
blendMode |
string |
'overlay' |
CSS blend modes | Mix blend mode |
tint: {
enabled: true,
color: '#3498db',
opacity: 0.2,
blendMode: 'overlay'
}
tint: {
enabled: true,
gradient: {
direction: 'to bottom',
colors: [
{ color: '#ffffff', stop: 0, opacity: 0.3 },
{ color: '#000000', stop: 50, opacity: 0.1 },
{ color: '#3498db', stop: 100, opacity: 0.5 }
]
},
opacity: 1,
blendMode: 'overlay'
}
interface GradientOptions {
direction: string; // CSS gradient direction
colors: Array<{
color: string; // Hex color value
stop: number; // Position (0-100)
opacity: number; // Individual opacity (0-1)
}>;
}
'to bottom'
: Top to bottom'to top'
: Bottom to top'to right'
: Left to right'to left'
: Right to left'to bottom right'
: Diagonal to bottom-right'to top left'
: Diagonal to top-left'45deg'
, '90deg'
, etc.Property | Type | Default | Range/Values | Description |
---|---|---|---|---|
enabled |
boolean |
false |
true | false |
Enable/disable the noise layer |
opacity |
number |
0.3 |
0 - 1 |
Layer opacity |
blendMode |
string |
'multiply' |
CSS blend modes | Mix blend mode |
noise: {
enabled: true,
opacity: 0.4,
blendMode: 'overlay'
}
Recommended blend modes for noise texture:
'multiply'
: Darkens with noise pattern (default)'overlay'
: Balanced contrast enhancement'screen'
: Lightens with noise pattern'darken'
: Shows darker noise pixels only'lighten'
: Shows lighter noise pixels onlyThe progressiveAcrylic()
function returns an object with control methods:
update(newOptions)
Updates the acrylic effect with new configuration options.
Parameter | Type | Required | Description |
---|---|---|---|
newOptions |
Object |
✅ | Partial configuration object with new options |
const acrylic = progressiveAcrylic(element, initialOptions);
// Update only blur settings
acrylic.update({
blur: { maxBlur: 300, height: '70%' }
});
// Update multiple layers
acrylic.update({
blur: { maxBlur: 200 },
tint: { color: '#ff3498', opacity: 0.3 },
noise: { enabled: true }
});
destroy()
Completely removes the acrylic effect and cleans up all layers.
const acrylic = progressiveAcrylic(element, options);
// Later, when component unmounts or effect is no longer needed
acrylic.destroy();
You can use predefined configurations for common styles:
// iOS-style acrylic
progressiveAcrylic(element, acrylicPresets['ios-default']);
// Windows acrylic
progressiveAcrylic(element, acrylicPresets['windows-acrylic']);
// Glass morphism
progressiveAcrylic(element, acrylicPresets['glass-morphism']);
// Check if backdrop-filter is supported
const supportsBackdropFilter = CSS.supports('backdrop-filter', 'blur(1px)');
if (supportsBackdropFilter) {
progressiveAcrylic(element, options);
} else {
// Apply fallback styles
}
Here are TypeScript type definitions for better IDE support:
interface AcrylicOptions {
blur?: {
enabled?: boolean;
direction?: 'top' | 'bottom' | 'left' | 'right';
height?: string;
layers?: number;
maxBlur?: number;
startOpacity?: number;
endOpacity?: number;
position?: 'top' | 'bottom';
curve?: [number, number, number, number];
};
luminosity?: {
enabled?: boolean;
brightness?: number;
contrast?: number;
saturate?: number;
opacity?: number;
blendMode?: string;
};
tint?: {
enabled?: boolean;
color?: string;
gradient?: {
direction: string;
colors: Array<{
color: string;
stop: number;
opacity: number;
}>;
} | null;
opacity?: number;
blendMode?: string;
};
noise?: {
enabled?: boolean;
opacity?: number;
blendMode?: string;
};
}
interface AcrylicInstance {
update: (newOptions: Partial<AcrylicOptions>) => void;
destroy: () => void;
}
declare function progressiveAcrylic(
target: HTMLElement,
options?: AcrylicOptions
): AcrylicInstance;
Progressive Acrylic includes built-in error handling:
try {
const acrylic = progressiveAcrylic(element, options);
} catch (error) {
console.error('Progressive Acrylic Error:', error.message);
// Common error types:
// - Invalid target element
// - Unsupported browser
// - Invalid configuration values
}
const startTime = performance.now();
const acrylic = progressiveAcrylic(element, options);
const endTime = performance.now();
console.log(`Acrylic creation took ${endTime - startTime} milliseconds`);
For more examples and tutorials, see the Examples Guide and Custom Effects.