@carbon/react
Version:
React components for the Carbon Design System
20 lines (17 loc) • 493 B
JavaScript
/**
* Copyright IBM Corp. 2016, 2023
*
* 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);
};
export { toggleClass };