Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

104
Visualizações
muiSlider restrict for certaing range

i'm usign below Mui Slider component for a UI where i have to restrict it's value for certaing range. For example slider's ball will not dragable after 50. user can select values upto 50 but it will show it full range. i didn't found any direct solution so i figured out a bypass with Discrete Slider Values. here's the code sandbox link ,Where i have make a array of full available values. Is there any neat and clean solution ?

<Slider
  size="small"
  defaultValue={30}
  aria-label="Small"
  valueLabelDisplay="auto"
/>
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I think you have to determine max value for yor slider like below

<Slider
   ...
   max={50}
   min={0}
/>

And i see your code and i think you can determine marks array for just labels not all values

about 4 years ago · Juan Pablo Isaza Relatório

0

Hello Fazlay Rabbi it's so simple you need just think out of the box, just need to write simply if condition I write your solution in blow :

import React, { useState } from "react";
import Box from '@mui/material/Box';
import Slider from '@mui/material/Slider';

export default function DiscreteSliderLabel() {
  const [sliderValue, setSliderValue] = useState(0);
  
  const handleChange2 = (event, newValue) => {
   
    if (newValue > 50){
      setSliderValue(50);
    }else{
      setSliderValue(newValue);
    }
    
  };

  return (
    <Box sx={{ width: 300 }}>
      <Slider
        value={sliderValue}
        aria-label="Always visible"
        onChange={handleChange2}
        valueLabelDisplay="on"
      />
    </Box>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda