Issues arise when trying to implement Angular SCSS with ngx-datatable

I am encountering an issue with my SCSS. It seems that the CSS command from the SCSS file below is not being utilized. This particular SCSS file is generated with the component.

Interestingly, when I place the code in the styles.scss file included in the angular.json file, the command works without any problems. Originally, I thought that the styles.scss was overriding the code, but it appears that I can override the code from styles.scss in the component's SCSS as well.

My goal is to have a hover effect on a cell within a specific datatable only. When I write the code in the styles.scss, it impacts every table rather than just the one I need. That’s why it is essential for me to have it in the component's SCSS file.

example.component.ts file

@Component({
    selector: 'app-example.component',
    templateUrl: './example.component.html',
    styleUrls: ['example.component.scss']
    })
    

example.component.scss file

.ngx-datatable:not(.cell-selection) .datatable-body-row:hover
    {
       background: blue;
    }
    

Answer №1

If you want to modify the internal styles of a component, you can achieve this by using /deep/ or ::ng-deep (depending on the Angular version you're working with)

Here is an example of how to implement it:

Outdated Method

.ngx-datatable:not(.cell-selection) /deep/ .datatable-body-row:hover
{
   background: blue;
}

Recommended Approach

.ngx-datatable:not(.cell-selection) ::ng-deep .datatable-body-row:hover
{
   background: blue;
}

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

Bug with the button and text input feature in Firefox

I am facing a strange issue where the button and input have the same CSS (except for the background), but Firefox is displaying them differently. This problem does not occur in IE or Chrome. #searchInput { width: 80%; margin: 0 auto; display: ...

Utilizing identical child components in Angular 2 parent component

My goal is to have a page with 2 tabs, each containing a table. To simplify the structure of the tables, I decided to create a custom component for a table and use it as a child component. Here is how I structured my parent page: <p-tabPanel> ...

Tracking the progress of an AJAX call with a progress bar or progress status

Using an ajax call, I want to display progress status inside a text box. Below is the code for the ajax call: <input type="text" name="cm" id="cm" /> <script type="text/javascript" language="javascript"> $('#cm').blur(function() ...

Encountered an issue during the transition from Angular 7 to Angular 9

After following the advice in the second response of this discussion, I successfully upgraded to Angular 9. However, I am now encountering an issue in the browser console when running my project. https://i.sstatic.net/esAXf.png Package.json "dependencie ...

It appears that the font in style.css is not being updated properly and seems to resemble

My issue lies within my CSS code. The text on my website is not displaying correctly and seems to be ignoring the styling that I have applied. Even though I have used similar styling on other buttons which look fine, this specific text element is causing p ...

What methods are recommended for expanding the size of a select/dropdown menu?

Managing a long list of values can be challenging, especially when it continues to grow. Consider the following example: <select> <option value="1">1, some test</option> <option value="2">2, some text</option> <optio ...

An issue within the component.ts file is preventing Angular from correctly rendering the content

As a newcomer to Angular, I encountered an issue when trying to run my angular app. Instead of displaying the content as expected, all I see is a blank page. Upon inspecting it, I noticed that the app-root element was empty. So, I decided to take a look at ...

How can I populate a <select> tag with options dynamically using C# when the page loads?

I am using jQuery ajax to populate cascaded dropdown elements from a database. The issue I'm facing is that I can't seem to add the default "Select Program" option at the top of my first dropdown dynamically. Even though I tried using the prepend ...

Updating HTML element classnames with React hooks

My goal is to remove an attribute from an HTML element when a button is clicked: import React , {useState} from 'react'; import classNames from 'classnames'; function App () { const [isActive, setIsActive] = useState(false); co ...

How can you create an accordion menu that expands when a button is clicked?

Is there a way to make an accordion menu open when the 'More' button is clicked? I've tried, but it always starts in its expanded state and collapses when the button is clicked. What I really want is for the accordion to be closed initially ...

Tips for retrieving the chosen value from a dropdown list in HTML

I'm having an issue with exporting specific values from multiple HTML tables into an excel file. My goal is to only export the selected values from each table, with each table being on a separate tab in the excel file. Currently, when I export the ta ...

Issue with Jekyll (seems like the stylesheet is missing?)

While attempting to fork a Jekyll theme and build the Github Page, I noticed that the generated page looks different from the original one I followed the instructions to change the baseurl in _config.yml, without making any other modifications. The only ...

HTML5 full-screen API and its compatibility with different browsers

I'm curious to know the level of support for HTML5 full-screen API in popular browsers. Which is the earliest version of each browser that fully supports it? And for any browsers that don't (like IE I suppose), are there third-party libraries ava ...

The sidebar's background is cut off before reaching the bottom when scrolling

I have been working on creating a sidebar that includes a background image with a transparent overlay. However, I encountered an issue where the overlay background does not stretch all the way to the bottom when the scroll bar becomes visible. Despite sett ...

The Angular project I am hosting on GitHub Pages seems to be having trouble locating its files, leading to a

After successfully building an Angular project using the ng build command, I ran into an issue when uploading it to a GitHub repository and creating its GitHub Page. Despite working perfectly locally, none of the bundle files could be found when accessing ...

When floating divs with varying heights are wrapped, they may become stuck in place

Hey there! Let's tackle a challenge: I've got a few divs, each with varying heights. These divs contain portlets that can expand in height. Here's a basic example: .clz { float: left; } <div class="container"> <div class="cl ...

Tips for running a dry default with Angular CLI

Query: Can dry-run be set as the default in a configuration? Purpose: Enabling dry-run by default simplifies the learning process by minimizing clean-up tasks if the command is not correct. This can encourage users to always perform a test run before exec ...

anchor to # inquiry

I'm curious about the href link and its usage, I tried looking it up online but didn't find much information. Here is an example of a href link I have: <a href='#' onclick='openSerialWindow();return false;'><h:output ...

Dynamically pass a template to a child component

How can I dynamically load content on my page based on the active navigation point? export class Sub_navigation_item { constructor( public title: string, public templateName: string ) {} } I have a navigation item with an ID from an ...

Utilizing Bootstrap to create a responsive design with a full-height view on the body,

While adjusting the page width in Chrome dev tools, I noticed that the page also increases vertically. It appears that Bootstrap is assuming a viewport height larger than what it actually is. Here is the relevant code snippet: <!DOCTYPE html> <ht ...