【问题标题】:Add "small" attribute or .bp3-small on BlueprintJs DateInput在 BlueprintJs DateInput 上添加“small”属性或 .bp3-small
【发布时间】:2019-03-04 00:02:40
【问题描述】:

我在我的应用程序中使用来自 BlueprintJS 的控件,并且输入框上有一个名为“small”的属性,它向其中添加了类“.bp3-small”以减小字体大小和组件高度。但是,这似乎在 DateInput 控件上不可用。我试过手动添加类:

<DateInput className="bp3-small"
                    showActionsBar={true}
                    small={true}
                    closeOnSelection={true}
                    value={props.data[props.fieldId]}
                    onChange={(newDate) => {
                        props.mutator(props.fieldId, newDate)
                    }}
                    popoverProps={{ position: Position.BOTTOM }}
                    formatDate={ date => date.toLocaleString()}
                    parseDate={str => new Date(str)}
                />

和:

<DateInput className=".bp3-small"
                    showActionsBar={true}
                    small={true}
                    closeOnSelection={true}
                    value={props.data[props.fieldId]}
                    onChange={(newDate) => {
                        props.mutator(props.fieldId, newDate)
                    }}
                    popoverProps={{ position: Position.BOTTOM }}
                    formatDate={ date => date.toLocaleString()}
                    parseDate={str => new Date(str)}
                />

但它仍然没有得到应用。我也尝试添加样式,但仍然没有运气。

<DateInput style={{fontSize: "12px", height:"24px"}}
                    showActionsBar={true}
                    small={true}
                    closeOnSelection={true}
                    value={props.data[props.fieldId]}
                    onChange={(newDate) => {
                        props.mutator(props.fieldId, newDate)
                    }}
                    popoverProps={{ position: Position.BOTTOM }}
                    formatDate={ date => date.toLocaleString()}
                    parseDate={str => new Date(str)}
                />

如何在所有 BlueprintJS 组件中使用小样式?

我应该补充一点,我的 DateInput 位于 FormGroup 中。我也尝试使用 FormGroup 的 contentClassName 属性但没有成功

谢谢, 特洛伊

【问题讨论】:

    标签: javascript reactjs blueprintjs


    【解决方案1】:

    啊,我找到了答案。有一个名为 inputProps 的参数将属性传递给底层输入,因此它可以工作:

    inputProps={{small: true}}
    

    【讨论】:

      猜你喜欢
      • 2011-08-21
      • 1970-01-01
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-13
      相关资源
      最近更新 更多