Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
How to have dimmed content on Semantic UI React (NextJS)

Im having a problem on implementing dimmed content on semantic ui react sidebar on nextjs...

This is the dimmed content on semantic ui enter image description here https://react.semantic-ui.com/modules/sidebar/#states-dimmed

this is my layout code:

import React, { useState } from 'react';
import CartSidebar from './CartSidebar';
import Navbar from './Navbar';

const StoreLayout = ({ children }) => {
  const [toggleCart, setToggleCart] = useState(false);
  function toggleMenuCart() {
    setToggleCart(!toggleCart);
  }
  return (
    <>
      <CartSidebar toggleMenu={toggleCart} />
      <Navbar onToggleMenuCart={toggleMenuCart} />
      {children}
    </>
  );
};

export default StoreLayout;

this is my navbar code:

  <nav>
   <div className="borderLeftList">
    <li className="cart">
     <Button
       onClick={props.onToggleMenuCart}
       className="cart-icon empty"
     />
    </li>
   </div>
  </nav>

this is my sidebar code:

import React, { useState } from 'react';
import cn from 'classnames';
import { Icon, Menu } from 'semantic-ui-react';
import Link from 'next/link';

export default function CartSidebar(props) {
  const classes = cn(
    'ui',
    'sidebar',
    'push',
    'right',
    'inverted',
    'menu',
    'vertical',
    'animating',
    { visible: props.toggleMenu }
  );

  return (
    <div className={classes}>
      <Menu.Item as={Link} href="/admin">
        <a>
          <i className="fa fa-home" />
          Dashboard
        </a>
      </Menu.Item>

      <Menu.Item as={Link} href="/admin/orders">
        Second Menu
      </Menu.Item>
      <Menu.Item as={Link} href="/admin/products">
        Third Menu
      </Menu.Item>
    </div>
  );
}

this is my _app.js code:

   <StoreLayout>
     <Component {...pageProps} />
   </StoreLayout>

if you need any more details you can ask on the comment... Thank you so much in advance!!! :)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The documentation shows it will dim all of its children:

<Dimmer active={true} page>
  <ChildComponent/>
</Dimmer>

Which will then dim the child component. Along with that you can also specify properties like "page" to tell it to dim the whole page.

If you're trying to use it with sidebar, then you have to wrap the content for sidebar in a dimmer.

const Page = () => {
  const [active, setActive] = useState(false)

  return <div>
    <Sidebar setActive={setActive}/>
    <Dimmer active={active} page> // this is a child
      <Content/>
    </Dimmer>
  </div>
}

Then in the sidebar you'll have to set the active when you click an item or whatever. This example isn't perfect, just gives you a rough idea of what you can do.

Alternatively:

.dimmed {
  background: black;
  opacity: 0.5;
}

You can also just do it yourself and apply a class with opacity to whatever needs to be dimmed.

about 4 years ago · Juan Pablo Isaza Report

0

CREDITS ON @Matriarx for giving me idea on how to answer his question...

You have to import the Dimmer on sematic-ui-react and then parent the child using this code:

 <Dimmer.Dimmable dimmed={toggleCart}>
        <Dimmer
          className="dimmedContent"
          active={toggleCart}
          onClickOutside={handleHide}
        />

put this on your css so that you can give yourself a style, without this css you cant make the dimmed fullscreen

.dimmedContent {
  display: block !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.25) !important;
  cursor: default !important;
  z-index: 8 !important;
}

this is the full code:

import React, { useState } from 'react';
import { Dimmer } from 'semantic-ui-react';
import CartSidebar from './CartSidebar';
import Navbar from './Navbar';

const StoreLayout = ({ children }) => {
  const [toggleCart, setToggleCart] = useState(false);
  function toggleMenuCart() {
    setToggleCart(!toggleCart);
  }
  const handleHide = () => {
    setToggleCart({ active: false });
  };
  return (
    <>
      <Dimmer.Dimmable dimmed={toggleCart}>
        <Dimmer
          className="dimmedContent"
          active={toggleCart}
          onClickOutside={handleHide}
        />
      <CartSidebar toggleMenu={toggleCart} />
      <Navbar onToggleMenuCart={toggleMenuCart} />
      {children}
      </Dimmer.Dimmable>
    </>
  );
};

export default StoreLayout;

also dont forget to put the css that i provided above :)

Cheers!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!