question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color attribute: add color as an attribute to our components

See original GitHub issue

This makes dynamically changing attributes easier for the user, and it will be easier to manage internally. For example:

<button primary>Button</button>

will become

<button color="primary">Button</button>

Edit: I realized button is probably a bad example since it already has this attribute, but this will benefit components like ion-navbar as well:

<ion-navbar color="secondary">
   ...
</ion-navbar>

or

<ion-navbar [color]="barColor">
   ...
</ion-navbar>
@Component({
  templateUrl: 'build/pages/about/about.html'
})
export class AboutPage {
  barColor: string;

  constructor(private nav: NavController, platform: Platform) {
    this.barColor = platform.is('android') ? 'primary' : 'light';
  }
}

Edit: Components that will have the color input:

  • Badge
  • Button
  • Checkbox
  • Chip
  • Icon
  • Item (Item, Item Divider, List Header)
  • Label
  • Navbar
  • Radio
  • Searchbar
  • Segment
  • Spinner
  • Tabs
  • Toggle
  • Toolbar
  • Typography (headers, paragraphs, spans, etc.)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:8
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brandyscarneycommented, Dec 1, 2016

@albrecht-jun-zhang You can use property binding for full as well:

<button ion-button [full]="isFull">Full</button>

See: https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding

1reaction
szernercommented, Aug 22, 2016

@brandyscarney I opened a new issue #7826 for my suggestion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

add color as an attribute to our components #7467 - GitHub
I would appreciate the possibility to set the colors of the <ion-searchbar> component icons on the fly. Currently we can use some ionic...
Read more >
Applying color to HTML elements using CSS - MDN Web Docs
Applying color to HTML elements using CSS. This article is a primer introducing each of the ways CSS color can be used in...
Read more >
color as an attribute in litelement custom element
I'm building a custom web component with LitElement and would like to give it a color attribute. I've got the color working but...
Read more >
Use Attribute to set background Color on Lightning Compoents
Below is my Component and CSS where we are currently setting the background color statically. Component <aura:component implements=" ...
Read more >
How To Change the Color of HTML Elements - DigitalOcean
In these examples, the color value is defined by color names. Try changing the color of text, image borders and <div> elements using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found