简体   繁体   English

使用材质 ui 和 React,在 TextField 中更改 `carrot` 的样式

[英]Using material ui and React, change the style of the `carrot` in TextField

I'm using mui textfield per documentation here: https://mui.com/components/text-fields/ .我在这里使用每个文档的 mui 文本字段: https://mui.com/components/text-fields/ while there's plenty of docs on changing the font of the input text, I have yet to see any docs or resources on how to make the carrot fatter.虽然有很多关于更改输入文本字体的文档,但我还没有看到任何关于如何使胡萝卜更胖的文档或资源。 I'm looking for a style that simulates the console, and I have provided an image below.我正在寻找一种模拟控制台的样式,我在下面提供了一张图片。 Below is the code for textinput I'm using, rather standard:下面是我正在使用的 textinput 的代码,相当标准:


const translucent = 'rgba(255,255,255,0.1)';


const useStyles = makeStyles((theme: Theme) => createStyles({
    wrapForm : {
        display: "flex",
        justifyContent: "center",
        width: "95%",
        margin: `${theme.spacing(0)} auto`,
        // borderBottom: `0.8px solid ${translucent}`, // @TODO: remove this
    },
    wrapText  : {
        width: "100%"
    },
    button: {
        margin: theme.spacing(1),
    },
    multilineColor:{
        color:'white',
        borderColor: `white !important`,
        filter: 'blur(0.8px)'
    },
    overLayContainer: {
        display: 'grid',
    },

    overLayContainerInner: {
        gridArea: '1 / 1',
    },      
}));


/******************************************************
    @View
******************************************************/




export const TextInput = (props) => {

    const classes = useStyles();

    return (
        <>
            <form className={classes.wrapForm}  noValidate autoComplete="off">
                <TextField 
                    className = {classes.wrapForm}
                    fullWidth
                    multiline
                    InputProps={{className: classes.multilineColor, disableUnderline: true}}
                    rows   = "1"
                    margin = "normal"
                />
            </form>
        </>     
    )
}

在此处输入图像描述

The reason that there's no documentation on how to make a fatter "caret" is because this is not currently supposed in browsers.没有关于如何制作更胖的“插入符号”的文档的原因是因为浏览器目前不应该这样做。 You can change the caret color using CSS (eg. caret-color: red; ), but if you want to mimic a console's "fat" caret, you may have to add your own element to the screen and then move it based on the input entered.您可以使用 CSS 更改插入符号颜色(例如caret-color: red; ),但如果您想模仿控制台的“胖”插入符号,您可能必须将自己的元素添加到屏幕,然后根据输入。 Here is an old example of one way to do it and another which would also require your own JS implementation.这是一种方法的旧示例一种方法也需要您自己的 JS 实现。

There is a proposed revision for caret-shape: block;有一个caret-shape: block;建议修订:块; , which appears to be what you're looking for, but that is not currently supported. ,这似乎是您正在寻找的,但目前不支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM