Add UI Library
- Install dependencies
Set up the UI library dependencies and files
This lesson is not specific to Angular, but adding an UI library will enhance the application’s user interface rather than relying on default browser styles.
// TODO: add before/after illustration of the final application
What is a User Interface (UI) Library?
A user interface (UI) library is a collection of style rules to create a consistent UI throughout the application and saves development time. For this course, you will add DaisyUI and TailwindCSS to your project.
Instructions
-
Run the following command in your terminal to install DaisyUI and TailwindCSS:
Terminal window npm install tailwindcss @tailwindcss/postcss postcss daisyui@latest --force -
Create a PostCSS plugins file named
.postcssrc.json
at the root of your project and populate it with:.postcssrc.json {"plugins": {"@tailwindcss/postcss": {}}} -
Add these styles into the
src/styles.css
file:styles.css + @import "tailwindcss";+ @plugin "daisyui"; -
Stop the server if it’s still running (keyboard shortcut
CTRL+C
) and restart it with the following command:Terminal window ng serve -
Open the
src/app/app.html
file and replace its content once again to add a DaisyUI header:<div class="navbar bg-base-100 shadow-sm"><a class="btn btn-ghost text-xl">Task Manager</a></div> -
Check out the small changes in your browser.
You learned how to add a UI library to your Angular application. In the upcoming chapters, HTML snippets will include DaisyUI classes to enhance the application’s user interface. You won’t need to explore the DaisyUI documentation as all required classes will be included in snippets..