@carbon/react
Version:
React components for the Carbon Design System
27 lines (25 loc) • 706 B
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
//#region src/tools/toggleClass.ts
/**
* Copyright IBM Corp. 2019, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Toggles a class on an element.
*
* @param element - The target element.
* @param className - The class to toggle.
* @param add - `true` to add the class, `false` to remove it.
*/
const toggleClass = (element, className, add) => {
element.classList.toggle(className, add);
};
//#endregion
export { toggleClass };