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.

Recommended pattern for styling active tabs in v1?

See original GitHub issue

I know the tracker says questions will be closed, but since this is a change from v0 to v1 I felt this was still the appropriate place for this question.

In v0 the selected tab got an active class assigned to it in the DOM, which I was using. This was definitely not the best way to do things and I’m grateful for v1, but a bit confused about how to replicate that.

In emotion without reakit the pattern would be something like:

const StyledTab = styled.div(props => {
  return { color: props.currentId === props.selectedId ? "red" : "black" };
});

I’m not sure how that would translate to usage with reakit where I’ve got something like:

const StyledTab = styled(Tab)`
  // How can we access props here? Or is there some better pattern I'm overlooking?
`

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
diegohazcommented, Sep 23, 2019

Hi @Slapbox!

You can rely on aria attributes: https://github.com/reakit/reakit/blob/8837557636432cd7c6202a67e5d7d2ad5fdd4db6/packages/reakit-system-bootstrap/src/Tab.ts#L27-L30

You can also use reakit-system-bootstrap implementation as a styling reference. It also uses emotion. 😃

1reaction
diegohazcommented, Sep 23, 2019

I’m glad to hear that! 😃

And I’m sorry about the migration pain. But, yeah, that’s a huge improvement and a lot of effort has been made to make the v1 much more consistent and more likely to be adopted by big enterprise apps (I’m working on one). It shouldn’t change too much even on future major versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tabs | UI Design & Patterns - MindSphere Design System
Horizontal tabs are best used with ten or fewer tabs. Pay attention to the legibility of tab ... The icon color and style...
Read more >
Example of Tabs with Automatic Activation | APG | WAI - W3C
This example section demonstrates a tabs widget that implements the design pattern for tabs. In this example, a tab is automatically ...
Read more >
How to change active tab color in MUI? - reactjs - Stack Overflow
Configure your theme palette to use your desired color via the primary or secondary color intentions. You may then specify your desired primary ......
Read more >
Tabs - OutSystems 11 Documentation
You can use the Tabs UI Pattern to display large sets of information, which can be split into different areas, while always remaining...
Read more >
Tabs - a Collection by Team CodePen on CodePen
One of the most design pattern-y-est design patterns of all the design patterns. Share Copy Link. Created on: September 11, 2014.
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