# slider-blocks/2.11.0/src/generators/styles/background-control.js

GutSlider – All in One Slider and Carousel Blocks for Gutenberg, version 2.11.0. 29 lines.

- Page: https://pluginprobe.com/plugins/slider-blocks/2.11.0/code/src/generators/styles/background-control.js
- Raw: https://pluginprobe.com/plugins/slider-blocks/2.11.0/raw/src/generators/styles/background-control.js
- Modified: 2026-02-21T13:53:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/slider-blocks/2.11.0/code/src/generators/styles/background-control.js#L10-L20`.

```javascript
const generateBgStyles = ({ controlName, attributes }) => {
    const {
        [`${controlName}bgType`]: bgType = 'classic',
        [`${controlName}bgColor`]: bgColor,
        [`${controlName}bgGradient`]: bgGradient
    } = attributes;

    let bgStyle;
    if (bgType === 'classic' && bgColor !== undefined && bgColor !== '') {
        bgStyle = bgColor
            ? `background-color: ${bgColor};
        `
            : '';
    } else if (bgType === 'gradient' && bgGradient !== undefined && bgGradient !== '') {
        bgStyle = bgGradient
            ? `background-image: ${bgGradient};
        `
            : '';
    } else {
        bgStyle = '';
    }

    return {
        bgStyle
    };
};

export default generateBgStyles;

```
