आप TableHeaderColumn और इसके संबंधित TableRowColumns की शैली सेट कर सकते हैं। नीचे मैं 12 पिक्सल (और पृष्ठभूमि रंग पीला करने के लिए बस आगे डेमो कस्टम स्टाइल के लिए)
लिए चौड़ाई सेट काम कर jsFiddle: https://jsfiddle.net/0zh1yfqt/1/
const {
Table,
TableHeader,
TableHeaderColumn,
TableBody,
TableRow,
TableRowColumn,
MuiThemeProvider,
getMuiTheme,
} = MaterialUI;
class Example extends React.Component {
render() {
const customColumnStyle = { width: 12, backgroundColor: 'yellow' };
return (
<div>
<Table>
<TableHeader>
<TableRow>
<TableHeaderColumn>A</TableHeaderColumn>
<TableHeaderColumn style={customColumnStyle}>B</TableHeaderColumn>
<TableHeaderColumn>C</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableRowColumn>1</TableRowColumn>
<TableRowColumn style={customColumnStyle}>2</TableRowColumn>
<TableRowColumn>3</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>4</TableRowColumn>
<TableRowColumn style={customColumnStyle}>5</TableRowColumn>
<TableRowColumn>6</TableRowColumn>
</TableRow>
<TableRow>
<TableRowColumn>7</TableRowColumn>
<TableRowColumn style={customColumnStyle}>8</TableRowColumn>
<TableRowColumn>9</TableRowColumn>
</TableRow>
</TableBody>
</Table>
</div>
);
}
}
const App =() => (
<MuiThemeProvider muiTheme={getMuiTheme()}>
<Example />
</MuiThemeProvider>
);
ReactDOM.render(
<App />,
document.getElementById('container')
);
स्रोत
2016-11-23 20:51:35
लेकिन यह हार्डकोड चौड़ाई है, सही? मैं उस व्यक्ति की तलाश में था जो सामग्री के आधार पर गतिशील रूप से बदल जाएगा लेकिन फिर भी अन्य स्तंभों की तुलना में व्यापक चौड़ाई है। –
आप अतिरिक्त रूप से व्हाइटस्पेस का उपयोग कर सकते हैं: 'nowrap', और/या minWidth/maxWidth –
क्या आप व्हाइटस्पेस के साथ पूरा कोड दिखा सकते हैं? –