mirror of
https://github.com/tabler/tabler.git
synced 2026-10-22 23:57:26 +04:00
Support a leading input icon on Tom Select fields (#3300)
This commit is contained in:
1 parent
9d837ea0c3
commit
00746f2446
4 files changed
+34
-1
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@tabler/core": minor
|
||||||
|
"@tabler/docs": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Added `.input-icon` support for Tom Select: a leading icon no longer overlaps the selected value.
|
||||||
@@ -81,6 +81,7 @@ exports[`css custom-property prefixing > leaves vendor-owned names alone and pre
|
|||||||
"--tblr-green",
|
"--tblr-green",
|
||||||
"--tblr-icon-size",
|
"--tblr-icon-size",
|
||||||
"--tblr-info",
|
"--tblr-info",
|
||||||
|
"--tblr-input-icon-padding-start",
|
||||||
"--tblr-light",
|
"--tblr-light",
|
||||||
"--tblr-orange",
|
"--tblr-orange",
|
||||||
"--tblr-primary",
|
"--tblr-primary",
|
||||||
|
|||||||
Vendored
+7
@@ -94,6 +94,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In an `.input-icon`, the wrapper carries the `.form-select` class that gets the room for
|
||||||
|
// the icon, but the preset draws the text in `.ts-control` with its own padding: leave the
|
||||||
|
// room for a leading icon there.
|
||||||
|
.input-icon > .input-icon-addon ~ .ts-wrapper .ts-control {
|
||||||
|
padding-inline-start: var(--input-icon-padding-start);
|
||||||
|
}
|
||||||
|
|
||||||
// Every declaration below is `!important`: the bootstrap5 preset CSS targets
|
// Every declaration below is `!important`: the bootstrap5 preset CSS targets
|
||||||
// these same selectors at equal specificity, and whichever stylesheet is
|
// these same selectors at equal specificity, and whichever stylesheet is
|
||||||
// included last otherwise wins outright (not just for z-index — the preset's
|
// included last otherwise wins outright (not just for z-index — the preset's
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ related: [/ui/forms/select-group, /ui/forms/elements]
|
|||||||
---
|
---
|
||||||
|
|
||||||
import Example from '@components/Example.astro';
|
import Example from '@components/Example.astro';
|
||||||
|
import Icon from '@ui/Icon.astro';
|
||||||
import TabsPackage from '@components/TabsPackage.astro';
|
import TabsPackage from '@components/TabsPackage.astro';
|
||||||
import { Code } from 'astro:components';
|
import { Code } from 'astro:components';
|
||||||
import { site } from '@shared/lib/site.ts';
|
import { site } from '@shared/lib/site.ts';
|
||||||
@@ -146,6 +147,24 @@ Add `.is-valid` or `.is-invalid` to the `<select>` to show a validation state. T
|
|||||||
</div>
|
</div>
|
||||||
</Example>
|
</Example>
|
||||||
|
|
||||||
|
### With an icon
|
||||||
|
|
||||||
|
Put the `<select>` in an [`.input-icon`](/ui/forms/elements#input-with-icon) after an `.input-icon-addon`, as for an input. The icon shows inside the Tom Select field.
|
||||||
|
|
||||||
|
<Example>
|
||||||
|
<div class="input-icon">
|
||||||
|
<span class="input-icon-addon">
|
||||||
|
<Icon name="user" />
|
||||||
|
</span>
|
||||||
|
<select class="form-select" id="select-icon" data-placeholder="Assign to…">
|
||||||
|
<option value="">Assign to…</option>
|
||||||
|
<option value="1">Jane Doe</option>
|
||||||
|
<option value="2">Mark Smith</option>
|
||||||
|
<option value="3">Amy Kim</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</Example>
|
||||||
|
|
||||||
### Rich options
|
### Rich options
|
||||||
|
|
||||||
An option can carry extra markup - an avatar, a flag, a badge - through a `data-custom-properties` attribute. Read it in a custom `render.option` / `render.item` function and show it next to the option text.
|
An option can carry extra markup - an avatar, a flag, a badge - through a `data-custom-properties` attribute. Read it in a custom `render.option` / `render.item` function and show it next to the option text.
|
||||||
@@ -218,7 +237,7 @@ window.addEventListener('load', function () {
|
|||||||
return '<div>' + escape(data.text) + '</div>';
|
return '<div>' + escape(data.text) + '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
['select-overview', 'select-basic', 'select-placeholder', 'select-multiple', 'select-optgroup', 'select-valid', 'select-invalid'].forEach(function (id) {
|
['select-overview', 'select-basic', 'select-placeholder', 'select-multiple', 'select-optgroup', 'select-valid', 'select-invalid', 'select-icon'].forEach(function (id) {
|
||||||
var el = document.getElementById(id);
|
var el = document.getElementById(id);
|
||||||
if (el) new TomSelect(el, { copyClassesToDropdown: false, dropdownParent: 'body' });
|
if (el) new TomSelect(el, { copyClassesToDropdown: false, dropdownParent: 'body' });
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user