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

79
Views
Add shaddow to indicate scroll on an overflow element

I want to add some shadow to my table (or the container around my table) to indicate that there is more columns in it so the user knows he should scroll horizontally. I am wondering how I can accomplish this.

I have created this example where I am accomplishing what I want when you remove the background color on the commented line:

import React from 'react'
import styled from 'styled-components'

const ScrollContainer = styled.div`
  width: 200px;
  overflow-x: scroll;
  box-shadow: 10px 0px 10px -10px black inset;
  box-shadow: -10px 0px 10px -10px black inset;
`
const Container = styled.div`
  width: 100%;
`
const Box = styled.div`
  width: 500px;
  height: 500px;
`

const BlueBox = styled(Box)`
  background: lightblue; // If you remove this, I get what I want, but this background color is overlapping the box-shadow
`

export default function App() {
  return (
    <>
      <ScrollContainer>
        <Container>
          <BlueBox />
        </Container>
      </ScrollContainer>
    </>
  )
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I just figured it out. Check out the two added lines with comments on it:

import React from 'react'
import styled from 'styled-components'

const ScrollContainer = styled.div`
  width: 200px;
  overflow-x: scroll;
  box-shadow: 10px 0px 10px -10px black inset;
  box-shadow: -10px 0px 10px -10px black inset;
`
const Container = styled.div`
  width: 100%;
`
const Box = styled.div`
  width: 500px;
  height: 500px;
`

const BlueBox = styled(Box)`
  position: relative; // Added this line
  z-index: -1; // and this line
  background: lightblue;
`

export default function App() {
  return (
    <>
      <ScrollContainer>
        <Container>
          <BlueBox />
        </Container>
      </ScrollContainer>
    </>
  )
}

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!