Skip to content

docs: update class & style binding recommendation - #59240

Closed
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:docs/update-class-style-bindings-recommendation
Closed

JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:docs/update-class-style-bindings-recommendation

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

This commit introduces an update to the official recommendations when it comes to class & styles bindings.

[class] & [style] bindings are now recommended for basic uses cases.

[ngClass] and [ngStyle] allow more advanced bindings (like space separated keys) or keys with units (for ngStyle) which are not supported by the native bindings. They still require the dedicated directives.

@JeanMeche
JeanMeche marked this pull request as draft December 19, 2024 00:46
@angular-robot angular-robot Bot added the area: docs Related to the documentation label Dec 19, 2024
@ngbot ngbot Bot added this to the Backlog milestone Dec 19, 2024
@JeanMeche
JeanMeche force-pushed the docs/update-class-style-bindings-recommendation branch from 218735a to 33fca29 Compare December 19, 2024 00:53
@github-actions

github-actions Bot commented Dec 19, 2024 •

Copy link
Copy Markdown

Deployed adev-preview for b278240 to: https://ng-dev-previews-fw--pr-angular-angular-59240-adev-prev-ft7l9x4g.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

@JeanMeche
JeanMeche force-pushed the docs/update-class-style-bindings-recommendation branch 3 times, most recently from b1168ed to 16a2459 Compare December 19, 2024 01:30

@michael-small michael-small left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: two grammar suggestions

edit: I just realized this is still a draft, I hope suggestions at this point in the process aren't being too pedantic

@JeanMeche
JeanMeche force-pushed the docs/update-class-style-bindings-recommendation branch from 16a2459 to a00baf5 Compare December 19, 2024 10:24
@JeanMeche
JeanMeche marked this pull request as ready for review December 19, 2024 16:22
@pullapprove
pullapprove Bot requested a review from kirjs December 19, 2024 16:22
@JeanMeche
JeanMeche requested review from jelbourn and removed request for kirjs December 19, 2024 16:22
@pullapprove
pullapprove Bot requested a review from kirjs December 19, 2024 16:22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: maybe add a set example? Otherwise it's not super clear what ngClass can do that [class] can't

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the Set to the list of possibilities above. Having an example with Set would be a bit more complex as we can't create them in the template,

This commit introduces an update to the official recommendations when it comes to class & styles bindings.

`[class]` & `[style]` bindings are now recommended for basic uses cases.

`[ngClass]` and `[ngStyle]` allow more advanced bindings (like space separated keys) or keys with units (for `ngStyle`) which are not supported by the native bindings. They still require the dedicated directives.
@JeanMeche
JeanMeche force-pushed the docs/update-class-style-bindings-recommendation branch from a00baf5 to b278240 Compare January 14, 2025 20:10

@jelbourn jelbourn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Jan 14, 2025
@kirjs

kirjs commented Jan 15, 2025

Copy link
Copy Markdown
Contributor

This PR was merged into the repository by commit d797c5c.

The changes were merged into the following branches: main, 19.0.x, 19.1.x

@kirjs kirjs closed this in d797c5c Jan 15, 2025
kirjs pushed a commit that referenced this pull request Jan 15, 2025
This commit introduces an update to the official recommendations when it comes to class & styles bindings.

`[class]` & `[style]` bindings are now recommended for basic uses cases.

`[ngClass]` and `[ngStyle]` allow more advanced bindings (like space separated keys) or keys with units (for `ngStyle`) which are not supported by the native bindings. They still require the dedicated directives.

PR Close #59240
kirjs pushed a commit that referenced this pull request Jan 15, 2025
This commit introduces an update to the official recommendations when it comes to class & styles bindings.

`[class]` & `[style]` bindings are now recommended for basic uses cases.

`[ngClass]` and `[ngStyle]` allow more advanced bindings (like space separated keys) or keys with units (for `ngStyle`) which are not supported by the native bindings. They still require the dedicated directives.

PR Close #59240
PrajaktaB27 pushed a commit to PrajaktaB27/angular that referenced this pull request Feb 7, 2025
This commit introduces an update to the official recommendations when it comes to class & styles bindings.

`[class]` & `[style]` bindings are now recommended for basic uses cases.

`[ngClass]` and `[ngStyle]` allow more advanced bindings (like space separated keys) or keys with units (for `ngStyle`) which are not supported by the native bindings. They still require the dedicated directives.

PR Close angular#59240
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Feb 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker adev: preview area: docs Related to the documentation target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants