Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add example for inversing the card icon color #401

Merged
merged 8 commits into from
Apr 5, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions vizro-core/docs/pages/user-guides/card-button.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,27 @@ If you use the image URL hash `icon-top`, the image will be styled according to
Note that in the above example the first [`Card`][vizro.models.Card] navigates to an existing [`Page`][vizro.models.Page]
in the app with `path = filters-and-parameters` and the second one to an external link.

#### Icon responsive to theme switch
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

To add an icon that is responsive to the theme switch, you will need to override the value of the `filter` property.
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

The `filter` property allows the application of visual effects to elements and accepts various functions as parameters. In the example below, we will use `invert()` function, to invert the color of the icon on theme switch.
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved

1. Begin by introducing a new variable into the `vizro_dark` theme.
```css
.vizro_dark {
--icon-color: invert(100%);
}
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved
```
2. Next, utilize the previously defined variable and assign it as the value for the `filter` property in your custom CSS file:
nadijagraca marked this conversation as resolved.
Show resolved Hide resolved
```css
img[src*="#my-image"] {
filter: var(--icon-color);
}
```
!!! example "Responsive icon"
![responsive icon](../../assets/user_guides/components/responsive_icon.gif)

## Buttons

To enhance dashboard interactions, you can use the [`Button`][vizro.models.Button] component to trigger any pre-defined
Expand Down
Loading