import React, { forwardRef } from "react"; import { AkselColor } from "../types"; import type { OverridableComponent } from "../utils-external"; import { cl } from "../utils/helpers"; export interface ChipsToggleProps extends React.ButtonHTMLAttributes { children: string; /** * Toggles aria-pressed and visual changes */ selected?: boolean; /** * @deprecated Use `data-color` prop instead. */ variant?: "action" | "neutral"; /** * Overrides inherited color. * @see 🏷️ {@link AkselColor} * @see [📝 Documentation](https://aksel.nav.no/grunnleggende/styling/farger-tokens) */ "data-color"?: AkselColor; /** * Toggles display of checkmark on selected * @default true */ checkmark?: boolean; } export const ToggleChips: OverridableComponent< ChipsToggleProps, HTMLButtonElement > = forwardRef( ( { className, children, selected, variant, checkmark = true, as: Component = "button", "data-color": color, ...rest }, ref, ) => { return ( {checkmark && ( {selected ? ( ) : ( )} )} {children} ); }, ); function variantToColor( variant?: ChipsToggleProps["variant"], ): AkselColor | undefined { switch (variant) { case "action": return "accent"; case "neutral": return "neutral"; default: return undefined; } } export default ToggleChips;