diff --git a/packages/grafana-ui/src/components/Button/Button.tsx b/packages/grafana-ui/src/components/Button/Button.tsx index 0dba93067c5..a3d1a41c116 100644 --- a/packages/grafana-ui/src/components/Button/Button.tsx +++ b/packages/grafana-ui/src/components/Button/Button.tsx @@ -30,6 +30,8 @@ type CommonProps = { tooltip?: PopoverContent; /** Position of the tooltip */ tooltipPlacement?: TooltipPlacement; + /** Position of the icon */ + iconPlacement?: 'left' | 'right'; }; export type ButtonProps = CommonProps & ButtonHTMLAttributes; @@ -48,6 +50,7 @@ export const Button = React.forwardRef( tooltip, disabled, tooltipPlacement, + iconPlacement = 'left', onClick, ...otherProps }, @@ -73,6 +76,8 @@ export const Button = React.forwardRef( const hasTooltip = Boolean(tooltip); + const iconComponent = icon && ; + // In order to standardise Button please always consider using IconButton when you need a button with an icon only // When using tooltip, ref is forwarded to Tooltip component instead for https://github.com/grafana/grafana/issues/65632 const button = ( @@ -87,8 +92,9 @@ export const Button = React.forwardRef( disabled={!hasTooltip && disabled} ref={tooltip ? undefined : ref} > - + {iconPlacement === 'left' && iconComponent} {children && {children}} + {iconPlacement === 'right' && iconComponent} ); @@ -219,6 +225,7 @@ export const getButtonStyles = (props: StyleProps) => { label: 'button', display: 'inline-flex', alignItems: 'center', + gap: theme.spacing(1), fontSize: fontSize, fontWeight: theme.typography.fontWeightMedium, fontFamily: theme.typography.fontFamily, @@ -254,9 +261,7 @@ export const getButtonStyles = (props: StyleProps) => { marginRight: theme.spacing(-padding / 2), marginLeft: theme.spacing(-padding / 2), }) - : css({ - marginRight: theme.spacing(padding / 2), - }), + : undefined, content: css({ display: 'flex', flexDirection: 'row', diff --git a/public/app/features/dashboard-scene/edit-pane/DashboardEditableElement.tsx b/public/app/features/dashboard-scene/edit-pane/DashboardEditableElement.tsx index 3ccdf843e82..f0cf2c16b7f 100644 --- a/public/app/features/dashboard-scene/edit-pane/DashboardEditableElement.tsx +++ b/public/app/features/dashboard-scene/edit-pane/DashboardEditableElement.tsx @@ -2,7 +2,7 @@ import { ReactNode, useMemo } from 'react'; import { Trans } from '@grafana/i18n'; import { t } from '@grafana/i18n/internal'; -import { Button, Icon, Input, Stack, TextArea } from '@grafana/ui'; +import { Button, Input, TextArea } from '@grafana/ui'; import { OptionsPaneCategoryDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneCategoryDescriptor'; import { OptionsPaneItemDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor'; @@ -67,13 +67,10 @@ export class DashboardEditableElement implements EditableDashboardElement { size="sm" onClick={() => this.dashboard.onOpenSettings()} tooltip={t('dashboard.toolbar.dashboard-settings.tooltip', 'Dashboard settings')} + icon="sliders-v-alt" + iconPlacement="right" > - - - Settings - - - + Settings );