Basic example
Chips are compact elements that represent an input, attribute, or action.
The most common use will be used in some form of input, in fields, such as an entity or different attribute. You can add an optional close button so the user can easily close it or dismiss selected element.
Text
John Doe
John Doe
John Doe
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl bg-zinc-50 px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:!shadow-none dark:bg-neutral-700 dark:text-white"
data-twe-close="true">
Text
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl bg-zinc-50 px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:!shadow-none dark:bg-neutral-700 dark:text-white">
<img
class="my-0 -ms-3 me-2 h-[inherit] w-[inherit] rounded-full"
src="https://tecdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp"
alt="Contact Person" />
John Doe
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-[42px] cursor-pointer items-center justify-between rounded-[21px] bg-zinc-50 px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:!shadow-none dark:bg-neutral-700 dark:text-white">
<img
class="my-0 -ms-3 me-2 h-[inherit] w-[inherit] rounded-full"
src="https://tecdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp"
alt="Contact Person" />
John Doe
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-[52px] cursor-pointer items-center justify-between rounded-[26px] bg-zinc-50 px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:!shadow-none dark:bg-neutral-700 dark:text-neutral-200">
<img
class="my-0 -ms-3 me-2 h-[inherit] w-[inherit] rounded-full"
src="https://tecdn.b-cdn.net/img/Photos/Avatars/avatar-6.webp"
alt="Contact Person" />
John Doe
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
// Initialization for ES Users
import {
Chip,
Ripple,
initTWE,
} from "tw-elements";
initTWE({ Chip, Ripple });
Outline
You can use outline styling in your chips.
Primary
Secondary
Success
Danger
Warning
Info
Light
Dark
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-primary bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-primary-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Primary
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-secondary bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-secondary-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Secondary
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-success bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-success-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Success
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class=" [word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-danger bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-danger-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Danger
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-warning bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-warning-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Warning
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-info bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-info-600 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Info
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-neutral-200 bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-neutral-400 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Light
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
<div
data-twe-chip-init
data-twe-ripple-init
class="[word-wrap: break-word] my-[5px] me-4 flex h-8 cursor-pointer items-center justify-between rounded-2xl border border-neutral-800 bg-[transparent] px-3 py-0 text-[13px] font-normal normal-case leading-loose text-surface shadow-none transition-[opacity] duration-300 ease-linear hover:border-neutral-900 hover:!shadow-none active:bg-zinc-50 dark:text-white active:dark:bg-neutral-700"
data-twe-ripple-color="dark">
Dark
<span
data-twe-chip-close
class="float-right w-4 cursor-pointer ps-1 text-[16px] text-black/30 opacity-[.53] transition-all duration-200 ease-in-out hover:text-black/50 dark:text-white/30 dark:hover:text-white/50 [&>svg]:h-4 [&>svg]:w-4">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor">
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12" />
</svg>
</span>
</div>
// Initialization for ES Users
import {
Chip,
Ripple,
initTWE,
} from "tw-elements";
initTWE({ Chip, Ripple });
Placeholder
Type a name and press enter to add a tag. Click X to remove it.
<div
data-twe-chips-input-init
data-twe-chips-placeholder
class="mb-0 min-h-[45px] border-none pb-0 shadow-none outline-none transition-all duration-300 ease-[cubic-bezier(0.25,0.1,0.25,1)] hover:cursor-text"></div>
// Initialization for ES Users
import {
ChipsInput,
initTWE,
} from "tw-elements";
initTWE({ ChipsInput });
Initial Value
You can set initial tags with js options.
<div
id="chips-initial"
data-twe-chips-initial
class="mb-0 min-h-[45px] border-none pb-0 shadow-none outline-none transition-all duration-300 ease-[cubic-bezier(0.25,0.1,0.25,1)] hover:cursor-text"></div>
import { ChipsInput } from "tw-elements";
const chipsInitial = document.querySelector("#chips-initial");
const chipsInitialInstance = new ChipsInput(chipsInitial, {
initialValues: [
{ tag: "MDBReact" },
{ tag: "MDBAngular" },
{ tag: "MDBVue" },
{ tag: "MDB5" },
{ tag: "MDB" },
],
});
const chipsInitial = document.querySelector("#chips-initial");
const chipsInitialInstance = new twe.ChipsInput(chipsInitial, {
initialValues: [
{ tag: "MDBReact" },
{ tag: "MDBAngular" },
{ tag: "MDBVue" },
{ tag: "MDB5" },
{ tag: "MDB" },
],
});
Content editable
You can set content editable with setting an option editable
to
true or with data-twe-attributes
<div
data-twe-chips-input-init
data-twe-chips-placeholder
class="mb-0 min-h-[45px] border-none pb-0 shadow-none outline-none transition-all duration-300 ease-[cubic-bezier(0.25,0.1,0.25,1)] hover:cursor-text"
data-twe-editable="true"></div>
// Initialization for ES Users
import {
ChipsInput,
initTWE,
} from "tw-elements";
initTWE({ ChipsInput });
Related resources
Tutorials:
Extended Docs:
colors
icons
alerts
avatar
badges
buttons
list group
placeholders
inputs
textarea
border opacity
borders
color picker
colors
display flex
letter spacing
position
spacing
visibility hidden