Make sure to consistently show the rating bubble within the md-slider

I am currently exploring the functionality of md-slider in its md-discrete mode. However, I would like to have the slider bubble always visible on the screen, similar to this:

I do not want the slider bubble to disappear when clicking elsewhere. Is there a way to achieve this desired behavior?

Answer №1

To modify the appearance of the bubbles, you can override specific CSS rules that control their display. By default, the bubbles are only visible during active or focus states using the following rule:

md-slider[md-discrete]:not([disabled]):focus .md-sign,
md-slider[md-discrete]:not([disabled]):focus .md-sign:after,
md-slider[md-discrete]:not([disabled]).active .md-sign,
md-slider[md-discrete]:not([disabled]).active .md-sign:after {
  opacity: 1;
  -webkit-transform: translate3d(0, 0, 0) scale(1);
  transform: translate3d(0, 0, 0) scale(1);
}

To always display the bubbles, you can create a new absolute rule like this:

md-slider[md-discrete] .md-sign,
md-slider[md-discrete] .md-sign:after {
  opacity: 1;
  -webkit-transform: translate3d(0, 0, 0) scale(1);
  transform: translate3d(0, 0, 0) scale(1);
}

Check out the demo here

Answer №2

A different method to create a shortcut is to utilize onblur="this.focus()" in this manner:

<md-slider id="my-slider" flex onblur="this.focus()" md-discrete ng-model="3" min="1" max="5" aria-label="rating">

Then, within the JavaScript code, add:

$("#my-slider").focus();

Answer №3

After trying multiple solutions, I finally found the one that resolved my issue. Simply adding the css class "_md-active" to the slider did the trick for me.

document.getElementById("YOUR-MD-SLIDER-ID").classList.add("_md-active");

Answer №4

When it comes to md-slider, there are two main components: md-track-container and md-thumb-container. These parts can be customized using CSS to suit your needs perfectly. Below is both an image demonstration and the accompanying code snippet for reference.

<md-slider title="md-title" style="margin-top: -31px;margin-left: 45px;" id="red-slider" md-discrete="" round="0" ng-model="" step="5" min="0" max="100" aria-label="rating" class="ng-pristine ng-untouched ng-valid ng-isolate-scope ng-empty" tabindex="0" role="slider" aria-valuenow="55" aria-invalid="false" aria-valuemin="0" aria-valuemax="100">
<div class="md-slider-wrapper">
    <div class="md-track-container">
        <div class="md-track"></div>
        <div class="md-track md-track-fill" style="width: 55%;"></div>
        <div class="md-track-ticks"><canvas style="position:absolute;" width="151" height="5"></canvas> </div>
    </div>
    <div class="md-thumb-container" style="left: 55%;">
        <div class="md-thumb"></div>
        <div class="md-focus-thumb"></div>
        <div class="md-focus-ring"></div>
        <div class="md-sign"><span class="md-thumb-text">55</span></div><div class="md-disabled-thumb"></div>
    </div>
</div>
</md-slider>

CSS:

md-slider[md-discrete] .md-track-container,
md-slider[md-discrete] .md-track-container:after {
  height: 5px;
}

md-slider[md-discrete] .md-track-ticks,
md-slider[md-discrete] .md-track-ticks:after {
  display: none;
}

https://i.sstatic.net/Tt349.jpg

Answer №5

Always displaying the bubble

.mat-slider-horizontal .mat-slider-thumb-label {
    transform: rotate(45deg) !important;
}

Ensuring text visibility

.mat-slider-thumb-label-text {
    opacity: 1 !important;
}

Customizing thumb colors

.mat-slider-min-value.mat-slider-thumb-label-showing .mat-slider-thumb, 
.mat-slider-min-value.mat-slider-thumb-label-showing .mat-slider-thumb-label {
    background-color: green;
}

Adjusting fill color

.mat-accent .mat-slider-track-fill, .mat-accent .mat-slider-thumb, .mat-accent .mat-slider-thumb-label {
    background-color: $greenColor;
}

Answer №6

Here's the method that worked for me:

::ng-deep {
  .mat-slider-thumb-label {
    transform: rotate(45deg) !important;
    border-radius: 50% 50% 0 !important;
  }  
  .mat-slider-thumb {
    transform: scale(0) !important;
  }  
  .mat-slider-thumb-label-text {
    opacity: 1 !important;
  }
}

I found this solution from user michaelpwilson on this page: https://github.com/angular/components/issues/4803

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

What is the best way to conceal a component in AngularJS while still allowing an external library to connect to it seamlessly?

In the code I'm working with, there is a similar structure to this: <div ng-if="variableThatEvaluatesToFalse"> <input id="location"> </div> I'm attempting to hide a component initially and then display it based on user inpu ...

What are the steps to create a reliable menu?

