# CSS Struggles with Components

**URL:** <https://discuss.emberjs.com/t/css-struggles-with-components/9141>\
**Category:** Uncategorized\
**Created:** [November 19, 2015, 5:56pm UTC](https://discuss.emberjs.com/t/css-struggles-with-components/9141 "2015-11-19T17:56:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jesmith](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/jesmith/32/11707_2.png) [@jesmith](https://discuss.emberjs.com/u/jesmith)\
**Post date:** [November 19, 2015, 5:56pm UTC](https://discuss.emberjs.com/t/css-struggles-with-components/9141/1 "2015-11-19T17:56:32Z")

</div>

I am working on a new app using the AdminLTE template. One of the struggles I am currently facing is that when I take pieces and break them out into components (like the user-profile popup that is in the upper right corner) when Ember actually renders that, the wrapped div breaks my look and feel by not having correct CSS to not enforce it’s on changes. Suddenly objects that weren’t originally inside a div end up there due to the component work. And the ember-view class doesn’t seem to do what’s expected to minimize that (if that’s what it’s trying to do).

What’s the best practice for making sure that making something a component doesn’t create un-intended CSS issues?

---

<div class="post-metadata">

**Author:** ![dpreston](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dpreston/32/10590_2.png) [@dpreston](https://discuss.emberjs.com/u/dpreston)\
**Post date:** [November 20, 2015, 1:09am UTC](https://discuss.emberjs.com/t/css-struggles-with-components/9141/2 "2015-11-20T01:09:05Z")

</div>

Have a look at customizing the component tag [Customizing a Component's Element - Components - Ember Guides](http://guides.emberjs.com/v2.2.0/components/customizing-a-components-element/) , you can also set the `tagName: ''` to remove it entirely.

---

<div class="post-metadata">

**Author:** ![spectras](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@spectras](https://discuss.emberjs.com/u/spectras)\
**Post date:** [November 20, 2015, 6:24am UTC](https://discuss.emberjs.com/t/css-struggles-with-components/9141/3 "2015-11-20T06:24:20Z")

</div>

So following the link given by dpreston, you can set CSS classes on the component’s `div`, or even change the `div` to be something more relevant.

So the idea could be to change:

```
<ul class="my-list">{{#each list as |item|}}<li>{{item}}</li>{{/each}}</ul>

```

To:

```
{{#each list as |item|}}<li>{{item}}</li>{{/each}}

```

And in the component:

```
export default Ember.Component.extend({
    tagName: 'ul',
    classNames: ['my-list']
});

```

Also note that `classNames` you set on the component can be added to when you instanciate it. For instance, if I do `{{my-list class="someclass"}}`, the resulting `ul` will have both `someclass` and `my-list`.

Try to keep the `tagName: ''` as a last resort solution, because it breaks some of the component features (event handling, `this.$`)

---

<div class="post-metadata">

**Author:** ![dpreston](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dpreston/32/10590_2.png) [@dpreston](https://discuss.emberjs.com/u/dpreston)\
**Post date:** [November 20, 2015, 7:32am UTC](https://discuss.emberjs.com/t/css-struggles-with-components/9141/4 "2015-11-20T07:32:08Z")

</div>

Thanks @spectras, I wasnt aware of the issues with `tagName: ''`, it also seems to be removed from angle-components as well, so probably best not to use it.
