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.

Changing Tabs width, not the content inside

See original GitHub issue

I want to customize the Tabs width, but not the width of the content of each tab.

simulator screen shot - iphone x - 2018-06-12 at 13 30 34

I want the width of the Tabs header to not affect the width of the content inside each Tab.

This is my code. Currently I’m adding a style to Tabs

<Tabs
	style={{
		width: PixelRatio.getPixelSizeForLayoutSize(101),
	}}
	initialPage={0}
	tabBarUnderlineStyle={ styles.tabBarUnderlineStyle }
	>
        <Tab
	        heading="Phone"
	        tabStyle={ styles.tabStyle }
	        activeTabStyle={ styles.tabStyle }
	        textStyle={ styles.tabBarText }
	        activeTextStyle={ styles.tabBarText }
	        >
	        <Content>
		       
	        </Content>
	</Tab>
	<Tab
		heading="Email"
		tabStyle={ styles.tabStyle }
		activeTabStyle={ styles.tabStyle }
		textStyle={ styles.tabBarText }
		activeTextStyle={ styles.tabBarText }
		>
	        {/* <Tab2 /> */}
	</Tab>
</Tabs>

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
akhil-gacommented, Jun 28, 2018

@rostyys try setting the tabs container width using tabsContainerStyle

Gif

tabs

Sample code

import React, { Component } from 'react';
import { Dimensions } from "react-native";
import { Container, Header, Tab, Tabs, ScrollableTab, Text } from 'native-base';
export default class App extends Component {
  render() {
    return (
      <Container>
        <Header />
        <Tabs
          renderTabBar={() =>
            <ScrollableTab style={{
              width: 300,
              marginHorizontal: Dimensions.get("window").width / 11,
              paddingTop: Dimensions.get("window").width / 35
            }}
              tabsContainerStyle={{ width: 300 }} />}>
          <Tab heading="Tab1" tabStyle={{ width: 100 }} activeTabStyle={{ width: 100 }} tab>
            <Text style={{ flex: 1, backgroundColor: "red" }}>Tab one</Text>
          </Tab>
          <Tab heading="Tab2" tabStyle={{ width: 100 }} activeTabStyle={{ width: 100 }}>
            <Text style={{ flex: 1, backgroundColor: "blue" }}>Tab two</Text>
          </Tab>
        </Tabs>
      </Container>
    );
  }
}
1reaction
akhil-gacommented, Jun 22, 2018

@rostyys try setting width to ScrollableTab. like

<ScrollableTab style={{ width: 200 }} />

This sets the tab bar width. To change the width of each tab apply width to tabStyle and activeTabStyle props of <Tab/>

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change tabs width in material UI - Stack Overflow
If you want tabs of fixed width, you need to override the root css class passed to the Tab component, where you have...
Read more >
How to Change Tab Width in Google Chrome - Winaero
To Change Tab Width in Google Chrome ... From the drop-down menu next to the Scrollable Tabstrip option, select one of the following...
Read more >
tab-size - CSS: Cascading Style Sheets - MDN Web Docs
The tab-size CSS property is used to customize the width of tab characters (U+0009).
Read more >
height and width of the tabs - WordPress.org
Hi @airafleur, blocks are not allowed inside table cells. To tweak the tabs width/height assign a class to the block and through theme...
Read more >
Set tabs and indents in Adobe InDesign
When the top of a horizontal frame is displayed, the Tabs dialog box will snap to the top of the current text frame,...
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