1

There is a checkbox component:

import React, { InputHTMLAttributes } from "react";
import styled, { css } from "styled-components";

export const CheckBox: React.FC<InputHTMLAttributes<HTMLInputElement>> = (
  props
) => {
  return <Input type="checkbox" {...props} />;
};

const Input = styled.input`
  ${({ theme }) => css`
    border: 1px solid white;

    &:checked {
      background-color: green;
      border-color: green;
    }
  `}
`;

I want to set its checked color to another but doesn't work. It's still the default blue background color.


I hope:

Before

enter image description here

After

enter image description here

5
  • Does this answer your question? How to style a checkbox using CSS Commented Jul 1, 2022 at 6:09
  • @jsejcksn accent-color doesn't work for my requirement. I only want to set the mark and border color. Commented Jul 1, 2022 at 6:20
  • You should conditionally render two icons one if checkbox is checked and second when checkbox is not checked Commented Jul 1, 2022 at 8:45
  • If you want to example snippet then let me know into comment Commented Jul 1, 2022 at 8:56
  • @AnujPanwar Yes, if you can show me an example will be very helpful. Commented Jul 1, 2022 at 9:28

1 Answer 1

1

You can create own your component for that but it takes a lot of time.

Checkout into sandbox

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.