Skip to content

Commit 98122e0

Browse files
committed
feat: add classInput and classDvgDiv to Tablesearch
1 parent b82b03a commit 98122e0

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/lib/tables/TableSearch.svelte

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
export let customColor: string = '';
1111
export let color: 'blue' | 'green' | 'red' | 'yellow' | 'purple' | 'default' | 'custom' = 'default';
1212
export let innerDivClass: string = 'p-4';
13+
export let searchClass: string = 'relative mt-1';
14+
export let svgDivClass: string = 'absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none';
15+
export let svgClass: string = 'w-5 h-5 text-gray-500 dark:text-gray-400';
16+
export let inputClass: string = 'bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-80 pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500';
17+
18+
let inputCls = twMerge(inputClass, $$props.classInput);
19+
let svgDivCls = twMerge(svgDivClass, $$props.classSvgDiv);
1320
1421
const colors = {
1522
default: 'text-gray-500 dark:text-gray-400',
@@ -27,15 +34,17 @@
2734
</script>
2835

2936
<div class={divClass}>
30-
<div class="{innerDivClass}">
37+
<div class={innerDivClass}>
3138
<label for="table-search" class="sr-only">Search</label>
32-
<div class="relative mt-1">
33-
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
34-
<svg class="w-5 h-5 text-gray-500 dark:text-gray-400" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
35-
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
36-
</svg>
39+
<div class={searchClass}>
40+
<div class={svgDivCls}>
41+
<slot name="svgSearch">
42+
<svg class={svgClass} fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
43+
<path fill-rule="evenodd" d="M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z" clip-rule="evenodd" />
44+
</svg>
45+
</slot>
3746
</div>
38-
<input bind:value={inputValue} type="text" id="table-search" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-80 pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" {placeholder} />
47+
<input bind:value={inputValue} type="text" id="table-search" class={inputCls} {placeholder} />
3948
</div>
4049
<slot name="header" />
4150
</div>

src/routes/docs/components/table.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ The component has the following props, type, and default values. See [types page
861861
### TableSearch styling
862862

863863
- Use the `class` prop to overwrite the `table` tag class.
864+
- Use the `classInput` prop to overwrite `inputClass`.
865+
- Use the `classSvgDiv` prop to overwrite `svgDivClass`.
864866

865867
<CompoAttributesViewer {components}/>
866868

0 commit comments

Comments
 (0)