simple-datatables icon indicating copy to clipboard operation
simple-datatables copied to clipboard

How to adjust width of search input field

Open Trilarion opened this issue 4 years ago • 7 comments

I'd like to have a wider search input field. I did not find anything obvious about that in the documentation (some option maybe) or in the css (no css class called search in the style.css file). I couldn't even determine where exactly the width (170px) is set.

If it's not yet possible conveniently, maybe that could become a feature proposal.

Trilarion avatar Oct 27 '21 14:10 Trilarion

looking via chrome-dev tool, i see that the css is dataTable-input (since it is a input-field) wrapped in a div class="dataTable-search" something like: .dataTable-search { width:400px <- your width specification } .dataTable-input { width:100% <- make the input the same size as the wrapper div }

will do the job?

DNWEIJ avatar Nov 19 '21 07:11 DNWEIJ

That does the job. I wonder though, how the default width of the search field is determined without this override, and maybe setting this could become an option in the data table creation.

Trilarion avatar Nov 19 '21 09:11 Trilarion

It seems to me like this is an issue that can be resolved entirely in CSS. Everyone will want a different style for their tables, so I don't really see why we should include something about this in the package. Else someone else will want to include an option "to make the headers bold and yellow and comic sans". Or am I misunderstanding something?

johanneswilm avatar Nov 19 '21 09:11 johanneswilm

Yes, that seems right. It's more to do with styling. The only thing maybe might be more reasonable default values. The search field seems very small by default, a larger width might reduce the need to adapt the CSS for some people.

Trilarion avatar Nov 19 '21 10:11 Trilarion

Ok, but the default value of 20 characters is given by means of the W3C [1], right? So if you want to change it, you'd need to engage with them. As far as I can tell, we don't define any styling that changes the default size your browser sets for text input fields. Or am I missing something?

[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size

johanneswilm avatar Nov 19 '21 10:11 johanneswilm

:) Okay, thanks for the link. If I ever have the free time I will take it to them. Of course one could say that this field here is not just any ordinary text input field but a search input field, so one could set a different reasonable default here, if only to make it easier for users who might then have less to adjust the CSS by themselves.

Trilarion avatar Nov 19 '21 10:11 Trilarion

We could change it to a search field: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search That would be semantically more correct. However, it looks like even for that kind of field, the default width is 20 characters.

johanneswilm avatar Nov 19 '21 11:11 johanneswilm