Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Angular Material UI #17

Open
reboottime opened this issue Nov 13, 2023 · 2 comments
Open

Angular Material UI #17

reboottime opened this issue Nov 13, 2023 · 2 comments

Comments

@reboottime
Copy link
Owner

reboottime commented Nov 13, 2023

Overview

Introduction

This article intends to guide a newbie to be familiar with angular material ui. content covered are highly similar what angular material ui official doc.


Quick References

@reboottime
Copy link
Owner Author

reboottime commented Nov 13, 2023

Angular Material UI CDK

  • What is it: Angular Material UI CDK is a set of prebuilt toolkits that facilitates building your own components/functions on top of it.
  • When and how to use CDK: Identify the components or behaviors in your application that could benefit from the CDK. For example, if you need a custom drag-and-drop list, the CDK’s drag-and-drop utilities would be perfect for that.

@reboottime
Copy link
Owner Author

reboottime commented Nov 13, 2023

Customize Material UI based Angular SPA

Guideline: https://material.angular.io/guides

  • Angular Material UI uses SASS as its theming styling language.
  • If you installed Angular Material UI, by default, the styles property in angular.json points to something like below

image



Now the next task is how to know what colors a component uses to style itself at a glimpse.



Common Problems

  • Style doesn't work as Material UI shows: For example, button component-related directives may function without Angular CLI errors but lose styling. Ensure that the corresponding module for the component or directive is correctly imported to resolve this.

My Tricks

  • How to force styling using sass: When styling Angular components, it can be challenging, especially for extensive customization, and identifying relevant class names within the Angular code isn't always clear. Here's my approach:

    • Inspect in the Browser: Select the CSS class names from the browser for the component to be customized.
    • ChatGPT for SCSS: Ask ChatGPT to generate condensed SCSS for the component you want to customize
    • Apply Styling: Copy styling from Figma and apply it to the specified SCSS class names.
  • How to update deeply nested styling on material ui components: Manipulate on scss variables

  • Another trick is to read material ui guideline and source code,

    • to figure out how the angular component class names are generated on html, for example, take form field as an example
    • view how class names are added to which DOM element

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant