Utilizing a personalized class to enhance the aesthetic of VMware's clarity dark theme

I've been experimenting with the dark theme feature in VMware Clarity to toggle between light and dark themes.

However, I'm encountering an issue where the dark theme isn't being applied to my custom CSS classes, which is to be expected.

For instance, I have a custom class that defines a white background:

.custom-class { background: white; }

When the dark theme is activated, I anticipate the background color to change. However, I'm unsure of how to achieve this.

You can test it out on Stackblitz here: https://stackblitz.com/edit/clarity-theme-switcher-9mjqdm

In attempting to find a workaround, I looked for existing classes in the clarity.css file that have different backgrounds based on the theme (e.g., cards). Unfortunately, most of them add extra CSS properties that affect the UI layout.

Additionally, the bg-classes like bg-faded, bg-primary, etc. don't have corresponding dark theme options. Can anyone help me with a workaround for this issue?

https://i.sstatic.net/ytXpG.png

Answer №1

If you find yourself toggling between the two preset stylesheets provided by Clarity (Light/Dark), it's likely that we create these themes from a single css file using custom properties (css variables) instead of scss variables as initially designed.

To achieve a similar functionality for your own application, consider generating light/dark stylesheets for your custom classes. For instance, convert white to $custom-class-background and produce two separate stylesheets: one for light with $custom-class-background:white and another for dark with $custom-class-background:black.

Subsequently, your application can seamlessly switch between these stylesheets when switching between the Clarity themes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for saving Web page changes permanently

After tweaking the background color and fonts on a website, I want these changes to stick for future visits. However, every time I refresh the site, it reverts back to its original design. Is there a way to make these modifications permanent, whether usin ...

Can you explain why the .js code is causing such high CPU usage in popular video players?

Why is the .js code running continuously even when the video is paused and there is no user interaction? I observed this phenomenon on a Windows 10 Atom Tablet, particularly when in energy-saving mode. The CPU usage for video playback and decoding almost ...

Move the element outside of the parent container

I am in the process of creating a collapsible sidebar using bootstrap, and I am attempting to have a submenu appear outside of the sidebar when it is toggled to a mini navigation. For example: When the window size is greater than 767 pixels and you click ...

place an icon on the left side of a tag in tailwind CSS while keeping text in the center

Is there a way to align an icon to the left side of a link while keeping the text centered at the same time? <div className="max-w-screen-2xl mx-auto sm:px-6 lg:px-8"> <Link href="#" className="px-6 py-3 mt-2 fle ...

Encountering a problem with AJAX 'post' method while trying to post HTML elements

Incorporating AJAX to transmit the content of a div to my C# MVC controller. The structure of the AJAX post is as follows: $.ajax({ url: '/Home/SaveContent', type: 'POST', data: { model: modelDataJson, activ ...

Dynamically loading audio references in a foreach loop using C# MVC

One approach I am exploring involves utilizing a foreach loop to play an audio file by first storing a reference to the sound. The method in place successfully achieves this using <audio controls> <source src="~/Sounds/@item.Irish_Tr" id="@ ...

Code Snippet: Adjust Table Column Alignment using CSS

Apologies for the basic question, as I am new to CSS. Below is the UI that I am working with: https://i.stack.imgur.com/crAYE.png Here is the code that corresponds to the UI: <div class="row centered-form center-block"> <div cla ...

Unable to view the image in browsers other than Internet Explorer

On a webpage, there is a feature where clicking on the "Add More" link should display an input box and a "Delete" button image. Surprisingly, this functionality works perfectly on IE browsers, but not on Mozilla or Chrome. In non-IE browsers, only the text ...

What is the best way to ensure a DIV fills the entire page without using "position: absolute;"?

I am currently working on designing a webpage layout with multiple headers, main content, and a footer. My goal is to use the jQuery UI tabs widget in the main content area with a border around it. The div should span the entire space between the headers ...

Storing various data inputs in a database via an HTML form with PHP

Currently, I am facing a challenge in adding multiple values to a database using PHP from an HTML form. The issue is that I am unable to simply refer to the name attribute of the HTML form because each field in the form is dynamically generated by a PHP sc ...

Having difficulty accessing the live server on VS Code for download

I'm having trouble installing the live server extension in my VS Code. When I search for "live server" in the extensions marketplace, I can't seem to find it among the results. Can someone please suggest an alternative method for installation? ...

Looking to automate the scraping of Wikipedia info boxes and displaying the data using Python for any Wikipedia page?

My current project involves automating the extraction and printing of infobox data from Wikipedia pages. For example, I am currently working on scraping the Star Trek Wikipedia page (https://en.wikipedia.org/wiki/Star_Trek) to extract the infobox section d ...

Using regular expressions to extract URLs from code in Python

My research involves a dataset of newspaper article links, but I've run into an issue. The links in the dataset all end with .ece extension, which is causing problems due to some API restrictions. http://www.telegraaf.nl/telesport/voetbal/buitenlands ...

The font size in the Android Chrome browser appears different when switched between portrait and landscape modes

I have uploaded a screenshot here, but I am puzzled as to why the font size appears differently on the Android browser in portrait and landscape modes. $(document).ready(function(e) { var x=$(".main").css("font-size"); alert(x) }); .main{ font-size: ...

Constantly centered div

I'm dealing with a situation like this: .center_position_div{ width:100%; background-color:green; display: flex; flex-wrap: wrap; } .show_running_exam { width: 22%; background-color:aliceblue; margin-left: 1%; margi ...

If a radio button is chosen, the input field must be filled out

Can someone assist me with this issue? I currently have 2 radio buttons and it is mandatory to select one of them. If the user chooses the first option and submits the form, the information gets sent successfully as intended. However, if the user select ...

Is it possible to conceal the "Image not found" error icon without the need for "this.style.display = 'none'"?

Creating multiple image boxes within a span element without a predetermined src is the task I have set for myself in JavaScript, specifically for a basic game of blackjack. Below is the current HTML code for the span of image boxes: Note: This site is not ...

What is the best way to utilize d3.domain for extracting both d3.min and d3.max values from various columns within a JSON dataset?

I have a JSON file that contains data from different years for "male," "female," and "both" categories. I want to set the minimum value in my domain to be the lowest value across all three columns and do the same for the maximum value. Is there a way for ...

verify access with mysql database

Need urgent assistance, sorry if this is a repeated query due to my username! I am facing an issue with my login page. I want it to redirect to my home page when authentication fails by cross-checking input with a MySQL database which should output succes ...

A fading transparency box on the border

Looking for a box with varying opacity from left to right (See image for reference - the red marked box has decreasing opacity from right to left). Here is my attempt: .waterMark { background-color: #FFFFFF; float: right; opacity: 0.6; position: ...