react-google-recaptcha icon indicating copy to clipboard operation
react-google-recaptcha copied to clipboard

How to center the captcha

Open eichgi opened this issue 5 years ago • 2 comments

Hi there, I read docs but I couldn't find a way to specify styles.

Do you know how could I center the recaptcha box?

eichgi avatar Aug 24 '20 20:08 eichgi

I think adding an outer div to the recaptcha component and centering might help.

<div className={style.form_group_recaptcha}>
       <ReCAPTCHA
              sitekey='siteKey'
              onChange={onChange}
         />
 </div>

In CSS file,

.form_group_recaptcha > div > div {
  display: flex;
  place-content: center;
}

As you can see here you have to go two times to the inner div. Hope this helps you out.

mshiyaf avatar Aug 31 '20 09:08 mshiyaf

@eichgi ^ i like that example from @mshiyaf and additionally think you could center the container that you render the recaptcha in and possibly achieve what you're looking for?

If you'd like some eyes on a possible solution please create a codesandbox.io example, can even fork the example one

hartzis avatar Sep 02 '20 20:09 hartzis