代码之家  ›  专栏  ›  技术社区  ›  mayaah

如何更改react instantsearch的复选框颜色和其他样式?

  •  1
  • mayaah  · 技术社区  · 7 年前

    我的项目中有ToggleRefineration复选框,并试图使用“.ais ToggleRefineration checkbox{}”设置其样式,但唯一可以更改的是字体大小,以使复选框变大。颜色和背景色没有任何作用。我想更改复选框的颜色(尤其是选中复选框时的颜色)和其他样式,因为我在网站的其他部分使用BlueprintJS自定义复选框,我希望它们之间的样式保持一致。

    有没有办法做到这一点?

    1 回复  |  直到 7 年前
        1
  •  7
  •   Haroen Viaene Olintonatiuh    7 年前

    要使用 BlueprintJS 组件,可以使用连接器。这些文件是 here 以及连接器的一般指南 here 。这看起来有点像这样:

    import React from "react";
    import { Checkbox } from "@blueprintjs/core";
    import { connectToggleRefinement } from "react-instantsearch/connectors";
    
    const Toggle = ({ refine, currentRefinement, label }) => (
      <Checkbox
        checked={currentRefinement}
        label={label}
        onChange={() => refine(!currentRefinement)}
      />
    );
    const ToggleRefinement = connectToggleRefinement(Toggle);
    
    const App = () => (
      <InstantSearch>
        {/* add the rest of the app */}
        <ToggleRefinement
          attribute="materials"
          value="Made with solid pine"
          label="Solid Pine"
        />
      </InstantSearch>
    );