diff --git a/docusaurus/docs/key-concepts/best-practices.md b/docusaurus/docs/key-concepts/best-practices.md index 36486d6fd..af1271511 100644 --- a/docusaurus/docs/key-concepts/best-practices.md +++ b/docusaurus/docs/key-concepts/best-practices.md @@ -32,7 +32,7 @@ Is something missing from this list? [Let us know](https://github.com/grafana/pl ## Frontend -- **Use Grafana UI components** - Always use components from `@grafana/ui` when building your plugin's user interface. This ensures a consistent UI experience across Grafana and helps prevent UI breakages as Grafana evolves. These components are designed to work seamlessly with Grafana's theming system and follow the [Saga Design System](https://grafana.com/developers/saga/about/overview). For available components, refer to the [Grafana UI documentation](https://developers.grafana.com/ui/latest/index.html?path=/docs/docs-overview-intro--page). +- **Use Grafana UI components** - Always use components from `@grafana/ui` when building your plugin's user interface. This ensures a consistent UI experience across Grafana and helps prevent UI breakages as Grafana evolves. These components are designed to work seamlessly with Grafana's theming system. For available components, refer to the [Grafana UI documentation](https://developers.grafana.com/ui/latest/index.html?path=/docs/docs-overview-intro--page). - **Use Emotion for styling** - When custom styling is needed, use [Emotion](https://emotion.sh/) with the `@emotion/css` package. Always use the `useStyles2` hook to access theme variables, which provides proper memoization and ensures your styles work with Grafana's theming system. Import styling utilities from `@emotion/css` (such as `css` and `cx`). Never use global styles as they can cause breakages as Grafana evolves. For detailed styling guidelines, refer to the [Grafana styling guide](https://github.com/grafana/grafana/blob/main/contribute/style-guides/styling.md). - **Use theme variables for colors, spacing, and typography** - Never hardcode visual properties like colors, spacing, padding, or font sizes. Use the `useTheme2()` hook from `@grafana/ui` to access design tokens (for example, `theme.spacing(2)`, `theme.colors.primary.main`). This ensures your plugin adapts to light/dark mode and maintains visual consistency. For theme implementation details, refer to the [Grafana themes guide](https://github.com/grafana/grafana/blob/main/contribute/style-guides/themes.md). @@ -50,7 +50,6 @@ Is something missing from this list? [Let us know](https://github.com/grafana/pl - **Add a health check for your plugin** - [Health checks](../key-concepts/backend-plugins/#health-checks) are used to verify that the data source is working properly. How this is implemented depends on whether the plugin has a backend. For the `backend` case, it's not necessary to modify its frontend code as long as it extends the `DataSourceWithBackend` class from `@grafana/runtime`. - **Add [dashboard variables](https://grafana.com/docs/grafana/latest/dashboards/variables/) support** - Dashboard (or template) variables allow users to create dynamic dashboards. There are two aspects of adding support for variables in your plugin. The first is allowing queries for your data source and return values to be used as variables. The second is replacing existing variables in other queries. For more information, refer to our [documentation](../how-to-guides/data-source-plugins/add-support-for-variables#add-support-for-query-variables-to-your-data-source). Pay special attention when selecting "All values" since it may require specific logic to join variable values. - **Add annotations support** - Annotations allow users to add contextual information to their dashboards and it's possible to use queries to define them. For more information, refer to [Enable annotations](../how-to-guides/data-source-plugins/add-support-for-annotation-queries). -- **Practice good front-end design** - When building frontend components, make sure to use [Grafana components](https://developers.grafana.com/ui/latest/index.html?path=/docs/docs-overview-intro--page) as the base and follow the [Saga Design System](https://grafana.com/developers/saga/about/overview). - **Add query editor help** - Query editors can be complex and it's useful to provide help to users. For more information, refer to [Add query editor help](../how-to-guides/data-source-plugins/add-query-editor-help). - **Skip hidden or empty queries** - This avoids executing unnecessary or wrong queries. Data sources implementing `DataSourceWithBackend` only need to implement the method `filterQuery`. Refer to this [example](https://github.com/grafana/grafana/blob/fd5f66083c91b9759ae7772f99b80c9342b93290/public/app/plugins/datasource/loki/datasource.ts#L1085). - **Specify a default query** - Default queries can help users to discover how queries are written for the plugin.