How to use bootstrap in angular framework?
In Angular, there are 5 main ways to write CSS, from component-level styling to global styling.
I’ll explain each one clearly with examples 👇
✅ 1. Component CSS File (Most Common & Recommended)
Each component has its own CSS file.
📁 app.component.ts
📁 app.component.css
✔ Scoped to that component only
✔ Best practice for large apps
✅ 2. Inline Styles in Component Template
CSS written directly inside HTML.
✔ Quick styling
❌ Not reusable
❌ Avoid in production
✅ 3. Styles Inside Component (styles property)
Write CSS directly inside the component file.
✔ Component-scoped
✔ Useful for small components
✅ 4. Global Styles (styles.css )
Applied to the entire application.
📁 src/styles.css
✔ Best for:
-
Bootstrap overrides
-
Theme styles
-
Common classes
✅ 5. External CSS Library (Bootstrap, Tailwind, etc.)
Example: Bootstrap
✔ Used for UI frameworks
✔ Global effect
✅ Method 1: Install Bootstrap via npm (Recommended)
🔹 Step 1: Install Bootstrap
Open your Angular project folder and run:
🔹 Step 2: Add Bootstrap CSS to angular.json
Open angular.json and find the styles array:
✅ Save the file.
🔹 Step 3: Restart Angular Server
Bootstrap is now available globally 🎉
🔹 Step 4: Use Bootstrap Classes in Component HTML
✅ Method 2: Using Bootstrap CDN
Add CDN in src/index.html

0 Comments
POST Answer of Questions and ASK to Doubt