diff --git a/packages/grafana-ui/src/components/Card/Card.mdx b/packages/grafana-ui/src/components/Card/Card.mdx index a5efbed8383..63ab7ac1d05 100644 --- a/packages/grafana-ui/src/components/Card/Card.mdx +++ b/packages/grafana-ui/src/components/Card/Card.mdx @@ -126,7 +126,7 @@ Tags can be rendered inside the Card, by being wrapped in `Card.Tags` component. ### As a link -Card can be used as a clickable link item by specifying `href` prop. In this case the Card's content will be rendered inside `a`. +Card can be used as a clickable link item by specifying `href` prop. ```jsx @@ -142,6 +142,45 @@ Card can be used as a clickable link item by specifying `href` prop. In this cas +### As a button + +Card can be used as a clickable buttons item by specifying `onClick` prop. + +```jsx + alert('Hello, Grafana!')}> + Hello, Grafana + Clicking this card will create an alert + +``` + + + alert('Hello, Grafana!')}> + Hello, Grafana + Clicking this card will create an alert + + + +> **Note**: When used in conjunction with [Metadata elements](#multiple-metadata-elements), clicking on any element +> inside `` will prevent the card action to be executed (either `href` to be followed or `onClick` to be called). +> +> Example: + +```jsx + alert('Hello, Grafana!')}> + Hello, Grafana + Clicking on this text (Meta) WILL NOT trigger the alert! + Clicking on this text (Description) WILL trigger the alert! + +``` + + + alert('Hello, Grafana!')}> + Hello, Grafana + Clicking on this text (Meta) WILL NOT trigger the alert! + Clicking on this text (Description) WILL trigger the alert! + + + ### Inside a list item To render cards in a list, it is possible to nest them inside `li` items. diff --git a/packages/grafana-ui/src/components/Card/Card.tsx b/packages/grafana-ui/src/components/Card/Card.tsx index 2ba11fc31f5..34524c1e7de 100644 --- a/packages/grafana-ui/src/components/Card/Card.tsx +++ b/packages/grafana-ui/src/components/Card/Card.tsx @@ -261,6 +261,7 @@ const getMetaStyles = (theme: GrafanaTheme2) => ({ margin: theme.spacing(0.5, 0, 0), lineHeight: theme.typography.bodySmall.lineHeight, overflowWrap: 'anywhere', + zIndex: 0, }), separator: css({ margin: `0 ${theme.spacing(1)}`,