Add overflow, animation-timeline and an animation of inset box-shadows to the element. A large shadow on the right is visible when the element is overflowing, as it is scrolled the right shadow is reduced and a small left shadow is added. Once the full width has been scrolled the right shadow is removed and the left shadow is increased.
.scroll-shadow-inline {
--shadow-color: rgb(0 0 0 / .2);
--shadow-size: 8px;
--shadow-spread: calc(var(--shadow-size) * -.5);
overflow-x: auto;
animation: scroll-shadow-inset linear;
scroll-timeline: --scroll-shadow-timeline inline;
animation-timeline: --scroll-shadow-timeline;
}
@keyframes scroll-shadow-inset {
from {
box-shadow:
inset calc(var(--shadow-size) * -2) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color),
inset calc(var(--shadow-size) * 0) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color);
}
10%, 90% {
box-shadow:
inset calc(var(--shadow-size) * -1) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color),
inset calc(var(--shadow-size) * 1) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color);
}
to {
box-shadow:
inset calc(var(--shadow-size) * 0) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color),
inset calc(var(--shadow-size) * 2) 0 var(--shadow-size) var(--shadow-spread) var(--shadow-color);
}
}