# post-carousel/4.0.7/src/components/toggle/toggle.js

Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog &amp; News, version 4.0.7. 49 lines.

- Page: https://pluginprobe.com/plugins/post-carousel/4.0.7/code/src/components/toggle/toggle.js
- Raw: https://pluginprobe.com/plugins/post-carousel/4.0.7/raw/src/components/toggle/toggle.js
- Modified: 2026-04-24T11:48:54+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/post-carousel/4.0.7/code/src/components/toggle/toggle.js#L10-L20`.

```javascript
import { ToggleControl } from "@wordpress/components";
import "./editor.scss";
import { memo } from "@wordpress/element";
import { DndTitleIcon } from "../../icons/icons";
import { priceLink } from "../../blocks/shared/helpFn";

const Toggle = ({
	label = "",
	attributes,
	pro = false,
	setAttributes = () => {},
	attributesKey = "",
	onChange = false,
	updated = false,
	helpText = false,
}) => {
	return (
		<>
			<div className={`sp-smart-post-toggle sp-smart-post-component-mb ${updated ? "updated-toggle" : ""} ${pro ? "sp-smart-pro-toggle" : ""}`}>
				{(updated || pro) && (
					<>
					{updated && <div className="sp-smart-post-toggle-left">
						<DndTitleIcon />
						<span className="sp-smart-post-component-title">{label}</span>
					</div>}
					{pro && <> <span className="sp-smart-pro-label"> {label} </span> <a target="_blank" href={priceLink} className="sp-smart-pro-text"> (Pro) </a></>}
					</>
				)}
				<ToggleControl
					label={!(updated || pro) ? label : ""}
					checked={attributes}
					onChange={pro ? () => {} : (newField) =>
						onChange
							? onChange(!newField)
							: setAttributes({
									[attributesKey]: !attributes,
								})
					}
					// help={helpText}
					__nextHasNoMarginBottom={true}
				/>
			</div>
			{helpText && <span className="components-toggle-control__help"> {helpText} </span>}
		</>
	);
};

export default memo(Toggle);

```
