diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx
index 5294fee2b45..3a0737d31c0 100644
--- a/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx
+++ b/packages/grafana-ui/src/components/IconButton/IconButton.story.tsx
@@ -1,10 +1,11 @@
import React from 'react';
import { css } from '@emotion/css';
-import { IconButton } from '@grafana/ui';
+import { IconButton, IconButtonVariant } from './IconButton';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
import { useTheme2 } from '../../themes';
import { IconSize, IconName } from '../../types';
import mdx from './IconButton.mdx';
+import { VerticalGroup } from '../Layout/Layout';
export default {
title: 'Buttons/IconButton',
@@ -35,6 +36,7 @@ const RenderScenario = ({ background }: ScenarioProps) => {
const theme = useTheme2();
const sizes: IconSize[] = ['sm', 'md', 'lg', 'xl', 'xxl'];
const icons: IconName[] = ['search', 'trash-alt', 'arrow-left', 'times'];
+ const variants: IconButtonVariant[] = ['secondary', 'primary', 'destructive'];
return (
{
}
`}
>
-
{background}
- {icons.map((icon) => {
- return sizes.map((size) => (
-
-
-
- ));
- })}
+
+ {background}
+ {variants.map((variant) => {
+ return (
+
+ {icons.map((icon) => {
+ return sizes.map((size) => (
+
+
+
+ ));
+ })}
+
+ );
+ })}
+
);
};
diff --git a/packages/grafana-ui/src/components/IconButton/IconButton.tsx b/packages/grafana-ui/src/components/IconButton/IconButton.tsx
index aa0d10f906f..ec9da91e4dd 100644
--- a/packages/grafana-ui/src/components/IconButton/IconButton.tsx
+++ b/packages/grafana-ui/src/components/IconButton/IconButton.tsx
@@ -4,11 +4,13 @@ import { IconName, IconSize, IconType } from '../../types/icon';
import { stylesFactory } from '../../themes/stylesFactory';
import { css, cx } from '@emotion/css';
import { useTheme2 } from '../../themes/ThemeContext';
-import { GrafanaThemeV2 } from '@grafana/data';
+import { GrafanaThemeV2, colorManipulator } from '@grafana/data';
import { Tooltip } from '../Tooltip/Tooltip';
import { TooltipPlacement } from '../Tooltip/PopoverController';
import { getFocusStyles, getMouseFocusStyles } from '../../themes/mixins';
+export type IconButtonVariant = 'primary' | 'secondary' | 'destructive';
+
export interface Props extends React.ButtonHTMLAttributes {
/** Name of the icon **/
name: IconName;
@@ -22,14 +24,16 @@ export interface Props extends React.ButtonHTMLAttributes {
tooltip?: string;
/** Position of the tooltip */
tooltipPlacement?: TooltipPlacement;
+ /** Variant to change the color of the Icon */
+ variant?: IconButtonVariant;
}
type SurfaceType = 'dashboard' | 'panel' | 'header';
export const IconButton = React.forwardRef(
- ({ name, size = 'md', iconType, tooltip, tooltipPlacement, className, ...restProps }, ref) => {
+ ({ name, size = 'md', iconType, tooltip, tooltipPlacement, className, variant = 'secondary', ...restProps }, ref) => {
const theme = useTheme2();
- const styles = getStyles(theme, size);
+ const styles = getStyles(theme, size, variant);
const button = (