Skip to content

Commit

Permalink
feat: Adds the --starlight-image-zoom-backdrop-bg CSS custom proper…
Browse files Browse the repository at this point in the history
…ty to customize the backdrop background color of zoomed images
  • Loading branch information
HiDeoo committed Mar 23, 2024
1 parent 3cde78f commit b302a6a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig({
items: [
{ label: 'Getting Started', link: '/getting-started/' },
{ label: 'Ignoring Images', link: '/ignoring-images/' },
{ label: 'Customization', link: '/customization/' },
],
},
{ label: 'Demo', link: '/demo/' },
Expand Down
25 changes: 25 additions & 0 deletions docs/src/content/docs/customization.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Customization
description: Learn how to customize the appearance of zoomed images.
---

Zoomed images are displayed in a modal [`<dialog>` element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog) which includes a backdrop displayed behind the image.

## Customizing the backdrop

By default, the backdrop background color is an non-transparent color based on Starlight's color palette.
You can customize this color using the `--starlight-image-zoom-backdrop-bg` CSS custom property.

To learn how to add custom CSS styles to Starlight, refer to the [“Custom CSS styles”](https://starlight.astro.build/guides/css-and-tailwind/#custom-css-styles) guide in the Starlight documentation.

```css
:root {
/* Custom backdrop background color in dark mode. */
--starlight-image-zoom-backdrop-bg: oklch(0 0 0);
}

:root[data-theme='light'] {
/* Custom backdrop background color in light mode. */
--starlight-image-zoom-backdrop-bg: oklch(100% 0 0);
}
```
2 changes: 1 addition & 1 deletion packages/starlight-image-zoom/components/ImageZoom.astro
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
}

dialog::backdrop {
background: var(--sl-color-black);
background: var(--starlight-image-zoom-backdrop-bg, var(--sl-color-black));
opacity: 0;
}

Expand Down

0 comments on commit b302a6a

Please sign in to comment.