switch-icon.mdx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. ---
  2. title: Switch icon
  3. summary: The Switch Icon component is used to create a transition between two icons. You can use any icon, both line and filled version.
  4. banner: icons
  5. description: Transition between two icons smoothly.
  6. ---
  7. ## Default markup
  8. The icon transition is triggered by adding an `.active` class to the `switch-icon` component.
  9. ```html example centered
  10. <button class="switch-icon" data-bs-toggle="switch-icon">
  11. <span class="switch-icon-a text-secondary">
  12. <svg
  13. xmlns="http://www.w3.org/2000/svg"
  14. class="icon icon-tabler icon-tabler-heart"
  15. width="24"
  16. height="24"
  17. viewBox="0 0 24 24"
  18. stroke-width="2"
  19. stroke="currentColor"
  20. fill="none"
  21. stroke-linecap="round"
  22. stroke-linejoin="round"
  23. >
  24. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  25. <path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"></path>
  26. </svg>
  27. </span>
  28. <span class="switch-icon-b text-red">
  29. <svg
  30. xmlns="http://www.w3.org/2000/svg"
  31. class="icon icon-tabler icon-tabler-heart-filled"
  32. width="24"
  33. height="24"
  34. viewBox="0 0 24 24"
  35. stroke-width="2"
  36. stroke="currentColor"
  37. fill="none"
  38. stroke-linecap="round"
  39. stroke-linejoin="round"
  40. >
  41. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  42. <path
  43. d="M6.979 3.074a6 6 0 0 1 4.988 1.425l.037 .033l.034 -.03a6 6 0 0 1 4.733 -1.44l.246 .036a6 6 0 0 1 3.364 10.008l-.18 .185l-.048 .041l-7.45 7.379a1 1 0 0 1 -1.313 .082l-.094 -.082l-7.493 -7.422a6 6 0 0 1 3.176 -10.215z"
  44. stroke-width="0"
  45. fill="currentColor"
  46. ></path>
  47. </svg>
  48. </span>
  49. </button>
  50. ```
  51. ## Switch animations
  52. You can also add a fancy animation to add variety to your button. See demo below:
  53. ```html example centered separated
  54. <button class="switch-icon" data-bs-toggle="switch-icon">
  55. <span class="switch-icon-a text-secondary">
  56. <svg
  57. xmlns="http://www.w3.org/2000/svg"
  58. class="icon icon-tabler icon-tabler-circle"
  59. width="24"
  60. height="24"
  61. viewBox="0 0 24 24"
  62. stroke-width="2"
  63. stroke="currentColor"
  64. fill="none"
  65. stroke-linecap="round"
  66. stroke-linejoin="round"
  67. >
  68. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  69. <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"></path>
  70. </svg>
  71. </span>
  72. <span class="switch-icon-b text-primary">
  73. <svg
  74. xmlns="http://www.w3.org/2000/svg"
  75. class="icon icon-tabler icon-tabler-circle-filled"
  76. width="24"
  77. height="24"
  78. viewBox="0 0 24 24"
  79. stroke-width="2"
  80. stroke="currentColor"
  81. fill="none"
  82. stroke-linecap="round"
  83. stroke-linejoin="round"
  84. >
  85. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  86. <path
  87. d="M7 3.34a10 10 0 1 1 -4.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 4.995 -8.336z"
  88. stroke-width="0"
  89. fill="currentColor"
  90. ></path>
  91. </svg>
  92. </span>
  93. </button>
  94. <button class="switch-icon switch-icon-fade" data-bs-toggle="switch-icon">
  95. <span class="switch-icon-a text-secondary">
  96. <svg
  97. xmlns="http://www.w3.org/2000/svg"
  98. class="icon icon-tabler icon-tabler-heart"
  99. width="24"
  100. height="24"
  101. viewBox="0 0 24 24"
  102. stroke-width="2"
  103. stroke="currentColor"
  104. fill="none"
  105. stroke-linecap="round"
  106. stroke-linejoin="round"
  107. >
  108. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  109. <path d="M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572"></path>
  110. </svg>
  111. </span>
  112. <span class="switch-icon-b text-red">
  113. <svg
  114. xmlns="http://www.w3.org/2000/svg"
  115. class="icon icon-tabler icon-tabler-heart-filled"
  116. width="24"
  117. height="24"
  118. viewBox="0 0 24 24"
  119. stroke-width="2"
  120. stroke="currentColor"
  121. fill="none"
  122. stroke-linecap="round"
  123. stroke-linejoin="round"
  124. >
  125. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  126. <path
  127. d="M6.979 3.074a6 6 0 0 1 4.988 1.425l.037 .033l.034 -.03a6 6 0 0 1 4.733 -1.44l.246 .036a6 6 0 0 1 3.364 10.008l-.18 .185l-.048 .041l-7.45 7.379a1 1 0 0 1 -1.313 .082l-.094 -.082l-7.493 -7.422a6 6 0 0 1 3.176 -10.215z"
  128. stroke-width="0"
  129. fill="currentColor"
  130. ></path>
  131. </svg>
  132. </span>
  133. </button>
  134. <button class="switch-icon switch-icon-scale" data-bs-toggle="switch-icon">
  135. <span class="switch-icon-a text-secondary">
  136. <svg
  137. xmlns="http://www.w3.org/2000/svg"
  138. class="icon icon-tabler icon-tabler-star"
  139. width="24"
  140. height="24"
  141. viewBox="0 0 24 24"
  142. stroke-width="2"
  143. stroke="currentColor"
  144. fill="none"
  145. stroke-linecap="round"
  146. stroke-linejoin="round"
  147. >
  148. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  149. <path
  150. d="M12 17.75l-6.172 3.245l1.179 -6.873l-5 -4.867l6.9 -1l3.086 -6.253l3.086 6.253l6.9 1l-5 4.867l1.179 6.873z"
  151. ></path>
  152. </svg>
  153. </span>
  154. <span class="switch-icon-b text-yellow">
  155. <svg
  156. xmlns="http://www.w3.org/2000/svg"
  157. class="icon icon-tabler icon-tabler-star-filled"
  158. width="24"
  159. height="24"
  160. viewBox="0 0 24 24"
  161. stroke-width="2"
  162. stroke="currentColor"
  163. fill="none"
  164. stroke-linecap="round"
  165. stroke-linejoin="round"
  166. >
  167. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  168. <path
  169. d="M8.243 7.34l-6.38 .925l-.113 .023a1 1 0 0 0 -.44 1.684l4.622 4.499l-1.09 6.355l-.013 .11a1 1 0 0 0 1.464 .944l5.706 -3l5.693 3l.1 .046a1 1 0 0 0 1.352 -1.1l-1.091 -6.355l4.624 -4.5l.078 -.085a1 1 0 0 0 -.633 -1.62l-6.38 -.926l-2.852 -5.78a1 1 0 0 0 -1.794 0l-2.853 5.78z"
  170. stroke-width="0"
  171. fill="currentColor"
  172. ></path>
  173. </svg>
  174. </span>
  175. </button>
  176. <button class="switch-icon switch-icon-flip" data-bs-toggle="switch-icon">
  177. <span class="switch-icon-a text-secondary">
  178. <svg
  179. xmlns="http://www.w3.org/2000/svg"
  180. class="icon icon-tabler icon-tabler-thumb-up"
  181. width="24"
  182. height="24"
  183. viewBox="0 0 24 24"
  184. stroke-width="2"
  185. stroke="currentColor"
  186. fill="none"
  187. stroke-linecap="round"
  188. stroke-linejoin="round"
  189. >
  190. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  191. <path
  192. d="M7 11v8a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1h3a4 4 0 0 0 4 -4v-1a2 2 0 0 1 4 0v5h3a2 2 0 0 1 2 2l-1 5a2 3 0 0 1 -2 2h-7a3 3 0 0 1 -3 -3"
  193. ></path>
  194. </svg>
  195. </span>
  196. <span class="switch-icon-b text-facebook">
  197. <svg
  198. xmlns="http://www.w3.org/2000/svg"
  199. class="icon icon-tabler icon-tabler-thumb-up-filled"
  200. width="24"
  201. height="24"
  202. viewBox="0 0 24 24"
  203. stroke-width="2"
  204. stroke="currentColor"
  205. fill="none"
  206. stroke-linecap="round"
  207. stroke-linejoin="round"
  208. >
  209. <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
  210. <path
  211. d="M13 3a3 3 0 0 1 2.995 2.824l.005 .176v4h2a3 3 0 0 1 2.98 2.65l.015 .174l.005 .176l-.02 .196l-1.006 5.032c-.381 1.626 -1.502 2.796 -2.81 2.78l-.164 -.008h-8a1 1 0 0 1 -.993 -.883l-.007 -.117l.001 -9.536a1 1 0 0 1 .5 -.865a2.998 2.998 0 0 0 1.492 -2.397l.007 -.202v-1a3 3 0 0 1 3 -3z"
  212. stroke-width="0"
  213. fill="currentColor"
  214. ></path>
  215. <path
  216. d="M5 10a1 1 0 0 1 .993 .883l.007 .117v9a1 1 0 0 1 -.883 .993l-.117 .007h-1a2 2 0 0 1 -1.995 -1.85l-.005 -.15v-7a2 2 0 0 1 1.85 -1.995l.15 -.005h1z"
  217. stroke-width="0"
  218. fill="currentColor"
  219. ></path>
  220. </svg>
  221. </span>
  222. </button>
  223. <button class="switch-icon switch-icon-slide-up" data-bs-toggle="switch-icon">
  224. <span class="switch-icon-a text-secondary">
  225. <svg
  226. xmlns="http://www.w3.org/2000/svg"
  227. class="icon"
  228. width="24"
  229. height="24"
  230. viewBox="0 0 24 24"
  231. stroke-width="2"
  232. stroke="currentColor"
  233. fill="none"
  234. stroke-linecap="round"
  235. stroke-linejoin="round"
  236. >
  237. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  238. <path
  239. d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c-.002 -.249 1.51 -2.772 1.818 -4.013z"
  240. />
  241. </svg>
  242. </span>
  243. <span class="switch-icon-b text-twitter">
  244. <svg
  245. xmlns="http://www.w3.org/2000/svg"
  246. class="icon"
  247. width="24"
  248. height="24"
  249. viewBox="0 0 24 24"
  250. stroke-width="2"
  251. stroke="currentColor"
  252. fill="none"
  253. stroke-linecap="round"
  254. stroke-linejoin="round"
  255. >
  256. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  257. <path
  258. d="M22 4.01c-1 .49 -1.98 .689 -3 .99c-1.121 -1.265 -2.783 -1.335 -4.38 -.737s-2.643 2.06 -2.62 3.737v1c-3.245 .083 -6.135 -1.395 -8 -4c0 0 -4.182 7.433 4 11c-1.872 1.247 -3.739 2.088 -6 2c3.308 1.803 6.913 2.423 10.034 1.517c3.58 -1.04 6.522 -3.723 7.651 -7.742a13.84 13.84 0 0 0 .497 -3.753c-.002 -.249 1.51 -2.772 1.818 -4.013z"
  259. />
  260. </svg>
  261. </span>
  262. </button>
  263. <button class="switch-icon switch-icon-slide-left" data-bs-toggle="switch-icon">
  264. <span class="switch-icon-a text-secondary">
  265. <svg
  266. xmlns="http://www.w3.org/2000/svg"
  267. class="icon"
  268. width="24"
  269. height="24"
  270. viewBox="0 0 24 24"
  271. stroke-width="2"
  272. stroke="currentColor"
  273. fill="none"
  274. stroke-linecap="round"
  275. stroke-linejoin="round"
  276. >
  277. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  278. <path d="M5 12l5 5l10 -10" />
  279. </svg>
  280. </span>
  281. <span class="switch-icon-b text-red">
  282. <svg
  283. xmlns="http://www.w3.org/2000/svg"
  284. class="icon"
  285. width="24"
  286. height="24"
  287. viewBox="0 0 24 24"
  288. stroke-width="2"
  289. stroke="currentColor"
  290. fill="none"
  291. stroke-linecap="round"
  292. stroke-linejoin="round"
  293. >
  294. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  295. <line x1="18" y1="6" x2="6" y2="18" />
  296. <line x1="6" y1="6" x2="18" y2="18" />
  297. </svg>
  298. </span>
  299. </button>
  300. <button class="switch-icon switch-icon-slide-down" data-bs-toggle="switch-icon">
  301. <span class="switch-icon-a text-secondary">
  302. <svg
  303. xmlns="http://www.w3.org/2000/svg"
  304. class="icon"
  305. width="24"
  306. height="24"
  307. viewBox="0 0 24 24"
  308. stroke-width="2"
  309. stroke="currentColor"
  310. fill="none"
  311. stroke-linecap="round"
  312. stroke-linejoin="round"
  313. >
  314. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  315. <line x1="12" y1="5" x2="12" y2="19" />
  316. <line x1="18" y1="13" x2="12" y2="19" />
  317. <line x1="6" y1="13" x2="12" y2="19" />
  318. </svg>
  319. </span>
  320. <span class="switch-icon-b text-secondary">
  321. <svg
  322. xmlns="http://www.w3.org/2000/svg"
  323. class="icon"
  324. width="24"
  325. height="24"
  326. viewBox="0 0 24 24"
  327. stroke-width="2"
  328. stroke="currentColor"
  329. fill="none"
  330. stroke-linecap="round"
  331. stroke-linejoin="round"
  332. >
  333. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  334. <line x1="12" y1="5" x2="12" y2="19" />
  335. <line x1="18" y1="11" x2="12" y2="5" />
  336. <line x1="6" y1="11" x2="12" y2="5" />
  337. </svg>
  338. </span>
  339. </button>
  340. <button class="switch-icon switch-icon-slide-right" data-bs-toggle="switch-icon">
  341. <span class="switch-icon-a text-secondary">
  342. <svg
  343. xmlns="http://www.w3.org/2000/svg"
  344. class="icon"
  345. width="24"
  346. height="24"
  347. viewBox="0 0 24 24"
  348. stroke-width="2"
  349. stroke="currentColor"
  350. fill="none"
  351. stroke-linecap="round"
  352. stroke-linejoin="round"
  353. >
  354. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  355. <circle cx="7" cy="17" r="2" />
  356. <circle cx="17" cy="17" r="2" />
  357. <path d="M5 17h-2v-6l2 -5h9l4 5h1a2 2 0 0 1 2 2v4h-2m-4 0h-6m-6 -6h15m-6 0v-5" />
  358. </svg>
  359. </span>
  360. <span class="switch-icon-b text-secondary">
  361. <svg
  362. xmlns="http://www.w3.org/2000/svg"
  363. class="icon"
  364. width="24"
  365. height="24"
  366. viewBox="0 0 24 24"
  367. stroke-width="2"
  368. stroke="currentColor"
  369. fill="none"
  370. stroke-linecap="round"
  371. stroke-linejoin="round"
  372. >
  373. <path stroke="none" d="M0 0h24v24H0z" fill="none" />
  374. <circle cx="18" cy="17" r="2" />
  375. <circle cx="6" cy="17" r="2" />
  376. <path d="M8 17h5a6 6 0 0 1 5 -5v-5a2 2 0 0 0 -2 -2h-1" />
  377. </svg>
  378. </span>
  379. </button>
  380. ```