javascript 尝试删除输入ReactJS中的外观边框& Tailwind

dl5txlt9  于 2023-08-02  发布在  Java
关注(0)|答案(2)|浏览(77)

我正在尝试删除输入中的外观边框。但我无法移除它。请有人指导我如何删除它?使用TailwindCSS和React JS。
你可以看到一个内边框在所附的图片
这是codesandbox的链接:(Codesandbox
我的代码:

import * as React from "react";
import { useState, ChangeEvent } from "react";

export default function App() {
  const [selectedColor, setSelectedColor] = useState("#1C4B40");

  const handleColorChange = (event: ChangeEvent<HTMLInputElement>) => {
    let inputValue = event.target.value;
    if (!inputValue.startsWith("#")) {
      inputValue = `#${inputValue}`;
    }
    setSelectedColor(inputValue);
  };

  return (
    <div className="bg-gray-500">
      <input
        id="colorPicker"
        type="color"
        style={{
          WebkitAppearance: "none",
          appearance: "none",
          backgroundColor: selectedColor,
          borderColor: selectedColor,
          outline: "none"
        }}
        className="h-8 w-8 cursor-pointer rounded-[4px] border-none"
        value={selectedColor}
        onChange={handleColorChange}
      />
    </div>
  );
}

字符串
Image
我正在尝试从输入中删除内部灰色边框。我想利用顺风来实现
enter image description here

lokaqttq

lokaqttq1#

将其添加到index.css文件中

.swatch-wrapper {
  &::-webkit-color-swatch-wrapper {
    padding: 0;
  }

  &::-webkit-color-swatch {
    @apply border-2 border-transparent rounded-[4px];
  }
}

字符串
在代码中使用类之后

<input
    id="colorPicker"
    type="color"
    className="swatch-wrapper h-8 w-8 cursor-pointer appearance-none rounded-[4px] border-none bg-none"
     value={selectedColor}
    onChange={handleColorChange}
/>

2o7dmzc5

2o7dmzc52#

你的顺风配置有问题。这就是为什么它不工作。Tailwind styling not working in react project

相关问题