Looking to add a fixed menu to my website that stays at the top even when scrolling down the page. For an example, check out iplex.co.in for a demonstration. ...

Looking to recreate this style of table using HTML and CSS?

https://i.sstatic.net/nDrxq.png Trying to replicate the layout from this image for my blog, but struggling with the source code. Any suggestions on how to achieve a similar design without using divs within table rows? Looking for a cleaner solution. ...

Is it possible to extract the CSS path of a web element using Selenium and Python?

I am working with a collection of elements using find_elements_by_css_selector, and my next task is to extract their css locators. I attempted the following approach: foo.get_property('css_selector') However, it seems to be returning None. ...

Admin template system for CodeIgniter

In order to give the Administrator the ability to customize the Admin Dashboard Layout and provide an option for them to upload their own layouts or "Premium" layouts, I need to implement a solution. I have considered one approach: Utilizing CSS (allowin ...

What is the best way to cut out a portion of a div using CSS?

I have a scaled down version of my project, but it's not quite what I need. I would like the green div to have some transparency so that the content behind both divs is visible (there is none in the example, but there is in my actual project). However ...

Utilizing ngModel within the controller of a custom directive in Angular, instead of the link function

Is there a way to require and use ngModel inside the controller of a custom Angular directive without using the link function? I have seen examples that use the link function, but I want to know if it's possible to access ngModel inside the directive ...

Dynamic value in Angular select using ng-initExperience the power of Angular select

When working with Angular, I encountered an issue trying to set a default value for a select box using ng-init from an object that is generated during runtime. Here's the code snippet that's causing me trouble: <select ng-model= ...

NodeJS plus AngularJS utilizing the $http GET request

I'm currently working with Nodejs and AngularJS, and I've encountered an issue regarding populating a table in the front-end from a generated JSON file. Below is my ejs file: <% include layout %> <div class="panel panel-info"> < ...

The ng-repeat function is unable to fetch data from a JSON file

Within my AngularJS framework template, I have the following snippet of html code: <ul class="sb-parentlist"> <h1 class={{headerClass}}> Popular</h1><div data-ng-repeat="data in data track by $index"> <li> ...

What is the correct way to create a card outline in Bootstrap?

I am currently developing a Django website to enhance my skills in coding, CSS, Html, and Bootstrap. However, I am encountering an issue with the main page of my site. The visuals on my cards do not align properly with the colored boxes at the top of the p ...

My form does not receive the Bootstrap classes when using the jQuery script

**Why isn't my jQuery script coloring the rows as expected when certain conditions are met (I italicized the specific part of the code)?** Here is the HTML CODE for the POLL: <form id="pollForm" class="mb-4"> <d ...

Text in React Native exceeding one line is causing it to extend beyond the screen boundaries

I am having trouble displaying the last messages in my simple contact list as the text is getting cut off the screen. Below is the code I am using: (the readableTimestamp should be positioned behind the text.) View style={{ fontSize: 16, backgro ...

Hovering over the image causes it to flicker and it remains the same

I have an image column within a grid, where the images are displayed at 25px x 25px to fit nicely in each row. I've added a hover effect to the images so that when you hover over them, they shift left (which is working) and then expand for better vis ...

What is the best method to shift an element to the top by a fraction of its height, namely -100%?

I am facing an issue with an element where I set top: -100%. My requirement is to translate top: -100% to top: -{height-of-the-element}. Unfortunately, instead of getting top: -{height-of-the-element}, I am getting top: -{height-of-another-element-wrapping ...

Leverage the output from one $http request in AngularJS to make another $http request

My goal is to use $http to fetch data (such as students), then make another $http call to retrieve studentDetails. Next, I want to add a portion of studentDetails to the students JSON. The tricky part is that I need the response from the first call to cre ...

The use of jQuery addClass does not produce any changes

I am trying to modify a single attribute in my class using a JavaScript function. .msg_archivedropdown:before { content:""; display: block; position:absolute; width:0; height:0; left:-7px; top:0px; border-top: 10px solid tr ...

Emphasize multiple anchor points

I am looking to highlight two sections of a page simultaneously. Here is what I currently have: <li class="langLI" style="list-style-type:none"><a href="/non-discrimination-and-language-assistance##French">| French Creole</a></li> ...

Showing different HTML elements based on the link that is clicked

Recently, I delved into the world of web development and decided to test my skills by creating a basic webpage with an interactive top navigation bar. Depending on the link clicked, specific HTML elements would be displayed while turning off others using a ...

Issues arise when HTML components are not functioning correctly upon calling JSON

I'm encountering a challenging issue that's difficult to articulate. Here is a link to a JSFiddle that demonstrates the problem: https://jsfiddle.net/z8L392ug/ enter code here The problem stems from my utilization of a news API for F1 stories. W ...