Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

md-hint add color property #2965

Closed
tydanielson opened this issue Feb 7, 2017 · 8 comments
Closed

md-hint add color property #2965

tydanielson opened this issue Feb 7, 2017 · 8 comments
Labels
area: material/form-field feature This issue represents a new feature or feature request rather than a bug or bug fix needs: discussion Further discussion with the team is needed before proceeding P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@tydanielson
Copy link

This is a feature. It would be really nice to use the color property like on md-button to determine which hints are warnings, accents or primary etc... I'm using the hints for both showing validation errors and anything related to the users input.

@sumpton
Copy link

sumpton commented Feb 7, 2017

<md-text> would be a terrific addition to work along with <md-hint>

I have been refactoring hundreds of Bootstrap 4 fields to Material 2, and I appreciate <md-hint> very much. The positioning is also very useful.

But for validation messages I have been moving <div> out of the form-control, and wish there was a more direct and elegant Material component for Bootstrap's <... class="form-text"> that could be used for all the form components.

@devversion
Copy link
Member

Good idea. While I was thinking about the color property on md-hint I noticed that we often repeat the same logic to apply the color classes.

A good solution would be having a directive that is responsible for the color classes. Need to discuss first.

@devversion devversion self-assigned this Feb 7, 2017
@tinayuangao tinayuangao added the feature This issue represents a new feature or feature request rather than a bug or bug fix label Feb 8, 2017
@gvlekke
Copy link

gvlekke commented Feb 10, 2017

I think it's also good to have a color option on md-hint, but I think its better that you can set a error color in the theme file. Material2 itself should apply the error color on the hint and the md-input-underline. Just like https://material.io/guidelines/patterns/errors.html#errors-user-input-errors

For now I'm creating a css file that does that based on the ng-dirty and ng-invalid classes.

md-hint
  font-weight: lighter
  color: #A1A1A1

md-input-container.ng-dirty.ng-invalid
  .md-input-underline
    border-top-width: 2px
    border-color: #D50000

    .md-input-ripple
      background-color: #D50000

  md-hint
    color: #D50000

should i create a new issue: "add error styling to inputs" ?

@JoshMarler
Copy link

@gvlekke I agree with this being a good idea. Thanks for the css snippet. Helped me style my validation in the manner I required. Spent longer than I care to admit messing around having missed ng-dirty / ng-invalid overrides...

For those interested as of 2.4.6 relevant css is:

md-input-container.ng-touched.ng-invalid {

  .mat-input-placeholder {
    color: red;
  }

  .mat-input-underline {
    border-top-width: 2px;
    border-color: red;
  }

  .mat-input-ripple {
    background-color: red;
  }

  md-hint {
    color: red;
  }
}

@kamarouski
Copy link
Contributor

kamarouski commented Feb 25, 2017

Out of the box styling solution for invalid inputs and error messages would be great.

Color property for md-hint would definitely help a lot as everybody now need to write custom css to achieve this common task. Or maybe a separate md-error component.

Hopefully this will be considered before final release.

That's how I currently style it using theme warn color:

@import '~@angular/material/core/theming/all-theme';
@import './_custom-theme.scss';

.mat-hint {
    &.error {
        color: mat-color($custom-warn);
    }
}

@devversion devversion removed their assignment May 8, 2017
@devversion devversion removed the has pr label May 8, 2017
@niwrA
Copy link

niwrA commented May 15, 2017

I currently don't use any forms, just md-inputs (all inputs are hooked up to immediate updates on blur to the backend), and the first thing I did was try to add a color property to md-hint, so it certainly would feel a natural solution. Alternatively following the standard ng-dirty etc. would be great too of course.

@jelbourn jelbourn added discussion P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Jun 6, 2017
@mmalerba mmalerba added needs: discussion Further discussion with the team is needed before proceeding and removed discussion labels Mar 3, 2020
@mmalerba
Copy link
Contributor

This isn't something that's in the Material Design spec and we already have mat-error for showing error color messages. I don't think its a feature we'll add, though it should be easy enough for users to add by using CSS and Angular Material's theming system (see https://material.angular.io/guide/theming-your-components)

@angular-automatic-lock-bot
Copy link

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 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/form-field feature This issue represents a new feature or feature request rather than a bug or bug fix needs: discussion Further discussion with the team is needed before proceeding P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests

10 participants