react-materialize icon indicating copy to clipboard operation
react-materialize copied to clipboard

className on Tab not working as expected.

Open KalalauEnterprises opened this issue 6 years ago • 5 comments

When using the className prop on the Tabs component, the class in placed in the generated <ul> element. But when the className is used on the Tab component, the class is placed on the content <div> instead of the <li> for the Tab.

Why is this? How can I put a className on the generated <li> element? I'm trying to put an icon on the tab label.

<Tabs className="tabs-class"> <Tab className="tab-class"/> </Tabs> Results in:

<ul class="tabs tabs-class"> <li class="tab col"></li> </ul>

and the "tab-class" we wanted to put on the li shows up on the <div> of the tab content.

I expected that "tab-class" will be place on the <li> just like "tabs-class" is placed on the <ul>.

What actually happens is the "tabs-class" is on the <ul> as expected, but the "tab-class" is on a <div> down in the tab content.

Versions

react-materialize: 3.3.4 materialize-css: 1.0.0 react: 16.8.6

Thank you for any insight!!

KalalauEnterprises avatar Oct 17 '19 21:10 KalalauEnterprises

Im having the same issue. anyone knows how to resolve this?

Buooy avatar May 02 '20 16:05 Buooy

gonna have a look now

alextrastero avatar May 03 '20 09:05 alextrastero

One solution would be to make the title prop a node instead of a string, that way you could render like so: <Tab title={<MyCustomTitle />}>Test 1</Tab>

alextrastero avatar May 03 '20 10:05 alextrastero

Same issue here. It is not a good solution, but...it works. So my goal was to change the whole tab css.

component.jsx

<Tabs className={styles.tabSwitcher}>
  <Tab active title="Title">
</Tabs>

component.module.css

.tabSwitcher {
    border-bottom: 1px solid #edeff1;
    box-shadow   : 0 0;
}

.tabSwitcher li a {
    color: #55646D !important;
}

.tabSwitcher li a:focus {
    background-color: transparent !important;
}

/* for the indicator */
.tabSwitcher li:last-child {
    background-color: #55646D !important;
}

kamil-homer avatar Feb 16 '21 14:02 kamil-homer

Ok, so what about adding a titleClassName prop? Would that solve it?

alextrastero avatar Feb 17 '21 07:02 alextrastero