simplebar icon indicating copy to clipboard operation
simplebar copied to clipboard

Is it possible to set SimpleBar width based on content width?

Open vladimir-djokic opened this issue 4 years ago • 3 comments

💬 Questions and Help

Is it possible to set SimpleBar width based on content width, without using JavaScript to access DOM/Calculate/Update SimpleBar width? Something like (React example):

<SimpleBar className="max-height-20rem width-max-content">
  <MyList />
</Simplebar>
.max-height-20rem {
  max-height: 20rem;
}

.width-max-content {
  width: max-content; /* This obviously does not work /*
}

vladimir-djokic avatar May 11 '21 15:05 vladimir-djokic

+1! The legacy/deprecated jquery.scrollbar allowed the whole scroll area to grow with its content width - even allowing for CSS width transitions. It would be great if this is also possible with simplebar as I migrate to it.

strarsis avatar Jul 22 '21 20:07 strarsis

It works for me:

.simplebar-placeholder {
  width: max-content !important;
}

idefant avatar Jan 13 '24 20:01 idefant

@idefant: That's a good point! The now well-supported CSS keywords make many things possible that were not in the past. Thanks!

strarsis avatar Jan 13 '24 20:01 strarsis