2

currently implementing the tab with custom menu items

https://react.semantic-ui.com/modules/tab#custom-menu-items

How do I style the default colors from black to grey? All I know is that if you add a menu attribute with the color set to green, it will change the active color to green but I want the inactive color to be grey and active to be green. There doesn't seem to be an obvious way to set the default color.

import React, { Component } from 'react';
import { Label, Menu, Tab } from 'semantic-ui-react';


const panes = [
    {
      menuItem: <Menu.Item key='location'><i class="marker icon"></i></Menu.Item>,
      render: () => <Tab.Pane>Tab 1 Contents</Tab.Pane>,
    },
    {
      menuItem: <Menu.Item key='messages'><i class="marker icon"></i></Menu.Item>,
      render: () => <Tab.Pane>Tab 2 Content</Tab.Pane>,
    },
  ]

class TabBar extends Component {

    render() {
        return (
            <Tab menu = {{color: 'green'}} panes={panes} />
        );
    }
}

export default TabBar;

What about the size of the tabs? it seems I have very little control over the basic styling unless I go straight into the css file... I may just implement it myself and stop using semantic ui

4
  • You'll have to overwrite the CSS for .ui.menu > .item:not(.active) and give it color: gray. Commented Jan 29, 2018 at 20:27
  • I have to go into the semantic ui css? Commented Jan 29, 2018 at 20:30
  • Can you post how you're loading CSS in your application? Commented Jan 29, 2018 at 20:49
  • @MitchLillie im using a cdn Commented Jan 29, 2018 at 20:56

1 Answer 1

4
// In index.html or wherever you're rendering your React app
// AFTER you load the semantic UI css
<link rel="stylesheet" type="text/css" href="custom.css">

Then, as @ChaseDeAnda mentioned:

// In custom.css
.ui.menu > .item:not(.active) {
  color: gray;
}

Keeping your menu={{color:'green'}} in your component.

This will override the active class that semantic UI uses and set it to be green when active.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. What about the actual size of the tabs? I saw that there was a { paneWidth: 12, tabWidth: 4 } option under "grid" attribute. But it doesn't seem to do anything and there's no documentation on tabWidth
Styling is just CSS. Either 1. dig into the semantic-ui source code or documentation, 2. open your browser console, inspect the element you want to change, and play with some different values, or 3. post a new question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.