Published on

Practical Guide: Create A Vue 3 router tree With Tailwind CSS

Vue 3 router tree

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of Vue 3 router tree ui component

Vue 3 router tree

Why use Tailwind CSS to build a Vue 3 router tree ui component?

  • It can make the building process of Vue 3 router tree ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Vue 3 router tree component file.

The preview of Vue 3 router tree ui component

Free download of the Vue 3 router tree's source code

The source code of Vue 3 router tree ui component

<!-- This is an example component -->
<div>
    <div class="p-4">
    Vue 3 router tree check it <a class="text-indigo-700" target="_blank" href="https://boussadjra.github.io/vue3-router-tree/">here</a>
        </div>
	<div class="p-4">
		<div class="py-2 w-80 bg-indigo-900 rounded text-white" style="max-width: none;">
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center"><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M11.17 6l3.42 3.41l.58.59H28v16H4V6h7.17m0-2H4a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h24a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2H16l-3.41-3.41A2 2 0 0 0 11.17 4z"
									fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">.git</span></div><span class="px-1 text-xs"></span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center"><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M11.17 6l3.42 3.41l.58.59H28v16H4V6h7.17m0-2H4a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h24a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2H16l-3.41-3.41A2 2 0 0 0 11.17 4z"
									fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">node_modules</span></div>
						<span class="px-1 text-xs"></span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center"><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M11.17 6l3.42 3.41l.58.59H28v16H4V6h7.17m0-2H4a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h24a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2H16l-3.41-3.41A2 2 0 0 0 11.17 4z"
									fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">public</span></div><span class="px-1 text-xs"></span>
					</div>
					<span class="pl-4"><svg focusable="false" width="16px" height="16px" viewBox="0 0 32 32"><path d="M12 8l10 8l-10 8z" fill="currentColor"></path></svg></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">.gitignore</span></div><span class="px-1 text-xs"></span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">babel.config.js</span></div>
						<span class="px-1 text-xs text-yellow-300">M</span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">package.json</span></div>
						<span class="px-1 text-xs text-yellow-300">M</span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">README.md</span></div>
						<span class="px-1 text-xs text-green-400">U</span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">vue.config.js</span></div>
						<span class="px-1 text-xs text-purple-700">C</span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
			<div class="  px-4  cursor-pointer">
				<div class="flex items-center justify-between p-2 hover:text-xl ">
					<div class="flex justify-between items-center w-full hover:font-bold">
						<div class="flex items-center">
							<!----><svg aria-hidden="true" focusable="false" role="img"
								class="fill-current fill-current--carbon" width="20px" height="20px"
								preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"
								style="transform: rotate(360deg);">
								<path
									d="M25.7 9.3l-7-7c-.2-.2-.4-.3-.7-.3H8c-1.1 0-2 .9-2 2v24c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V10c0-.3-.1-.5-.3-.7zM18 4.4l5.6 5.6H18V4.4zM24 28H8V4h8v6c0 1.1.9 2 2 2h6v16z"
									fill="currentColor"></path>
								<path d="M10 22h12v2H10z" fill="currentColor"></path>
								<path d="M10 16h12v2H10z" fill="currentColor"></path>
							</svg>
							<!---->
							<!---->
							<!---->
							<!---->
							<!---->
							<!----><span class="ml-2 text-sm">yarn.lock</span></div>
						<span class="px-1 text-xs text-red-500">+1</span>
					</div><span class="pl-4"><!----></span>
				</div>
				<div>
					<!---->
				</div>
			</div>
		</div>
	</div>
</div>

How to build a Vue 3 router tree with Tailwind CSS?

Install tailwind css of verion 2.0.2

Use the script html tag to import the script of Tailwind CSS of the version 2.0.2

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to build a Vue 3 router tree component

  • p-4
  • text-indigo-700
  • py-2
  • w-80
  • bg-indigo-900
  • text-white
  • px-4
  • flex
  • p-2
  • hover:text-xl
  • w-full
  • ml-2
  • text-sm
  • px-1
  • text-xs
  • pl-4
  • text-yellow-300
  • text-green-400
  • text-purple-700
  • text-red-500

20 steps to build a Vue 3 router tree component with Tailwind CSS

  1. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  2. Control the text color of an element to indigo-700 using the text-indigo-700 utilities.

  3. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

  4. Use w-80 to set an element to a fixed width(20rem).

  5. Control the background color of an element to indigo-900 using the bg-indigo-900 utilities.

  6. Control the text color of an element to white using the text-white utilities.

  7. Control the horizontal padding of an element to 1rem using the px-4 utilities.

  8. Use flex to create a block-level flex container.

  9. Control the padding on all sides of an element to 0.5rem using the p-2 utilities.

  10. Control the text color of an element to xl on hover using the hover:text-xl utilities.

  11. Use w-full to set an element to a 100% based width.

  12. Control the margin on left side of an element to 0.5rem using the ml-2 utilities.

  13. Control the text color of an element to sm using the text-sm utilities.

  14. Control the horizontal padding of an element to 0.25rem using the px-1 utilities.

  15. Control the text color of an element to xs using the text-xs utilities.

  16. Adjust the left padding of an element to 1rem using the pl-4 utilities class

  17. Control the text color of an element to yellow-300 using the text-yellow-300 utilities.

  18. Control the text color of an element to green-400 using the text-green-400 utilities.

  19. Control the text color of an element to purple-700 using the text-purple-700 utilities.

  20. Control the text color of an element to red-500 using the text-red-500 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to build a Vue 3 router tree components, learn and follow along to implement your own components.