Any solution for styling the bar container in Native base ?
The offered vars are not enough, Like I need to change TabsContainer height, remove the bottom border and do some side padding before the tabs
Before I ask I checked all the related topics and nothing suitable for my situation
import React, { Component } from 'react';
import { Container, Tab, Tabs, ScrollableTab, Icon, Text } from 'native-base';
import Tab1 from './tabOne';
import Tab2 from './tabTwo';
import Tab3 from './tabThree';
import Tab4 from './tabFour';
import Tab5 from './tabFive';
export default class ProdList extends Component {
render() {
return (
<Container>
<Tabs tabContainerStyle={{ height: 30, borderWidth: 0 }} tabBarUnderlineStyle = {{ width: 0, borderWidth: 0}} tabBarBackgroundColor='#fff' tabStyle={{backgroundColor: '#fff'}} renderTabBar={()=> <ScrollableTab />}>
<Tab tabStyle={{backgroundColor: '#fff',marginLeft: 30, marginRight: 30, paddingLeft: 30 }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Main Course">
<Tab1 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{color: '#aeaeb1',fontFamily: 'Poppins', }} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Appetizers">
<Tab2 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Desserts">
<Tab3 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Soups">
<Tab4 />
</Tab>
<Tab tabStyle={{backgroundColor: '#fff', }} textStyle={{fontFamily: 'Poppins', color: '#aeaeb1'}} activeTabStyle={{ height: 30,backgroundColor: '#fbeaee',borderRadius: 20,marginTop: 10,}} activeTextStyle={{color: '#333',fontFamily: 'Poppins', fontWeight: 'normal'}} heading="Salads">
<Tab5 />
</Tab>
</Tabs>
</Container>
);
}
}
Here is the Result
need to change TabsContainer height, remove the bottom border and do some side padding before the tabs .. Any solution ?
Related
I'm using the simple react native tab. The tab works fine but it shows the default blue color background of the tag. That means About Courses and Chat are in a row and getting blue color by default. How could I change it?Also, how could I change ' ' this heading font-family, text color, and others property?
<View style={{ backgroundColor: 'red' }}>
<Tabs tabStyle={{ backgroundColor: 'red' }}>
<Tab heading="About Test" tabStyle={{ color: 'red' }}>
<View>
<Text>Hi THis is from ABout</Text>
</View>
</Tab>
<Tab heading="Courses">
<Text>Hi this is from Courses</Text>
</Tab>
<Tab heading="Chat">
<Text>This is from Chat</Text>
</Tab>
</Tabs>
</View>
Change it like this
<Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }}>
<Tab
heading="About Test"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<View>
<Text>Hi THis is from ABout</Text>
</View>
</Tab>
<Tab
heading="Courses"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<Text>Hi this is from Courses</Text>
</Tab>
<Tab
heading="Chat"
tabStyle={{ backgroundColor: 'white' }}
activeTabStyle={{ backgroundColor: 'orangered' }}
textStyle={{ color: 'black', fontWeight: '100' }}
activeTextStyle={{ fontWeight: '800',color: 'white' }}>
<Text>This is from Chat</Text>
</Tab>
</Tabs>
For underline styling just add
tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }}
to the <Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }} />
Also on Android I got to see that not setting activeTextStyle color shows no text..To fix this add
activeTextStyle={{ fontWeight: '800', color: 'white' }}> // Color as you desire
For removing border around the box
Add tabContainerStyle={{ elevation: 0 }} to <Tabs />, like this
<Tabs tabBarUnderlineStyle={{ backgroundColor: 'dodgerblue' }} tabContainerStyle={{ elevation: 0 }} >
To change Background Color of inside tabs space add style={{ backgroundColor: 'grey' }} to <Tab />, like this
<Tab
heading="About Test"
style={{ backgroundColor: 'grey' }}> // This line right here
<View>
<Text>Hi THis is from ABout</Text>
</View>
</Tab>
Check working example here
I have a layout file where I made footer and navigation and I insert these two functions in Layout const (code below). In the new file, I just need the Navigation function so how I can insert it without a footer? Because when I write in my new file import Navigation from "../components/layout" and the in code insert I've got error...
const Layout = ({ children }) => {return (
<div>
<Navigation></Navigation>
<Global
styles={{
html: {
backgroundColor: "#fff",
color: "#111",
fontFamily: `'Poppins', sans-serif`,
fontSize: 14,
[Screen.S]: {
fontSize: 16,
},
[Screen.M]: {
fontSize: 18,
},
[Screen.L]: {
fontSize: 20,
},
},
a: {
color: "unset",
},
}}
/>
{children}
<Footer></Footer>
</div>
)
}
function Navigation() { const [navbarOpen, setNavbarOpen] = useState(false) return (
<header
css={{
width: "100%",
maxWidth: "100%",
padding: "0 24px",
position: "fixed",
background: "#fff",
boxShadow: "0 0 0.35rem rgba(0,0,0,.25)",
zIndex: "100",
top: 0,
}}
>
<div
css={{
gridAutoFlow: "column",
minHeight: "4.5rem",
display: "grid",
maxWidth: 1200,
margin: "0 auto",
gridTemplateColumns: "auto 1fr",
alignItems: "center",
paddingLeft: 35,
}}>
<Link to="/ ">
<img style={{ height: "2.5rem" }} src={logo}/>
</Link>
<Toggle
navbarOpen={navbarOpen}
onClick={() => setNavbarOpen(!navbarOpen)}
>
{navbarOpen ? <Hamburger open /> : <Hamburger />}
</Toggle>
{navbarOpen ? (
<NavBoxIcons>
<NavbarSocialLinks />
</NavBoxIcons>
) : (
<NavBox open>
<div>
<HeaderLink>About</HeaderLink>
<HeaderLink>Blog</HeaderLink>
</div>
<div>
<NavbarLinks />
</div>
</NavBox>
)
}
</div>
</header >
)
}
function Footer() { return (
<footer
css={{
padding: "6rem 2rem",
fontSize: "1rem",
minHeight: 160,
fontFamily: "sans-serif",
...Css.container,
}}
>
<div
css={{
display: "flex",
flexDirection: "column",
marginBottom: "3.6rem",
}}
>
<div
css={{
fontSize: "1.2rem",
display: "grid",
gridGap: "0.8rem",
}}>
<a>
<span>Privacy police</span>
</a>
</div>
</div>
<div
css={{
display: "grid",
gridTemplateColumns: "1fr auto",
alignItems: "center",
fontWeight: "lighter",
}}>
<div css={{ display: "flex", flexDirection: "column" }}>
<span>My Page</span>
</div>
</div>
</footer>
)
}
try exporting both Navigation and Footer like this
//at bottom of file
export {Navigation, Footer}
import individual component like this
import {Navigation} from 'components/layout'
or
import {Navigation,Footer} from 'components/layout'
lookup exporting in js
I am using react-native-tab-view, but the TabBar is big, I want to make it small. How to customize it ? Applying margin/padding 0 didn't work.
Applying small height worked but the text went missing.
How to make it small or more customizable ?
<TabView
...
renderTabBar={props =>
<TabBar
{...props}
indicatorStyle={{ backgroundColor: 'white' }}
style={{ backgroundColor: 'pink' }}
tabStyle={{ backgroundColor: 'teal' }}
renderLabel={({ route, focused, color }) => (
<Text style={{ color, margin: 8 }}>
{route.title}
</Text>
)}
}
Try to use tabStyle prop for TabBar. By default it has a style:
minHeight: 48,
So in your case:
<TabView
...
renderTabBar={props =>
<TabBar
{...props}
indicatorStyle={{ backgroundColor: 'white' }}
style={{ backgroundColor: 'pink' }}
tabStyle={{ backgroundColor: 'teal', minHeight: 30 }} // here
renderLabel={({ route, focused, color }) => (
<Text style={{ color, margin: 8 }}>
{route.title}
</Text>
)}
}
vertical grouped bar chart of dynamic columns using react-vis
the output using react-vis vertical bar
Expected output
<XYPlot
xType={chartData['type']}
width={width}
height={height}>
<VerticalGridLines style={gridLineStyle} />
<HorizontalGridLines style={gridLineStyle} />
<XAxis tickLabelAngle={xAxisAngle} style={tickStyle} tickFormat={chartData['type'] == 'linear' ? tick => this.formatNumber(tick) : null} />
<YAxis tickLabelAngle={yAxisAngle} style={tickStyle} tickFormat={tick => this.formatNumber(tick)} />
<ChartLabel
text={chartData['name']}
className="alt-x-label"
includeMargin={false}
xPercent={0.5}
yPercent={1.18}
style={{
fontWeight: 'bold',
textAnchor: 'middle',
fontSize: "12px",
fill: "#6b6b76",
fontFamily: "sans-serif"
}}
/>
<ChartLabel
text={'No. of variants'}
className="alt-y-label"
includeMargin={false}
xPercent={-0.02}
yPercent={0.5}
style={{
transform: 'rotate(-90)',
fontWeight: 'bold',
textAnchor: 'middle',
fontSize: "12px",
fill: "#6b6b76",
fontFamily: "sans-serif"
}}
/>
{hoveredNode && (
<Hint value={hoveredNode}>
<div style={{ background: '#000000' }}>
<p style={{ fontSize: "10px", padding: "3px", color: '#ffffff' }}>{`${hoveredNode.y} variants with ${chartData['name']} of ${hoveredNode.x}`}</p>
</div>
</Hint>
)}
<BarSeries data={A} />
<BarSeries data={C} />
<BarSeries data={G} />
<BarSeries data={T} />
</XYPlot>
I get three 3 bars but there is always one fourth empty bar. Which is not needed. Any suggestion would be helpful. Thanks
I'm trying to render out a few buttons, but for some reason nothing is happening. I'm not certain where my mistake is. I have an OverviewRender class which will eventually handle different sets of buttons to render and an Overview class which calls OverviewRender to render out the buttons.
It feels like should be working, but the buttons aren't rendering. If I move the buttons inside the Overview return function I see can see them.
import React, { Component } from 'react'
import SearchBar from 'material-ui-search-bar'
import sass from '../scss/application.scss'
import PropTypes from 'prop-types'
import RaisedButton from 'material-ui/RaisedButton'
class OverviewRender extends Component {
render() {
const mainMenu = () => {
return (
<div>
<RaisedButton label="File Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
<RaisedButton label="Setup Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
<RaisedButton label="More Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
</div>
)
}
return (
<div>
{mainMenu}
</div>
)
}
}
class Overview extends Component {
constructor(props){
super(props)
this.state = {
open: false
}
}
render() {
return (
<div className="menuButtons">
<OverviewRender />
</div>
)
}
}
export default Overview;
It's because you have created a function mainMenu that creates your buttons, but you never call it.
Two options:
1. Move the mainMenu return contents directly into the div:
class OverviewRender extends Component {
render() {
return (
<div>
<RaisedButton
label="File Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
<RaisedButton
label="Setup Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
<RaisedButton
label="More Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
</div>
)
}
}
2. Move mainMenu out of the component to make it a functional component, which looks like what you are trying to achieve. And then you have to use it like you would any other component: <MainMenu />:
class OverviewRender extends Component {
render() {
return <MainMenu />
}
}
const MainMenu = () => (
<div>
<RaisedButton
label="File Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
<RaisedButton
label="Setup Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
<RaisedButton
label="More Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'
}}
/>
</div>
);
User-Defined Components Must Be Capitalized
We recommend naming components with a capital letter. If you do have a component that starts with a lowercase letter, assign it to a capitalized variable before using it in JSX.
Just rename mainMenu to MainMenu an it should work.
See the docs: component must be capitalized
class OverviewRender extends React.Component {
render() {
const MainMenu = ({name}) => (
<div>
<button label="File Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
<button label="Setup Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
<button label="More Options"
style={{
height: '80px',
width: '180px',
fontSize: '44px',
padding: '1px'}}
/>
</div>
);
return (
<div>
<MainMenu/>
</div>
)
}
}
ReactDOM.render( < OverviewRender / > , document.getElementById('root'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>