是否可以在材料中添加字幕-ui Appbars?

dlw*_*est 1 appbar reactjs material-ui

Material-UI的AppBar提供title属性但没有subtitle属性.我想在标题下面添加一些较小的文字,但我还没有找到办法.添加
标记会隐藏任何标记,并且更改该区域中任何内容的显示属性也会隐藏它.我能找到的唯一解决方案是严重破坏组件(基本上忽略了title属性并用宽度100%div劫持AppBar,这并不理想).有没有人找到更好的方法来做到这一点?谢谢!

Jef*_*oud 6

您可以在title支柱中放置所需的任何HTML /组件.titleStyle可以用来调整最外面的元素(我在下面使用它来覆盖默认AppBar添加到最外层的"line-height:64px" <div>):

https://jsfiddle.net/tktbsv63/1/

class Example extends React.Component {
  render() {
    return (
      <AppBar
        titleStyle={{ lineHeight: 'normal' }}
        title={
          <div>
            <div style={{ marginTop: 10 }}>Title of My App</div>
            <div style={{ fontSize: 'small', fontWeight: 300 }}>This is the subtitle</div>
          </div>
        }
      />
    );
  }
}
Run Code Online (Sandbox Code Playgroud)