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

90
Visualizações
How to open the Sidebar so that it sits on over of the main information page

My website has a sidebar (FiltersSideBar in my code) with filters. The sidebar is on the left.

I also made a functionality that would hide the Sidebar at certain sizes of the browser window. The sidebar hides and a button appears with which (I assume) Sidebar can be opened again.

This is where I have a problem. I can't figure out how to open the Sidebar so that it sits on over of the main information page.

App.js

export default function App() {
    const [filters, setFilters] = useState({.....})
    const size = WindowSize();   
    const [setHideSidebar] = useState(false);
 
    return (
        <ThemeProvider theme={theme}>
            <BrowserRouter>
                <Header/>
                <button style={{display: size.width > 600 ? "none" : "inline"}}
                        onClick={() => {setHideSidebar((prev) => !prev);}}>Toggle Sidebar
                </button>
                <AppContext.Provider value={{ filters, setFilters}}>
                    <div style={{display: 'flex'}} >
                        {size.width > 600 && <FiltersSideBar />}
                        <Routes>
                           <Route exact path='/devices/:deviceId/:userId/:sessionId' element={<Records />} />
                            <Route exact path='/devices/:deviceId/:userId/:sessionId/:recordId' element={<Record />} />
                            <Route path="*" element={<Navigate to="/devices" replace />} />
                        </Routes>
                    </div>
                </AppContext.Provider>
                <Footer />
            </BrowserRouter>
        </ThemeProvider>
    );
}

FiltersSideBar.jsx

export default function FiltersSideBar() {
    return (
        <CardContent>
            <Table>
                <TableBody>
                  ......
                </TableBody>
            </Table>
        </CardContent>
    );
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Start by actually using the value set by setHideSidebar

const [filters, setFilters] = useState({.....})
const size = WindowSize();
// Actually use the state here
const [hideSidebar, setHideSidebar] = useState(true);

And then below that, where you are checking if the sidebar can be shown above a certain width, add the following

{size.width > 600 && <FiltersSideBar />}
{size.width <= 600 && !hideSidebar && <FiltersSideBar className="overlay" />}

You'll need to augment your FiltersSideBar component to use the className when it's available:

export default function FiltersSideBar(props) {
    return (
        <CardContent className={props.className}>
            {/* ... */}
        </CardContent>
    );
}

And also you'll need to add the following css somewhere

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9999;
}
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